added code

This commit is contained in:
2025-09-10 10:37:55 +02:00
parent 36901c736d
commit c78a68de80
199 changed files with 3561 additions and 22579 deletions
+19
View File
@@ -150,3 +150,22 @@ def convert_for_json(obj):
return obj.item()
else:
return obj
def recursive_dict_update(current_dict: dict, update_dict: dict) -> dict:
for key, value in update_dict.items():
if key not in current_dict:
current_dict[key] = value
else:
if isinstance(value, list):
if not isinstance(current_dict[key], list):
raise ValueError(f"Type mismatch, {type(current_dict[key])} is not a list")
current_dict[key] = current_dict[key] + value
elif isinstance(value, dict):
if not isinstance(current_dict[key], dict):
raise ValueError(f"Type mismatch, {type(current_dict[key])} is not a dict")
current_dict[key] = recursive_dict_update(current_dict[key], value)
else:
current_dict[key] = value
return current_dict