Skip to content
Snippets Groups Projects
Commit 5d5bafb1 authored by Lauri Himanen's avatar Lauri Himanen
Browse files

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
Branches
Tags 1.2.0
No related merge requests found
...@@ -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
# Emit fixed start values
if self.matcher.fixedStartValues: if self.matcher.fixedStartValues:
for k,v in sorted(self.matcher.fixedStartValues.items()): for k,v in sorted(self.matcher.fixedStartValues.items()):
if k not in result_dict: if k not in result_dict:
v_converted = self.addValue(parser.backend, k, v) v_converted = self.addValue(parser.backend, k, v)
result_dict[k] = v_converted 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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment