-
Notifications
You must be signed in to change notification settings - Fork 249
/
Copy pathparse_iwyu_logs.py
executable file
·98 lines (96 loc) · 2.63 KB
/
parse_iwyu_logs.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/env python
from __future__ import print_function
import sys, json
fd = open(sys.argv[1], "r")
info = {}
includes = 0
excludes = 0
pkg_name = "/".join(sys.argv[1].split("/")[-3:-1])
files = 0
splitline = sys.argv[2] + "/src/"
print(
"""<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 2px solid green;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>"""
)
print("<a href=" + '"' + sys.argv[1].split("/")[-1] + '"' + ">" + "Access BuildLog" + "</a><br/>")
print('<table align="center">')
lines_seen = set()
for l in fd:
if "remove these lines" in l and l not in lines_seen:
lines_seen.add(l)
sec = iter(fd)
line = next(sec)
line = line.rstrip()
if len(line):
files += 1
items = l.split(splitline)[-1].split(" ", 1)
print(
'<tr><td bgcolor="#00FFFF"><b><a href='
+ '"'
+ "https://github.com/cms-sw/cmssw/tree/"
+ sys.argv[2]
+ "/"
+ items[0]
+ '"'
+ ">"
+ items[0]
+ "</a> "
+ items[1]
+ "</b>"
)
while len(line):
excludes += 1
line = line.replace("<", "<")
line = line.replace(">", ">")
print("<br/>" + line)
line = next(sec)
line = line.rstrip()
print("</td></tr>")
elif "add these lines" in l and l not in lines_seen:
lines_seen.add(l)
sec = iter(fd)
line = next(sec)
line = line.rstrip()
if len(line):
files += 1
items = l.split(splitline)[-1].split(" ", 1)
print(
'<tr><td bgcolor="#00FF90"><b><a href='
+ '"'
+ "https://github.com/cms-sw/cmssw/tree/"
+ sys.argv[2]
+ "/"
+ items[0]
+ '"'
+ ">"
+ items[0]
+ "</a> "
+ items[1]
+ "</b>"
)
while len(line):
includes += 1
line = line.replace("<", "<")
line = line.replace(">", ">")
print("<br />" + line)
line = next(sec)
line = line.rstrip()
print("</td></tr>")
print("</table>")
stat = [files, includes, excludes]
info[pkg_name] = stat
output_file = open("stats.json", "a")
output_file.write(json.dumps(info))
output_file.close()