Files
2020-04-08 10:39:44 -07:00

20 lines
674 B
Python

# Borrowed from: https://stackoverflow.com/questions/20656135/python-deep-merge-dictionary-data#20666342
def deepmerge(source, destination):
"""
Merge the first provided ``dict`` into the second.
:param dict source: The ``dict`` to merge into ``destination``
:param dict destination: The ``dict`` that should get updated
:rtype: dict
:returns: ``destination`` modified
"""
for key, value in source.items():
if isinstance(value, dict):
# get node or create one
node = destination.setdefault(key, {})
deepmerge(value, node)
else:
destination[key] = value
return destination