From f9a4a36b341b1d866269f568e86cbf63b90b5f63 Mon Sep 17 00:00:00 2001 From: Necoro <> Date: Mon, 14 Jan 2008 16:45:06 +0000 Subject: r609@Devoty: necoro | 2008-01-14 17:04:38 +0100 Allowed '-' and '_' in key names. Also use group names instead of their number. r610@Devoty: necoro | 2008-01-14 17:05:42 +0100 Disabled saving of the queues r611@Devoty: necoro | 2008-01-14 17:08:53 +0100 Added the possibility to permanently en-/disable plugins r612@Devoty: necoro | 2008-01-14 17:14:09 +0100 adjust changelog and translations r613@Devoty: necoro | 2008-01-14 17:40:53 +0100 Dropdown should be localized too --- portato/config_parser.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'portato/config_parser.py') diff --git a/portato/config_parser.py b/portato/config_parser.py index b2b47a6..30d5d28 100644 --- a/portato/config_parser.py +++ b/portato/config_parser.py @@ -43,8 +43,8 @@ COMMENT = [";","#"] # precompiled expressions TRUE = re.compile("((true)|(1)|(on)|(wahr)|(ja)|(yes))", re.I) FALSE = re.compile("((false)|(0)|(off)|(falsch)|(nein)|(no))", re.I) -SECTION = re.compile("\s*\[(\w+)\]\s*") -EXPRESSION = re.compile(r"\s*(\w+)\s*[:=]\s*(.*)\s*") +SECTION = re.compile("\s*\[(?P\w(\w|[-_])*)\]\s*") +EXPRESSION = re.compile(r"\s*(?P\w(\w|[-_])*)\s*[:=]\s*(?P.*)\s*") class Value (object): """Class defining a value of a key. @@ -187,7 +187,7 @@ class ConfigParser: # look for a section match = SECTION.search(line) if match: - sec = match.group(1).upper() + sec = match.group("name").upper() self.sections[sec] = count if sec != section: self.vars[sec] = {} @@ -197,7 +197,7 @@ class ConfigParser: # look for an expression match = EXPRESSION.search(line) if match: - val = match.group(2) + val = match.group("value") # find the boolean value bool = None @@ -207,9 +207,9 @@ class ConfigParser: bool = False # insert - key = match.group(1).lower() + key = match.group("key").lower() self.vars[section][key] = Value(val, count, bool = bool) - self.pos[count] = match.span(2) + self.pos[count] = match.span("value") else: # neither comment nor empty nor expression nor section => error error(_("Unrecognized line in configuration: %s"), line) @@ -252,7 +252,7 @@ class ConfigParser: if val.is_bool(): return val.boolean - raise ValueError, "\"%s\" is not a boolean." % key + raise ValueError, "\"%s\" is not a boolean. (%s)" % (key, val.value) def set (self, key, value = "", section = "MAIN"): """Sets a new value of a given key in a section. -- cgit v1.2.3