Commit 8435b6f2 authored by ale's avatar ale

extend pattern auto-extraction with support for user-specified regexps matches

parent ed85f669
......@@ -7,13 +7,15 @@ log = logging.getLogger(__name__)
class Pattern(object):
_tag_pattern = re.compile(r'@(\w+)@')
_tag_pattern = re.compile(r'@(\w+)(?::(.*[^\\]))?@')
def __init__(self, str):
def __init__(self, s):
self.groups = []
for match in self._tag_pattern.findall(str):
self.groups.append(match.lower())
self.regex = re.compile(self._tag_pattern.sub("(.+)", str))
def _rs(match):
self.groups.append(match.group(1).lower())
pattern = self.group(2) or '.+'
return '(%s)' % pattern
self.regex = re.compile(self._tag_pattern.sub(_rs, s))
class PatternExtractor(object):
......
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