From 466fbb9121007b53fa6d3ff4db0f3756f50f2c97 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 7c5532c94..5f5e1a2d2 100644 --- a/dangerzone/settings.py +++ b/dangerzone/settings.py @@ -20,7 +20,12 @@ def __init__(self, dangerzone: "DangerzoneCore") -> None: 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 @@ def __init__(self, dangerzone: "DangerzoneCore") -> None: }, } - self.load() - def get(self, key: str) -> Any: return self.settings[key]