forked from rootpy/rootpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-pyflakes
executable file
·61 lines (45 loc) · 1.31 KB
/
run-pyflakes
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
#!/usr/bin/env python
#
# Utility script to run pyflakes with the modules we care about and
# exclude errors we know to be fine.
import os
import re
import subprocess
import sys
def main():
modules = sys.argv[1:]
if not modules:
modules = ['rootpy']
p = subprocess.Popen(['pyflakes'] + modules,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
close_fds=True)
contents = p.stdout.readlines()
# Read in the ignore file
ignore = []
fp = open("pyflakes.ignore", "r")
for line in fp.readlines():
ignore.append(line.rstrip())
fp.close()
# Read in the exclusions file
exclusions = {}
fp = open("pyflakes.exclude", "r")
for line in fp.readlines():
exclusions[line.rstrip()] = 1
fp.close()
# Now filter things
for line in contents:
line = line.rstrip()
skip = False
for ignore_line in ignore:
if line.startswith(ignore_line):
skip = True
break
if skip:
continue
test_line = re.sub(r':[0-9]+:', r':*:', line, 1)
test_line = re.sub(r'line [0-9]+', r'line *', test_line)
if test_line not in exclusions:
print(line)
if __name__ == "__main__":
main()