def _GetExpectations(self): expects_file = join(self.root, "preparser.expectation") expectations_map = {} if not os.path.exists(expects_file): return expectations_map rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$") for line in utils.ReadLinesFrom(expects_file): rule_match = rule_regex.match(line) if not rule_match: continue expects = [] if (rule_match.group(2)): expects += [rule_match.group(2)] if (rule_match.group(3)): expects += [rule_match.group(3), rule_match.group(4)] expectations_map[rule_match.group(1)] = " ".join(expects) return expectations_map
def GetExpectations(self): expects_file = join(self.root, 'preparser.expectation') map = {} if exists(expects_file): rule_regex = re.compile("^([\w\-]+)(?::([\w\-]+))?(?::(\d+),(\d+))?$") for line in utils.ReadLinesFrom(expects_file): if (line[0] == '#'): continue rule_match = rule_regex.match(line) if rule_match: expects = [] if (rule_match.group(2)): expects = expects + [rule_match.group(2)] if (rule_match.group(3)): expects = expects + [rule_match.group(3), rule_match.group(4)] map[rule_match.group(1)] = expects return map;