forked from dmachi/StarCluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
executable file
·55 lines (45 loc) · 1.31 KB
/
check.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
53
54
55
#!/usr/bin/env python
import os
import sys
import glob
import pep8
from pyflakes.scripts import pyflakes
def findpy(path):
for cfile in glob.glob(os.path.join(path, '*')):
if os.path.isdir(cfile):
for py in findpy(cfile):
yield py
if cfile.endswith('.py'):
yield cfile
def check_pyflakes(srcdir):
print(">>> Running pyflakes...")
clean = True
for pyfile in findpy(srcdir):
if pyflakes.checkPath(pyfile) != 0:
clean = False
return clean
def check_pep8(srcdir):
print(">>> Running pep8...")
clean = True
pep8.process_options([''])
pep8.options.repeat=True
for pyfile in findpy(srcdir):
if pep8.Checker(pyfile).check_all() != 0:
clean = False
return clean
def main():
src = os.path.join(os.path.dirname(sys.argv[0]), 'starcluster')
if not check_pyflakes(src):
print
err = "ERROR: pyflakes failed on some source files\n"
err += "ERROR: please fix the errors and re-run this script"
print(err)
elif not check_pep8(src):
print
err = "ERROR: pep8 failed on some source files\n"
err += "ERROR: please fix the errors and re-run this script"
print(err)
else:
print(">>> Clean!")
if __name__ == '__main__':
main()