Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit d86d75f

Browse files
authored
Merge pull request #9 from Jorgmassih/dev
Fix bug while adding new root keys
2 parents 3e9286b + 946ac2d commit d86d75f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

portainer_deployer/utils/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,17 @@ def recursive_dict(dictionary: dict, keys: list, new_value: Any=None) -> dict:
7070
dict: _description_
7171
"""
7272
if len(keys) == 1:
73-
dictionary[keys[0]] = new_value
73+
truly_boolean = {
74+
'true': True,
75+
'false': False
76+
}
77+
dictionary[keys[0]] = truly_boolean.get(new_value, new_value)
7478

7579
elif not dictionary:
76-
dictionary[keys[0]] = recursive_dict({keys[1:]: {}}, keys[1:], new_value)
80+
dictionary[keys[0]] = recursive_dict({keys[1]: {}}, keys[1:], new_value)
7781

7882
else:
79-
dictionary[keys[0]] = recursive_dict(dictionary[keys[0]], keys[1:], new_value)
83+
dictionary[keys[0]] = recursive_dict(dictionary.get(keys[0], {}), keys[1:], new_value)
8084

8185
return dictionary
8286

0 commit comments

Comments
 (0)