diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:38:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 21:38:38 +0000 |
commit | 2e2851dc13d73352530dd4495c7e05603b2e520d (patch) | |
tree | 622b9cd8e5d32091c9aa9e4937b533975a40356c /deluge/ui/coreconfig.py | |
parent | Initial commit. (diff) | |
download | deluge-ba36a3baaa52c6e8dc58a724548d75d3db6e8ef9.tar.xz deluge-ba36a3baaa52c6e8dc58a724548d75d3db6e8ef9.zip |
Adding upstream version 2.1.2~dev0+20240219.upstream/2.1.2_dev0+20240219upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/ui/coreconfig.py')
-rw-r--r-- | deluge/ui/coreconfig.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/deluge/ui/coreconfig.py b/deluge/ui/coreconfig.py new file mode 100644 index 0000000..1e2927b --- /dev/null +++ b/deluge/ui/coreconfig.py @@ -0,0 +1,51 @@ +# +# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com> +# +# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with +# the additional special exception to link portions of this program with the OpenSSL library. +# See LICENSE for more details. +# + +import logging + +import deluge.component as component +from deluge.ui.client import client + +log = logging.getLogger(__name__) + + +class CoreConfig(component.Component): + def __init__(self): + log.debug('CoreConfig init..') + component.Component.__init__(self, 'CoreConfig') + self.config = {} + + def on_configvaluechanged_event(key, value): + self.config[key] = value + + client.register_event_handler( + 'ConfigValueChangedEvent', on_configvaluechanged_event + ) + + def start(self): + def on_get_config(config): + self.config = config + return config + + return client.core.get_config().addCallback(on_get_config) + + def stop(self): + self.config = {} + + def __contains__(self, key): + return key in self.config + + def __getitem__(self, key): + return self.config[key] + + def __setitem__(self, key, value): + client.core.set_config({key: value}) + + def __getattr__(self, attr): + # We treat this directly interacting with the dictionary + return getattr(self.config, attr) |