# HG changeset patch # User Paul Boddie # Date 1531692489 -7200 # Node ID d160ea01a5cf86eef0185d8456c66fe5a0cbad1a # Parent 225f92510d629d692de720612d0dac7940855b9d Remove the prefix from each key in the groups dictionary. diff -r 225f92510d62 -r d160ea01a5cf moinformat/parsers/common.py --- a/moinformat/parsers/common.py Mon Jul 16 00:04:23 2018 +0200 +++ b/moinformat/parsers/common.py Mon Jul 16 00:08:09 2018 +0200 @@ -191,10 +191,12 @@ "Filter groups from the current match for the matching pattern." + prefix = "%s_" % self.matching + d = {} for key, value in self.match.groupdict().items(): - if key.startswith("%s_" % self.matching): - d[key] = value + if key.startswith(prefix): + d[key[len(prefix):]] = value return d def match_group(self, group=None): @@ -211,7 +213,7 @@ if group is None: return self.s[self.start:self.end] else: - return self.groups.get("%s_%s" % (self.matching, group)) + return self.groups.get(group) else: return None @@ -227,7 +229,7 @@ else: l = [] for group in groups: - l.append(self.groups.get("%s_%s" % (self.matching, group))) + l.append(self.groups.get(group)) return l else: return []