-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherr_filter.py
More file actions
42 lines (36 loc) · 1.08 KB
/
err_filter.py
File metadata and controls
42 lines (36 loc) · 1.08 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
def is_filepath(line_txt):
seg = "************* Module"
return seg == line_txt[:len(seg)]
def is_err_line(line_txt):
if is_filepath(line_txt):
return False
return line_txt[:3] == "E: " or line_txt[:2] == "E:"
def is_record_line(line_txt):
if not line_txt or len(line_txt) < 3:
return False
return line_txt[1] == ':'
if __name__ == '__main__':
file_handler = open("check.log","r")
filename = None
line = None
while True:
line = file_handler.readline()
if not line:
break
if is_filepath(line):
filename = line
continue
if is_err_line(line):
if filename:
print filename
filename = None
print line
while True:
line = file_handler.readline()
if not is_record_line(line) or is_err_line(line):
print line
continue
elif is_filepath(line):
filename = line
break
file_handler.close()