从以下输入文件中,我想拆分testname和关联logdetails
输入文件:
2/1/1/2/tasdf.c:
LOG:
backslash-newline should be deleted before tokenizing
No diagnostics line
RESULT: 2/1/1/2/tasdf.c FAILED
----------------------------------------
2/1/1/2/tlasdf.c:
LOG:
+++ stderr ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tlasdf.c:15:5: error: use of undeclared identifier '_t'
t x[] = L\
^
ls: cannot access '*.o': No such file or directory
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| T | Translation Phases | 2 | \\ | L | 2 |
Compilation failed
RESULT: 2/1/1/2/tlasdf.c FAILED
----------------------------------------
2/2/4/1/texasdfgen(0):
LOG:
511 external identifiers in one source file
Compilation failed ungracefully
RESULT: 2/2/4/1/textasdf.gen FAILED
用于拆分的代码:
import re
import sys
#inputfile
TEST = sys.argv[1]
#Open input file and match testname
def testname(FILE):
testlist=[]
for line in open(FILE, 'r+'):
match1 = re.search(r'.*\.c\:$|.*\.gen\(\d+\)\:$', line)
if match1:
testname = match1.group(0)
testlist.append(testname)
return(testlist)
#Open input file and match log details
def logdetail(FILE):
array = []
with open(TEST) as f:
for line in f:
if line.startswith('LOG:'):
for line in f:
if line.startswith('RESULT:'):
break
# else process lines from section
array.append(line)
print(array)
testname = testname(TEST)
for test in testname:
print (test)
loddetails = logdetail1(TEST)
for log in loddetails:
print(log)
testname正确打印并且日志详细信息存在于数组中,但如何testname与logdetails.
HUWWW
相关分类