1 # Copyright 2016 ZTE Corporation.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
17 logger = logging.getLogger(__name__)
20 def ignore_case_get(args, key, def_val=""):
26 if old_key.upper() == key.upper():
31 def remove_none_key(data, none_list=None):
32 none_list = none_list if none_list else [None, '', 'NULL', 'None', 'null', {}, '{}']
33 if isinstance(data, dict):
34 data = dict([(k, remove_none_key(v)) for k, v in list(data.items()) if v not in none_list])
35 if isinstance(data, list):
36 data = [remove_none_key(s) for s in data if s not in none_list]
40 def update_value(origin_data, new_data):
41 logger.debug(origin_data)
42 if not isinstance(origin_data, dict):
43 str_data = origin_data.encode('utf-8')
44 logger.debug(str_data)
45 origin_data = eval(str_data)
46 logger.debug(isinstance(origin_data, dict))
47 logger.debug(new_data)
48 for k, v in list(new_data.items()):
49 if k not in origin_data:
52 if isinstance(origin_data[k], list):
53 origin_data[k] = origin_data[k].extend(v)