Update deep_merge_dicts to disallow null-overrides

This commit is contained in:
Matthias
2022-03-18 06:58:22 +01:00
parent b56aab0bdf
commit fdce055061
2 changed files with 21 additions and 7 deletions

View File

@@ -129,7 +129,7 @@ def format_ms_time(date: int) -> str:
return datetime.fromtimestamp(date/1000.0).strftime('%Y-%m-%dT%H:%M:%S')
def deep_merge_dicts(source, destination):
def deep_merge_dicts(source, destination, allow_null_overrides: bool = True):
"""
Values from Source override destination, destination is returned (and modified!!)
Sample:
@@ -142,8 +142,8 @@ def deep_merge_dicts(source, destination):
if isinstance(value, dict):
# get node or create one
node = destination.setdefault(key, {})
deep_merge_dicts(value, node)
else:
deep_merge_dicts(value, node, allow_null_overrides)
elif value is not None or allow_null_overrides:
destination[key] = value
return destination