Deluge Config Module
Bases: object
This class is used to access/create/modify config files
Parameters: |
|
---|
Calls all set functions
Usage
>>> config = Config("test.conf", defaults={"test": 5})
>>> def cb(key, value):
... print key, value
...
>>> config.register_set_function("test", cb, apply_now=False)
>>> config.apply_all()
test 5
Gets the value of item ‘key’
Parameters: |
|
---|---|
Returns: | the value of item ‘key’ |
Raises KeyError: | |
if ‘key’ is not in the config dictionary |
Usage
>>> config = Config("test.conf", defaults={"test": 5})
>>> config["test"]
5
Load a config file
Parameters: |
|
---|
Registers a callback function that will be called when a value is changed in the config dictionary
Parameters: |
|
---|
Usage
>>> config = Config("test.conf", defaults={"test": 5})
>>> def cb(key, value):
... print key, value
...
>>> config.register_change_callback(cb)
Register a function to be called when a config value changes
Parameters: |
|
---|
Usage
>>> config = Config("test.conf", defaults={"test": 5})
>>> def cb(key, value):
... print key, value
...
>>> config.register_set_function("test", cb, apply_now=True)
test 5
Save configuration to disk
Parameters: |
|
---|
Sets item ‘key’ to ‘value’ in the config dictionary, but does not allow changing the item’s type unless it is None
Parameters: |
|
---|---|
Raises ValueError: | |
raised when the type of value is not the same as what is currently in the config |
Usage
>>> config = Config("test.conf")
>>> config["test"] = 5
>>> config["test"]
5