[Config] Replace custom property decorator

This commit is contained in:
Calum Lind 2022-02-05 10:31:31 +00:00
parent a684029602
commit 099077fe20
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
1 changed files with 6 additions and 26 deletions

View File

@ -51,23 +51,6 @@ from deluge.common import JSON_FORMAT, get_default_config_dir
log = logging.getLogger(__name__)
def prop(func):
"""Function decorator for defining property attributes
The decorated function is expected to return a dictionary
containing one or more of the following pairs:
fget - function for getting attribute value
fset - function for setting attribute value
fdel - function for deleting attribute
This can be conveniently constructed by the locals() builtin
function; see:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183
"""
return property(doc=func.__doc__, **func())
def find_json_objects(text, decoder=json.JSONDecoder()):
"""Find json objects in text.
@ -546,14 +529,11 @@ class Config:
def config_file(self):
return self.__config_file
@prop
def config(): # pylint: disable=no-method-argument
@property
def config(self):
"""The config dictionary"""
return self.__config
def fget(self):
return self.__config
def fdel(self):
return self.save()
return locals()
@config.deleter
def config(self):
return self.save()