mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 16:14:21 +00:00
Update merge_dicts to recursively merge the dictionaries
Previously it was only merging dictionary at the first/top level
This commit is contained in:
parent
a876b652d8
commit
3abf3e5ee0
1 changed files with 3 additions and 1 deletions
|
@ -30,11 +30,13 @@ def get_from_dict(dictionary, *args):
|
|||
return current
|
||||
|
||||
|
||||
def merge_dicts(priority_dict, default_dict):
|
||||
def merge_dicts(priority_dict: dict, default_dict: dict):
|
||||
merged_dict = priority_dict.copy()
|
||||
for key, _ in default_dict.items():
|
||||
if key not in priority_dict:
|
||||
merged_dict[key] = default_dict[key]
|
||||
elif isinstance(priority_dict[key], dict) and isinstance(default_dict[key], dict):
|
||||
merged_dict[key] = merge_dicts(priority_dict[key], default_dict[key])
|
||||
return merged_dict
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue