From dec28b321aa2d451dd03a5cf8ed126e22413d78b Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 3 Feb 2018 01:10:54 -0800 Subject: [PATCH] Rename recursive_dict_update's parameters for clarity. --- etiquette/helpers.py | 14 +++++++------- etiquette/photodb.py | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/etiquette/helpers.py b/etiquette/helpers.py index 24e6076..cc3fe2e 100644 --- a/etiquette/helpers.py +++ b/etiquette/helpers.py @@ -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): ''' diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 82c1e45..cefb325 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -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: