From 0ad489f80b3a974027451d305eb11dc20497861f Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Tue, 4 Jul 2023 13:42:40 +0300 Subject: [PATCH] Get default settings without Settings instance Get the default settings of Dangezone for the current version, without having to instantiate the Settings class. Note that instantiating the Settings class also writes the settings to the underlying `settings.json` file, and there are cases where we don't want this behavior. --- dangerzone/settings.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/dangerzone/settings.py b/dangerzone/settings.py index 49db150..f30ec30 100644 --- a/dangerzone/settings.py +++ b/dangerzone/settings.py @@ -22,7 +22,12 @@ class Settings: self.settings_filename = os.path.join( self.dangerzone.appdata_path, "settings.json" ) - self.default_settings: Dict[str, Any] = { + self.default_settings: Dict[str, Any] = self.generate_default_settings() + self.load() + + @classmethod + def generate_default_settings(cls) -> Dict[str, Any]: + return { "save": True, "archive": True, "ocr": True, @@ -38,8 +43,6 @@ class Settings: "updater_errors": 0, } - self.load() - def get(self, key: str) -> Any: return self.settings[key]