From fe1a7f4c91639588598c74a0c27a91192fbba78b Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 7 Aug 2010 15:26:52 +0200 Subject: hook improvements --- module/ConfigParser.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'module/ConfigParser.py') diff --git a/module/ConfigParser.py b/module/ConfigParser.py index 42dce1858..91396a83b 100644 --- a/module/ConfigParser.py +++ b/module/ConfigParser.py @@ -235,10 +235,13 @@ class ConfigParser: #---------------------------------------------------------------------- def cast(self, typ, value): """cast value to given format""" + if type(value) not in (str, unicode): + return value + if typ == "int": return int(value) elif typ == "bool": - return True if value.lower() in ("true", "on", "an","yes") else False + return True if value.lower() in ("1","true", "on", "an","yes") else False else: return value @@ -278,6 +281,9 @@ class ConfigParser: #---------------------------------------------------------------------- def set(self, section, option, value): """set value""" + + value = self.cast(self.config[section][option]["type"], value) + self.config[section][option]["value"] = value self.save() @@ -289,6 +295,9 @@ class ConfigParser: #---------------------------------------------------------------------- def setPlugin(self, plugin, option, value): """sets a value for a plugin""" + + value = self.cast(self.plugin[plugin][option]["type"], value) + self.plugin[plugin][option]["value"] = value self.save() -- cgit v1.2.3