Commit 5d5bafb1 authored by Lauri Himanen's avatar Lauri Himanen

Fixed bug with caused clash in handling starReTransform and fixedStartValues...

Fixed bug with caused clash in handling starReTransform and fixedStartValues on the same SimpleMatcher.
parent 27dc5d91
...@@ -636,25 +636,30 @@ class CompiledMatcher(object): ...@@ -636,25 +636,30 @@ class CompiledMatcher(object):
result_dict = {} result_dict = {}
# If a separate transform function was defined in the matcher, call it # If a separate transform function was defined in the matcher, call it
# and do nothing else. # and ignore any named groups.
if self.matcher.startReTransform is not None: if self.matcher.startReTransform is not None:
self.matcher.startReTransform(parser.backend, m.groups()) self.matcher.startReTransform(parser.backend, m.groups())
else: else:
for k,v in sorted(m.groupdict().items()): for k,v in sorted(m.groupdict().items()):
if v is None: if v is None:
# a group may be optional (subexpression of ? or | in regex) # a group may be optional (subexpression of ? or | in regex)
continue continue
k_converted, v_converted = self.addStrValue(parser.backend, k, v) k_converted, v_converted = self.addStrValue(parser.backend, k, v)
result_dict[k_converted] = v_converted result_dict[k_converted] = v_converted
if self.matcher.fixedStartValues:
for k,v in sorted(self.matcher.fixedStartValues.items()): # Emit fixed start values
if k not in result_dict: if self.matcher.fixedStartValues:
v_converted = self.addValue(parser.backend, k, v) for k,v in sorted(self.matcher.fixedStartValues.items()):
result_dict[k] = v_converted if k not in result_dict:
v_converted = self.addValue(parser.backend, k, v)
result_dict[k] = v_converted
# If the match needs to be forwarded, push the read line back into the
# file stream
if self.matcher.forwardMatch: if self.matcher.forwardMatch:
logger.debug("handleStartMatch of %s on (%s) pushing back line", self.matcher.desc(),line) logger.debug("handleStartMatch of %s on (%s) pushing back line", self.matcher.desc(),line)
parser.fIn.pushbackLine(line) parser.fIn.pushbackLine(line)
return result_dict return result_dict
def handleEndMatch(self, parser): def handleEndMatch(self, parser):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment