aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriit Laes <plaes@plaes.org>2010-07-04 08:30:19 +0300
committerPriit Laes <plaes@plaes.org>2010-07-04 08:30:19 +0300
commit4ca74d491597746f9122dd897cc25891a3370439 (patch)
tree8102dde0c42e8cc071b27c019c3fec02bb0511f2 /setup.py
parentAdded setup.py (diff)
downloadgsoc2010-grumpy-4ca74d491597746f9122dd897cc25891a3370439.tar.gz
gsoc2010-grumpy-4ca74d491597746f9122dd897cc25891a3370439.tar.bz2
gsoc2010-grumpy-4ca74d491597746f9122dd897cc25891a3370439.zip
Added 'audit' command to setup.py
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/setup.py b/setup.py
index 802d015..6bcb652 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,44 @@ Project Grumpy is a an application and a set of utilities aimed to improve
life for Gentoo developers.
"""
-from setuptools import setup
+import os, sys
+
+from os.path import join
+from setuptools import Command, setup
+
+class cmd_Audit(Command):
+ """Audits Grumpy's 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 Grumpy's source with PyFlakes"
+ user_options = []
+
+ def initialize_options(self):
+ all = None
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ try:
+ import pyflakes.scripts.pyflakes as flakes
+ except ImportError:
+ print "Audit requires PyFlakes installed in your system."""
+ sys.exit(-1)
+
+ dirs = ['grumpy', 'utils']
+ warns = 0
+ for dir in dirs:
+ filenames = os.listdir(dir)
+ for filename in filenames:
+ 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.")
setup(
name='Grumpy',
@@ -18,6 +55,7 @@ setup(
description='Set of QA helpers for Gentoo Developers',
long_description=__doc__,
packages=['grumpy'],
+ scripts=[join('utils', 'grumpy_sync.py')],
zip_safe=False,
platforms='any',
install_requires=[
@@ -35,6 +73,7 @@ setup(
'Programming Language :: Python',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Utilities'
- ]
+ ],
+ cmdclass={'audit': cmd_Audit}
)