9f7272be8f53ee250e3f35084fac898c26e48e64
[releng.git] / utils / test / result_collection_api / common / config.py
1 ##############################################################################
2 # Copyright (c) 2015 Orange
3 # guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 """
11 from ConfigParser import SafeConfigParser
12
13 parser = SafeConfigParser()
14 parser.read('config.ini')
15
16
17 mongo_url = parser.get('default', 'mongo_url')
18 """
19
20
21 def prepare_put_request(edit_request, key, new_value, old_value):
22     """
23     This function serves to prepare the elements in the update request.
24     We try to avoid replace the exact values in the db
25     edit_request should be a dict in which we add an entry (key) after
26     comparing values
27     """
28     if not (new_value is None):
29         if len(new_value) > 0:
30             if new_value != old_value:
31                 edit_request[key] = new_value
32
33     return edit_request