-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatch_check.py
More file actions
71 lines (64 loc) · 2.4 KB
/
patch_check.py
File metadata and controls
71 lines (64 loc) · 2.4 KB
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
#!/usr/bin/python
# coding:utf-8
import csv
import os
import sys
def get_data(path):
final = []
# output=os.popen(' cd %s ;git log --author=htc --pretty=format:"%%s = %%ae = %%H = %%cd"'%(path)).read().splitlines()
output=os.popen(' cd %s ;git log --pretty=format:"%%s = %%ae = %%H = %%cd"'%(path)).read().splitlines()
for item in output:
temp = []
item=item.split('=')
for n in item:
temp.append(n)
# if 'xxxxx' in n:
# return final
final.append(temp)
return final
def write_data_csv(data, name):
file_name = name+'.csv'
with open(file_name, 'wb') as f:
f_csv = csv.writer(f)
f_csv.writerow(['Title','Author','Commit ID','Time'])
f_csv.writerows(data)
def write_data_html(data, name, path):
file_name = name+".html"
f = open(file_name,'w')
message ="""
<html>
<body>
<font size="10" color="#008000">Patch</font>
<font size="4" color="#008000">("""+path+""")</font></br></br>
<table border="1" cellspacing="0">
<tr bgcolor="#008000">
<th>Title</th>
<th>Author</th>
<th>Commit ID</th>
<th>Date</th>
</tr>
<font size="5" color="#FF0000">Total: """+bytes(len(data))+"""</font>"""
for n in data:
message = message+"""<tr>"""
message = message+"""<td style="padding-right:20px">"""+n[0]+"""</td><td style="padding-right:20px">"""+n[1]+""" """+"""</td>"""
message = message+"""<td style="padding-right:20px">"""+n[2]+"""</td><td style="padding-right:20px">"""+n[3]+""" """+"""</td>"""
message = message+"""</tr>"""
message = message+"""</table>
</br></br>
<div style="float:right;">
<font size="4 style="padding-right:20px" color="#008000">HTC SSD BT</font>
</div>
</body>
</html>"""
f.write(message)
f.close()
if __name__ == '__main__':
print("Path:")
print(sys.argv[1])
print("Excel Name:")
print(sys.argv[1].split('/')[-2]+'.csv')
print("HTML Name:")
print(sys.argv[1].split('/')[-2]+'.html')
result = get_data(sys.argv[1])
write_data_csv(result, sys.argv[1].split('/')[-2])
write_data_html(result, sys.argv[1].split('/')[-2], sys.argv[1])