mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-16 13:26:33 +00:00
[Config] Replace custom property decorator
This commit is contained in:
parent
a684029602
commit
099077fe20
@ -51,23 +51,6 @@ from deluge.common import JSON_FORMAT, get_default_config_dir
|
|||||||
log = logging.getLogger(__name__)
|
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()):
|
def find_json_objects(text, decoder=json.JSONDecoder()):
|
||||||
"""Find json objects in text.
|
"""Find json objects in text.
|
||||||
|
|
||||||
@ -546,14 +529,11 @@ class Config:
|
|||||||
def config_file(self):
|
def config_file(self):
|
||||||
return self.__config_file
|
return self.__config_file
|
||||||
|
|
||||||
@prop
|
@property
|
||||||
def config(): # pylint: disable=no-method-argument
|
def config(self):
|
||||||
"""The config dictionary"""
|
"""The config dictionary"""
|
||||||
|
return self.__config
|
||||||
|
|
||||||
def fget(self):
|
@config.deleter
|
||||||
return self.__config
|
def config(self):
|
||||||
|
return self.save()
|
||||||
def fdel(self):
|
|
||||||
return self.save()
|
|
||||||
|
|
||||||
return locals()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user