Only set a setting if the entire line parses
This commit is contained in:
parent
a63c1358ca
commit
32fc1f5082
|
@ -226,6 +226,8 @@ Some lines have been ignored.""") % escape(repr(self.rcfilename))
|
||||||
dialog.run()
|
dialog.run()
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
|
print repr(self.values)
|
||||||
|
|
||||||
def _rc_set_callback(self):
|
def _rc_set_callback(self):
|
||||||
def callback(section, key, value):
|
def callback(section, key, value):
|
||||||
if section is None:
|
if section is None:
|
||||||
|
|
|
@ -20,8 +20,8 @@ QuotedStrings = {"'": re.compile(r"'([^'\r\n]*)'"), '"': re.compile(r'"([^"\r\n]
|
||||||
Section = re.compile(r"\[([^\r\n\]]+)\][ \f\t]*")
|
Section = re.compile(r"\[([^\r\n\]]+)\][ \f\t]*")
|
||||||
Setting = re.compile(r"(\w+)\s*=\s*")
|
Setting = re.compile(r"(\w+)\s*=\s*")
|
||||||
|
|
||||||
PaletteColours = '(?:#[0-9a-fA-F]{12}:){15}#[0-9a-fA-F]{12}'
|
PaletteColours = '(?:(?:#[0-9a-fA-F]{12}:){15}#[0-9a-fA-F]{12})'
|
||||||
SingleColour = '#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3}'
|
SingleColour = '(?:#[0-9a-fA-F]{6}|#[0-9a-fA-F]{3})'
|
||||||
|
|
||||||
Colourvalue = re.compile(group(PaletteColours, SingleColour))
|
Colourvalue = re.compile(group(PaletteColours, SingleColour))
|
||||||
Barevalue = re.compile(r'((?:[^\r\n# \f\t]+|[^\r\n#]+(?!' + Ignore.pattern +'))+)')
|
Barevalue = re.compile(r'((?:[^\r\n# \f\t]+|[^\r\n#]+(?!' + Ignore.pattern +'))+)')
|
||||||
|
@ -114,7 +114,7 @@ class ConfigFile:
|
||||||
self._line = ''
|
self._line = ''
|
||||||
|
|
||||||
self._currsection = None
|
self._currsection = None
|
||||||
self._cursetting = None
|
self._currsetting = None
|
||||||
self._currvalue = None
|
self._currvalue = None
|
||||||
self.errors = []
|
self.errors = []
|
||||||
|
|
||||||
|
@ -164,8 +164,16 @@ class ConfigFile:
|
||||||
|
|
||||||
def _value(self, value):
|
def _value(self, value):
|
||||||
dbg("Value %s" % repr(value))
|
dbg("Value %s" % repr(value))
|
||||||
try:
|
self._currvalue = value
|
||||||
self.callback(self._currsection, self._currsetting, value)
|
|
||||||
except ValueError, e:
|
def _line_ok(self):
|
||||||
raise ConfigSyntaxError(str(e), self)
|
section, setting, value = self._currsection, self._currsetting, self._currvalue
|
||||||
|
if value is None: return
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.callback(self._currsection, self._currsetting, self._currvalue)
|
||||||
|
except ValueError, e:
|
||||||
|
raise ConfigSyntaxError(str(e), self)
|
||||||
|
finally:
|
||||||
|
self._currvalue = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue