Mercurial > hg > truffle
diff mx/outputparser.py @ 11514:dc3c8df55905
added support for pylint and fixed errors/warnings it found
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 03 Sep 2013 16:33:41 +0200 |
parents | 2025455e7d80 |
children |
line wrap: on
line diff
--- a/mx/outputparser.py Tue Sep 03 14:14:09 2013 +0200 +++ b/mx/outputparser.py Tue Sep 03 16:33:41 2013 +0200 @@ -26,13 +26,13 @@ import re class OutputParser: - + def __init__(self): self.matchers = [] - + def addMatcher(self, matcher): self.matchers.append(matcher) - + def parse(self, output): valueMaps = [] for matcher in self.matchers: @@ -47,12 +47,12 @@ given as the group name enclosed in '<' and '>'. """ class ValuesMatcher: - + def __init__(self, regex, valuesTemplate): assert isinstance(valuesTemplate, dict) self.regex = regex self.valuesTemplate = valuesTemplate - + def parse(self, text, valueMaps): for match in self.regex.finditer(text): valueMap = {} @@ -62,10 +62,10 @@ assert not valueMap.has_key(key), key valueMap[key] = value valueMaps.append(valueMap) - + def get_template_value(self, match, template): def replace_var(m): groupName = m.group(1) return match.group(groupName) - + return re.sub(r'<([\w]+)>', replace_var, template)