Rename recursive_dict_update's parameters for clarity.
This commit is contained in:
parent
f266e1c79c
commit
dec28b321a
2 changed files with 8 additions and 8 deletions
|
@ -231,20 +231,20 @@ def read_filebytes(filepath, range_min, range_max, chunk_size=2 ** 20):
|
|||
yield chunk
|
||||
sent_amount += len(chunk)
|
||||
|
||||
def recursive_dict_update(d1, d2):
|
||||
def recursive_dict_update(target, supply):
|
||||
'''
|
||||
Update d1 using d2, but when the value is a dictionary update the insides
|
||||
instead of replacing the dictionary itself.
|
||||
Update target using supply, but when the value is a dictionary update the
|
||||
insides instead of replacing the dictionary itself.
|
||||
'''
|
||||
for (key, value) in d2.items():
|
||||
for (key, value) in supply.items():
|
||||
if isinstance(value, dict):
|
||||
existing = d1.get(key, None)
|
||||
existing = target.get(key, None)
|
||||
if existing is None:
|
||||
d1[key] = value
|
||||
target[key] = value
|
||||
else:
|
||||
recursive_dict_update(existing, value)
|
||||
else:
|
||||
d1[key] = value
|
||||
target[key] = value
|
||||
|
||||
def recursive_dict_keys(d):
|
||||
'''
|
||||
|
|
|
@ -1087,7 +1087,7 @@ class PhotoDB(PDBAlbumMixin, PDBBookmarkMixin, PDBPhotoMixin, PDBTagMixin, PDBUs
|
|||
my_keys = helpers.recursive_dict_keys(config)
|
||||
stored_keys = helpers.recursive_dict_keys(user_config)
|
||||
needs_dump = not my_keys.issubset(stored_keys)
|
||||
helpers.recursive_dict_update(config, user_config)
|
||||
helpers.recursive_dict_update(target=config, supply=user_config)
|
||||
|
||||
if (not user_config_exists) or needs_dump:
|
||||
with open(self.config_filepath.absolute_path, 'w') as handle:
|
||||
|
|
Loading…
Reference in a new issue