Actually set a colour value. Only set config options if the entire line parses correctly.

This commit is contained in:
Thomas Hurst 2008-08-27 01:51:37 +01:00
parent e7467bfeba
commit c2524cec47
2 changed files with 18 additions and 4 deletions

View File

@ -238,6 +238,7 @@ Some lines have been ignored.""") % escape(repr(self.rcfilename))
if key.endswith('_color'): if key.endswith('_color'):
try: try:
gtk.gdk.color_parse(value) gtk.gdk.color_parse(value)
self.values[key] = value
except ValueError: except ValueError:
err(_("Setting %s value %s not a valid colour; ignoring") % (key,repr(value))) err(_("Setting %s value %s not a valid colour; ignoring") % (key,repr(value)))
continue continue
@ -268,6 +269,7 @@ Some lines have been ignored.""") % escape(repr(self.rcfilename))
except Exception, e: except Exception, e:
dbg (" VS_RCFile: %s Exception handling: %s" % (type(e), key)) dbg (" VS_RCFile: %s Exception handling: %s" % (type(e), key))
pass pass
dbg("Config parsed as: %s" % repr(self.values))
class TerminatorConfValuestoreGConf (TerminatorConfValuestore): class TerminatorConfValuestoreGConf (TerminatorConfValuestore):
profile = "" profile = ""

View File

@ -142,6 +142,8 @@ class ConfigFile:
if self._line[self._pos:] != '': if self._line[self._pos:] != '':
raise ConfigSyntaxError(_("Unexpected token"), self) raise ConfigSyntaxError(_("Unexpected token"), self)
self._line_ok()
except ConfigSyntaxError, e: except ConfigSyntaxError, e:
if self.errors_are_fatal: if self.errors_are_fatal:
raise e raise e
@ -161,8 +163,18 @@ class ConfigFile:
def _value(self, value): def _value(self, value):
dbg("Value %s" % repr(value)) dbg("Value %s" % repr(value))
if self._currsection is not None: self._currvalue = value
self.settings.setdefault(self._currsection, {})[self._currsetting] = value
else: def _line_ok(self):
self.settings[self._currsetting] = value if self._currvalue is None: return
try:
if self._currsection is not None:
try:
self.settings.setdefault(self._currsection, {})[self._currsetting] = self._currvalue
except TypeError, e:
raise ConfigSyntaxError(_("Section %s is being used as a setting name" % repr(self._currsection)), self)
else:
self.settings[self._currsetting] = self._currvalue
finally:
self._currvalue = None