Skip to content

Commit

Permalink
Get default settings without Settings instance
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apyrgio committed Jul 20, 2023
1 parent b4b7833 commit c9f264b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dangerzone/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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,
Expand All @@ -38,8 +43,6 @@ def __init__(self, dangerzone: "DangerzoneCore") -> None:
"updater_errors": 0,
}

self.load()

def get(self, key: str) -> Any:
return self.settings[key]

Expand Down

0 comments on commit c9f264b

Please sign in to comment.