Skip to content

Commit

Permalink
Configuration update fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuchulain committed Oct 12, 2023
1 parent 470f023 commit 6c89e43
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion config.py
Expand Up @@ -56,9 +56,22 @@ def get_values():

parameters = toml.load(full_path)

merged_parameters = parameters | DEFAULT_VALUES
merged_parameters = merge_dicts(DEFAULT_VALUES, parameters)

if parameters != merged_parameters:
toml.dump(merged_parameters, open(full_path, 'w'))

return merged_parameters


def merge_dicts(tgt, enhancer):
for key, val in enhancer.items():
if key not in tgt:
tgt[key] = val
continue

if isinstance(val, dict):
merge_dicts(tgt[key], val)
else:
tgt[key] = val
return tgt

0 comments on commit 6c89e43

Please sign in to comment.