in lib/core/config.py [0:0]
def merge_dicts(dict_a, dict_b):
from ast import literal_eval
for key, value in dict_a.items():
if key not in dict_b:
raise KeyError('Invalid key in config file: {}'.format(key))
if type(value) is dict:
dict_a[key] = value = AttrDict(value)
if isinstance(value, str):
try:
value = literal_eval(value)
except BaseException:
pass
# the types must match, too
old_type = type(dict_b[key])
if old_type is not type(value) and value is not None:
raise ValueError(
'Type mismatch ({} vs. {}) for config key: {}'.format(
type(dict_b[key]), type(value), key)
)
# recursively merge dicts
if isinstance(value, AttrDict):
try:
merge_dicts(dict_a[key], dict_b[key])
except BaseException:
raise Exception('Error under config key: {}'.format(key))
else:
dict_b[key] = value