Skip to content
Myr

Added initial version of 'setup.py audit'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Priit Laes · committed by Armin Ronacher · parent 549af62 · Browse files · 1 file+38 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+38 added−1 removed

  • other:+38 added−1 removed

1 file+38 added−1 removed

modified:setup.py+38 added-1 removed
36 unmodified lines
37* `development version38 <http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_3940"""41from setuptools import setup41from setuptools import Command, setup4243class 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 = []5051 def initialize_options(self):52 all = None5354 def finalize_options(self):55 pass5657 def run(self):58 import os, sys59 try:60 import pyflakes.scripts.pyflakes as flakes61 except ImportError:62 print "Audit requires PyFlakes installed in your system."""63 sys.exit(-1)6465 dirs = ['flask', 'tests']66 # Add example directories67 for dir in ['flaskr', 'jqueryexample', 'minitwit']:68 dirs.append(os.path.join('examples', dir))69 # TODO: Add test subdirectories70 warns = 071 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.")7980def run_tests():81 import os, sys82 sys.path.append(os.path.join(os.path.dirname(__file__), 'tests'))83 from flask_tests import suite
26 unmodified lines
110 'Programming Language :: Python',111 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',112 'Topic :: Software Development :: Libraries :: Python Modules'113 ],114 cmdclass={'audit': run_audit},115 test_suite='__main__.run_tests'116)