feat(config): Config loading and merging

This commit is contained in:
2026-05-03 15:09:05 +02:00
parent 190fb86758
commit 7b1dfe6ebc
9 changed files with 176 additions and 37 deletions
+28 -2
View File
@@ -1,3 +1,4 @@
from typing import cast
from config.dtype import ArchMgrConfig
@@ -5,5 +6,30 @@ def merge_configs(config: ArchMgrConfig, new_config: ArchMgrConfig) -> ArchMgrCo
if len(new_config) == 0 or len(config) == 0:
return config
# Merge configs
return config
def combine(a: dict, b: dict):
combined = {}
for key in b:
val = b[key]
try:
a[key]
if isinstance(val, dict):
combined[key] = combine(val, a[key])
elif isinstance(val, list):
combined[key] = val
for v in a[key]:
combined[key].append(v)
else:
combined[key] = val
except KeyError:
combined[key] = val
for key in a:
try:
b[key]
except KeyError:
combined[key] = a[key]
return combined
# Merge configs (using nasty casts)
return cast(ArchMgrConfig, combine(cast(dict, config), cast(dict, new_config)))