mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 10:12:38 +02:00
Make it easier to get and save updater settings
Add the following two features in the Settings class: 1. Add a way to save the settings, if the contents of a key have changed. 2. Add a way to get all the updater settings, by getting fetching the keys that start with `"updater_"`.
This commit is contained in:
parent
2df459bcfc
commit
266addb5b7
1 changed files with 9 additions and 1 deletions
|
@ -43,8 +43,16 @@ class Settings:
|
|||
def get(self, key: str) -> Any:
|
||||
return self.settings[key]
|
||||
|
||||
def set(self, key: str, val: Any) -> None:
|
||||
def set(self, key: str, val: Any, autosave: bool = False) -> None:
|
||||
old_val = self.get(key)
|
||||
self.settings[key] = val
|
||||
if autosave and val != old_val:
|
||||
self.save()
|
||||
|
||||
def get_updater_settings(self) -> Dict[str, Any]:
|
||||
return {
|
||||
key: val for key, val in self.settings.items() if key.startswith("updater_")
|
||||
}
|
||||
|
||||
def load(self) -> None:
|
||||
if os.path.isfile(self.settings_filename):
|
||||
|
|
Loading…
Reference in a new issue