diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-03-25 15:18:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-03-25 15:18:36 -0400 |
commit | c81b2b09eadf8ee8775f61831db055425bcf7d27 (patch) | |
tree | 83988789bada3aa6f47180efdeb55d0830edbc52 /scripts | |
parent | d4d541c53c209370ae33f5f6caad2ec13743a4ba (diff) | |
parent | 135b51c9d3436b3afcf323a193c755deafa53f7d (diff) | |
download | tor-c81b2b09eadf8ee8775f61831db055425bcf7d27.tar.gz tor-c81b2b09eadf8ee8775f61831db055425bcf7d27.zip |
Merge branch 'practracker_comments'
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/maint/practracker/problem.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/scripts/maint/practracker/problem.py b/scripts/maint/practracker/problem.py index ab3d55057e..d5ebedd17f 100644 --- a/scripts/maint/practracker/problem.py +++ b/scripts/maint/practracker/problem.py @@ -10,6 +10,7 @@ get worse. from __future__ import print_function import os.path +import re import sys class ProblemVault(object): @@ -30,8 +31,15 @@ class ProblemVault(object): def register_exceptions(self, exception_file): # Register exceptions - for line in exception_file: - problem = get_old_problem_from_exception_str(line) + for lineno, line in enumerate(exception_file, 1): + try: + problem = get_old_problem_from_exception_str(line) + except ValueError as v: + print("Exception file line {} not recognized: {}" + .format(lineno,v), + file=sys.stderr) + continue + if problem is None: continue @@ -122,11 +130,20 @@ class FunctionSizeProblem(Problem): def __init__(self, problem_location, metric_value): super(FunctionSizeProblem, self).__init__("function-size", problem_location, metric_value) +comment_re = re.compile(r'#.*$') + def get_old_problem_from_exception_str(exception_str): - try: - _, problem_type, problem_location, metric_value = exception_str.split(" ") - except ValueError: + orig_str = exception_str + exception_str = comment_re.sub("", exception_str) + fields = exception_str.split() + if len(fields) == 0: + # empty line or comment return None + elif len(fields) == 4: + # valid line + _, problem_type, problem_location, metric_value = fields + else: + raise ValueError("Misformatted line {!r}".format(orig_str)) if problem_type == "file-size": return FileSizeProblem(problem_location, metric_value) @@ -135,6 +152,4 @@ def get_old_problem_from_exception_str(exception_str): elif problem_type == "function-size": return FunctionSizeProblem(problem_location, metric_value) else: -# print("Unknown exception line '{}'".format(exception_str)) - return None - + raise ValueError("Unknown exception type {!r}".format(orig_str)) |