diff --git a/panc/src/main/scripts/panlint/panlint.py b/panc/src/main/scripts/panlint/panlint.py index 3945bf74..a6f18c22 100755 --- a/panc/src/main/scripts/panlint/panlint.py +++ b/panc/src/main/scripts/panlint/panlint.py @@ -378,12 +378,15 @@ def get_string_ranges(line): def filestats_table(problem_stats): """Return a formatted table of problem counts per file""" - t = PrettyTable(['Filename', 'Problems']) + t = PrettyTable(['Filename'] + [severity for severity in SEVERITY_VALUE] + ['Total']) t.align['Filename'] = 'l' - t.align['Problems'] = 'r' - for filename, problem_count in problem_stats.iteritems(): - if problem_count > 0: - t.add_row([filename, problem_count]) + t.align['Total'] = 'r' + for severity in SEVERITY_VALUE: + t.align[severity] = 'r' + + for filename, stats in problem_stats.items(): + if stats: + t.add_row([filename] + stats + [sum(stats)]) t.sortby = 'Filename' return t @@ -595,6 +598,7 @@ def main(): problem_count = 0 problem_lines = [] problem_stats = {} + problem_max_severity = 0 if not args.paths: print('No files were provided, not doing anything') @@ -615,6 +619,17 @@ def main(): problem_count += file_problem_count problem_stats[filename] = file_problem_count + file_severities = [0] + for line in file_problem_lines: + for problem in line.problems: + file_severities.append(problem.message.severity) + + problem_stats[filename] = [] + for value in SEVERITY_TEXT: + problem_stats[filename].append(file_severities.count(value)) + + problem_max_severity = max(problem_max_severity, max(file_severities)) + for line in problem_lines: print_report(line, vi=args.vi)