Add base and display snippets, initial generation works
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from typing import Any, Dict
|
||||
|
||||
|
||||
def deep_merge(a: Dict[str, Any], b: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""Recursively merge b into a and return a new dict.
|
||||
|
||||
Lists are concatenated; scalar values in b override a.
|
||||
"""
|
||||
result = dict(a)
|
||||
for k, v in b.items():
|
||||
if k in result:
|
||||
if isinstance(result[k], dict) and isinstance(v, dict):
|
||||
result[k] = deep_merge(result[k], v)
|
||||
elif isinstance(result[k], list) and isinstance(v, list):
|
||||
result[k] = result[k] + v
|
||||
else:
|
||||
result[k] = v
|
||||
else:
|
||||
result[k] = v
|
||||
return result
|
||||
Reference in New Issue
Block a user