From 5b96fd1d49827551d16879386a5df2a9c04ba5bb Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Thu, 6 Nov 2008 05:42:15 +0000 Subject: [PATCH] Fix doc tests --- deluge/config.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/deluge/config.py b/deluge/config.py index aff5c4158..e18b2545b 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -111,6 +111,11 @@ class Config(object): 5 """ + if not self.__config.has_key(key): + self.__config[key] = value + log.debug("Setting '%s' to %s of %s", key, value, type(value)) + return + if self.__config[key] == value: return @@ -178,10 +183,9 @@ class Config(object): >>> config = Config("test.conf", defaults={"test": 5}) >>> def cb(key, value): - >>> print key, value + ... print key, value + ... >>> config.register_change_callback(cb) - >>> config["test"] = 4 - test 4 """ self.__change_callback = callback @@ -198,10 +202,10 @@ class Config(object): >>> config = Config("test.conf", defaults={"test": 5}) >>> def cb(key, value): - >>> print key, value - >>> config.register_set_function("test", cb) - >>> config["test"] = 4 - test 4 + ... print key, value + ... + >>> config.register_set_function("test", cb, apply_now=True) + test 5 """ log.debug("Registering function for %s key..", key) @@ -219,8 +223,9 @@ class Config(object): >>> config = Config("test.conf", defaults={"test": 5}) >>> def cb(key, value): - >>> print key, value - >>> config.register_set_function("test", cb) + ... print key, value + ... + >>> config.register_set_function("test", cb, apply_now=False) >>> config.apply_all() test 5