forked from chipsalliance/i3c-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_lint.py
49 lines (39 loc) · 1.09 KB
/
stats_lint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import sys
from collections import Counter
error_codes = []
run_cmds = []
syntax_errors = []
if not os.path.isfile("exec_lint.log"):
print("File does not exist")
sys.exit(1)
f = open("exec_lint.log", "r")
lines = f.readlines()
for line in lines:
if line.strip() is None:
continue
# Remove [RUN CMD] lines
if line.startswith("[RUN CMD]"):
run_cmds.append(line.strip())
continue
# Remove syntax errors
if "syntax error" in line:
syntax_errors.append(line.strip())
continue
# Error type is hidden in 2 last square brackets
line = line.split("[")
error_code = "[" + line[-2].strip() + " [" + line[-1].strip()
error_codes.append(error_code)
dd = dict(Counter(error_codes))
total = 0
print("=" * 20 + " Error statistics " + "=" * 20)
for k in dd.keys():
print(k, dd[k])
total += dd[k]
print(f"Total = {total}")
print("=" * 20 + " Syntax errors " + "=" * 20)
for syntax_error in syntax_errors:
print(syntax_error)
print("=" * 20 + " Used run cmds " + "=" * 20)
for run_cmd in run_cmds:
print(run_cmd)