Module: deluge Branch: multiuser Commit: 4b3a515ef7f653a239f00d2e70f266d5c39c7b8f
Author: Pedro Algarvio <[email protected]> Date: Thu Dec 23 18:56:40 2010 +0000 Keep consistency on `deluge.config`. --- deluge/config.py | 29 +++++++++++++++++++++++++---- 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/deluge/config.py b/deluge/config.py index d15aafd..6be5c13 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -71,6 +71,7 @@ import cPickle as pickle import shutil import os +from twisted.internet import reactor import deluge.common from deluge.log import LOG as log @@ -217,7 +218,6 @@ what is currently in the config and it could not convert the value self.__config[key] = value # Run the set_function for this key if any - from twisted.internet import reactor try: for func in self.__set_functions[key]: reactor.callLater(0, func, key, value) @@ -242,9 +242,6 @@ what is currently in the config and it could not convert the value """ return self.get_item(key) - def __delitem__(self, key): - del self.__config[key] - def get_item(self, key): """ Gets the value of item 'key' @@ -269,6 +266,30 @@ what is currently in the config and it could not convert the value else: return self.__config[key] + def __delitem__(self, key): + """ + See + :meth:`del_item` + """ + self.del_item(key) + + def del_item(self, key): + """ + Deletes item with a specific key from the configuration. + + :param key: the item which you wish to delete. + :raises KeyError: if 'key' is not in the config dictionary + + **Usage** + >>> config = Config("test.conf", defaults={"test": 5}) + >>> del config["test"] + """ + del self.__config[key] + # We set the save_timer for 5 seconds if not already set + if not self._save_timer or not self._save_timer.active(): + self._save_timer = reactor.callLater(5, self.save) + + def register_change_callback(self, callback): """ Registers a callback function that will be called when a value is changed in the config dictionary -- You received this message because you are subscribed to the Google Groups "deluge-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/deluge-commit?hl=en.
