From 941d50eae0920a1d2675acb0a8dcdc63deb04155 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 17 Mar 2018 17:05:34 -0700 Subject: [PATCH] Move config saving to own method. --- etiquette/photodb.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 8f7ab72..937d9f8 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -1184,12 +1184,19 @@ class PhotoDB( stored_keys = helpers.recursive_dict_keys(user_config) needs_dump = not my_keys.issubset(stored_keys) helpers.recursive_dict_update(target=config, supply=user_config) + else: + needs_dump = True - if (not user_config_exists) or needs_dump: - with open(self.config_filepath.absolute_path, 'w') as handle: - handle.write(json.dumps(config, indent=4, sort_keys=True)) + if needs_dump: + self._save_config() + + self.config = config return config + def _save_config(self): + with open(self.config_filepath.absolute_path, 'w') as handle: + handle.write(json.dumps(self.config, indent=4, sort_keys=True)) + def __del__(self): self.close()