@@ -38,8 +38,44 @@ def hello():
38
38
<http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_
39
39
40
40
"""
41
- from setuptools import setup
42
-
41
+ from setuptools import Command , setup
42
+
43
+ class run_audit (Command ):
44
+ """Audits source code using PyFlakes for following issues:
45
+ - Names which are used but not defined or used before they are defined.
46
+ - Names which are redefined without having been used.
47
+ """
48
+ description = "Audit source code with PyFlakes"
49
+ user_options = []
50
+
51
+ def initialize_options (self ):
52
+ all = None
53
+
54
+ def finalize_options (self ):
55
+ pass
56
+
57
+ def run (self ):
58
+ import os , sys
59
+ try :
60
+ import pyflakes .scripts .pyflakes as flakes
61
+ except ImportError :
62
+ print "Audit requires PyFlakes installed in your system." ""
63
+ sys .exit (- 1 )
64
+
65
+ dirs = ['flask' , 'tests' ]
66
+ # Add example directories
67
+ for dir in ['flaskr' , 'jqueryexample' , 'minitwit' ]:
68
+ dirs .append (os .path .join ('examples' , dir ))
69
+ # TODO: Add test subdirectories
70
+ warns = 0
71
+ for dir in dirs :
72
+ for filename in os .listdir (dir ):
73
+ if filename .endswith ('.py' ) and filename != '__init__.py' :
74
+ warns += flakes .checkPath (os .path .join (dir , filename ))
75
+ if warns > 0 :
76
+ print ("Audit finished with total %d warnings." % warns )
77
+ else :
78
+ print ("No problems found in sourcecode." )
43
79
44
80
def run_tests ():
45
81
import os , sys
@@ -75,5 +111,6 @@ def run_tests():
75
111
'Topic :: Internet :: WWW/HTTP :: Dynamic Content' ,
76
112
'Topic :: Software Development :: Libraries :: Python Modules'
77
113
],
114
+ cmdclass = {'audit' : run_audit },
78
115
test_suite = '__main__.run_tests'
79
116
)
0 commit comments