forked from orbit-oss/flask
Added initial version of 'setup.py audit'
This commit is contained in:
parent
549af62290
commit
f52f4fd31b
1 changed files with 38 additions and 1 deletions
39
setup.py
39
setup.py
|
|
@ -38,8 +38,44 @@ Links
|
||||||
<http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_
|
<http://github.com/mitsuhiko/flask/zipball/master#egg=Flask-dev>`_
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from setuptools import setup
|
from setuptools import Command, setup
|
||||||
|
|
||||||
|
class run_audit(Command):
|
||||||
|
"""Audits source code using PyFlakes for following issues:
|
||||||
|
- Names which are used but not defined or used before they are defined.
|
||||||
|
- Names which are redefined without having been used.
|
||||||
|
"""
|
||||||
|
description = "Audit source code with PyFlakes"
|
||||||
|
user_options = []
|
||||||
|
|
||||||
|
def initialize_options(self):
|
||||||
|
all = None
|
||||||
|
|
||||||
|
def finalize_options(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
import os, sys
|
||||||
|
try:
|
||||||
|
import pyflakes.scripts.pyflakes as flakes
|
||||||
|
except ImportError:
|
||||||
|
print "Audit requires PyFlakes installed in your system."""
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
|
dirs = ['flask', 'tests']
|
||||||
|
# Add example directories
|
||||||
|
for dir in ['flaskr', 'jqueryexample', 'minitwit']:
|
||||||
|
dirs.append(os.path.join('examples', dir))
|
||||||
|
# TODO: Add test subdirectories
|
||||||
|
warns = 0
|
||||||
|
for dir in dirs:
|
||||||
|
for filename in os.listdir(dir):
|
||||||
|
if filename.endswith('.py') and filename != '__init__.py':
|
||||||
|
warns += flakes.checkPath(os.path.join(dir, filename))
|
||||||
|
if warns > 0:
|
||||||
|
print ("Audit finished with total %d warnings." % warns)
|
||||||
|
else:
|
||||||
|
print ("No problems found in sourcecode.")
|
||||||
|
|
||||||
def run_tests():
|
def run_tests():
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
@ -75,5 +111,6 @@ setup(
|
||||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||||
],
|
],
|
||||||
|
cmdclass={'audit': run_audit},
|
||||||
test_suite='__main__.run_tests'
|
test_suite='__main__.run_tests'
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue