-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp5.py
executable file
·52 lines (45 loc) · 1.93 KB
/
p5.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
#!/usr/bin/python
import os
import sys
import csv
def check(filename, writer):
datafile = open(filename.rstrip(), 'r')
err_str="VCM_LOG_ERRO"
endStr=");"
linenum=0
for line in datafile:
errLog=""
log=""
linenum += 1
if err_str in line:
if endStr in line:
errLog=":" + str(linenum) + ":" + line.strip()
log=line.strip()
#print filename.rstrip() + ":" + str(linenum) + ":" + line.strip()
else:
errLog=":" + str(linenum) + ":" + line.strip()
log=line.strip()
for count in range(1,15):
linenum += 1
line=datafile.next()
errLog=errLog+line.strip()
log=log+line.strip()
if endStr in line:
break;
if len(errLog) > 0:
writer.writerow({'filename':filename.rstrip(), 'lno':str(linenum), 'log':log, 'B':"", 'C':"", 'D':"", 'F':"", 'G':"", 'desc':"", 'pm-comment':""})
# print filename.rstrip() + errLog
def main(argv):
# cmd="""find . -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > files.out"""
# os.system(cmd)
filelist=open(argv[1], 'r')
csvFileName="csv/errorLog-"+argv[1]+".csv"
csvFile=open(csvFileName,'w+')
fieldnames = ['filename', 'lno', 'log', 'B', 'C', 'D', 'F', 'G','desc', 'pm-comment']
writer = csv.DictWriter(csvFile, fieldnames=fieldnames, delimiter='@')
writer.writerow({'filename':'Log message ', 'lno':'', 'log':'', 'B':'Grammar, More info', 'C':'Warn-Level or delete', 'D':'Owner', 'F':'Handling Action needed', 'G':'Target release', 'desc':'', 'pm-comment':''})
writer.writerow({'filename':"", 'lno':"", 'log':"", 'B':"", 'C':"", 'D':"", 'F':"", 'G':"", 'desc':"", 'pm-comment':""})
for line in filelist:
check(line, writer)
if __name__ == "__main__":
main(sys.argv)