1
0

commands: getconfig to use default values, add existence checks

- getconfig and setconfig now both check configvars for existence
- getconfig returns default values when applicable
- setconfig does not side-step type-checks for values

fixes https://github.com/spesmilo/electrum/issues/8607
closes https://github.com/spesmilo/electrum/pull/8608
This commit is contained in:
SomberNight
2023-09-08 14:55:22 +00:00
parent 552bfb589a
commit 8c9fec4ab8
4 changed files with 43 additions and 3 deletions

View File

@@ -160,6 +160,15 @@ class Plugins(DaemonThread):
p.close()
self.logger.info(f"closed {name}")
@classmethod
def is_plugin_enabler_config_key(cls, key: str) -> bool:
if not key.startswith('use_'):
return False
# note: the 'use_' prefix is not sufficient to check, there are
# non-plugin-related config keys that also have it... hence:
name = key[4:]
return name in cls.find_all_plugins()
def toggle(self, name: str) -> Optional['BasePlugin']:
p = self.get(name)
return self.disable(name) if p else self.enable(name)