mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 05:32:30 +08:00
20 lines
674 B
Python
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
|