Show More
@@ -1,32 +1,38 b'' | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 |
|
2 | |||
3 | # Filter output by pyflakes to control which warnings we check |
|
3 | # Filter output by pyflakes to control which warnings we check | |
4 |
|
4 | |||
5 | import sys, re |
|
5 | import sys, re, os | |
6 |
|
6 | |||
7 | def makekey(message): |
|
7 | def makekey(message): | |
8 | # "path/file:line: message" |
|
8 | # "path/file:line: message" | |
9 | match = re.search(r"(line \d+)", message) |
|
9 | match = re.search(r"(line \d+)", message) | |
10 | line = '' |
|
10 | line = '' | |
11 | if match: |
|
11 | if match: | |
12 | line = match.group(0) |
|
12 | line = match.group(0) | |
13 | message = re.sub(r"(line \d+)", '', message) |
|
13 | message = re.sub(r"(line \d+)", '', message) | |
14 | return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$", |
|
14 | return re.sub(r"([^:]*):([^:]+):([^']*)('[^']*')(.*)$", | |
15 | r'\3:\5:\4:\1:\2:' + line, |
|
15 | r'\3:\5:\4:\1:\2:' + line, | |
16 | message) |
|
16 | message) | |
17 |
|
17 | |||
18 | lines = [] |
|
18 | lines = [] | |
19 | for line in sys.stdin: |
|
19 | for line in sys.stdin: | |
20 | # We whitelist tests |
|
20 | # We whitelist tests | |
21 | pats = [ |
|
21 | pats = [ | |
22 | r"imported but unused", |
|
22 | r"imported but unused", | |
23 | r"local variable '.*' is assigned to but never used", |
|
23 | r"local variable '.*' is assigned to but never used", | |
24 | r"unable to detect undefined names", |
|
24 | r"unable to detect undefined names", | |
25 | ] |
|
25 | ] | |
26 | if not re.search('|'.join(pats), line): |
|
26 | if not re.search('|'.join(pats), line): | |
27 | continue |
|
27 | continue | |
|
28 | fn = line.split(':', 1)[0] | |||
|
29 | f = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), fn)) | |||
|
30 | data = f.read() | |||
|
31 | f.close() | |||
|
32 | if 'no-check-code' in data: | |||
|
33 | continue | |||
28 | lines.append(line) |
|
34 | lines.append(line) | |
29 |
|
35 | |||
30 | for line in sorted(lines, key = makekey): |
|
36 | for line in sorted(lines, key = makekey): | |
31 | sys.stdout.write(line) |
|
37 | sys.stdout.write(line) | |
32 |
|
38 |
General Comments 0
You need to be logged in to leave comments.
Login now