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.
This commit is contained in:
Alex Pyrgiotis 2023-07-04 13:42:40 +03:00
parent 266addb5b7
commit 0ad489f80b
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -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]