From 4e68f79ace6e4f061945936b949bf445539c33ed Mon Sep 17 00:00:00 2001 From: Zev Lee <60147316+zevlee@users.noreply.github.com> Date: Sun, 30 Oct 2022 04:38:04 -0500 Subject: [PATCH] Change when settings are saved Only save settings when generating password if the settings have changed --- lib/window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/window.py b/lib/window.py index fc50a98..e61f9bf 100644 --- a/lib/window.py +++ b/lib/window.py @@ -270,15 +270,16 @@ def _generate_password(self): generated = password.generate_password() self.password.set_text(generated) self.password_length.set_text(f"Length: {len(generated)}") - # Save the settings used to generate the password + # Save the settings used to generate the password if changed for k, v in zip( ["lst", "mnw", "mxw", "wrd", "sep", "cap", "num", "sym"], [lst, mnw, mxw, wrd, sep, cap, num, sym] ): self.config[k] = v - with open(join(Utils.CONFIG_DIR, "settings.json"), "w") as c: - c.write(dumps(self.config)) - c.close() + if Utils.read_config("settings.json") != self.config: + with open(join(Utils.CONFIG_DIR, "settings.json"), "w") as c: + c.write(dumps(self.config)) + c.close() def on_generate_clicked(self, button): """