Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Option for explicit files/packages to be covered #1

Merged
merged 1 commit into from

2 participants

@onlynone

This is useful if you want to test a specific module/package/file.

@johnnoone johnnoone merged commit 3ebd018 into from
@johnnoone
Owner

thanks ! i will quickly publish it on the cheeseshop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 21, 2014
  1. Option for explicit files/packages to be covered

    Steven Willis authored
This page is out of date. Refresh to see the latest.
Showing with 28 additions and 7 deletions.
  1. +7 −0 NEWS.txt
  2. +1 −1  setup.py
  3. +20 −6 src/setuptools_lint/setuptools_command.py
View
7 NEWS.txt
@@ -1,6 +1,13 @@
News
====
+0.1.1
+---
+
+*Release date: 5-Jun-2012*
+
+* Better support for packages
+
0.1
---
View
2  setup.py
@@ -6,7 +6,7 @@
NEWS = open(os.path.join(here, 'NEWS.txt')).read()
-version = '0.1'
+version = '0.1.1'
install_requires = [
'pylint'
View
26 src/setuptools_lint/setuptools_command.py
@@ -17,17 +17,26 @@ def user_options():
class PylintCommand(setuptools.Command):
description = "run pylint on all your modules"
user_options = user_options() + [
+ ('lint-packages=', None,
+ 'Report on just these packages. These arguments are passed straight '
+ 'through to pylint as the module_or_package arguments. As such, they '
+ 'can be paths to files or packages'),
('lint-exclude-packages=', None, 'exclude these packages'),
('lint-output=', None, "output report into this file"),
]
def initialize_options(self):
+ self.lint_packages = ''
self.lint_exclude_packages = 'tests test'
self.lint_output = None
for longopt, params in _opts:
setattr(self, 'lint_' + longopt.replace('-', '_').rstrip('='), None)
def finalize_options(self):
+ self.lint_packages = [package.strip()
+ for package
+ in re.split('[\s,]+', self.lint_packages)
+ if package != '']
self.lint_exclude_packages = [module.strip() \
for module in re.split('[\s,]+', self.lint_exclude_packages)]
if self.lint_output:
@@ -42,12 +51,17 @@ def run(self):
value = '"' + value + '"'
options.append('--{0}={1}'.format(longopt, value))
- files = []
- base = self.get_finalized_command('build_py')
- for (package, module, filename) in base.find_all_modules():
- if package in self.lint_exclude_packages:
- continue
- files.append(filename)
+ if self.lint_packages:
+ # The user explicitly specified the paths/packages to send to lint
+ files = self.lint_packages
+ else:
+ # With no packages specified, find all of them and pass them
+ # through the filter
+ base = self.get_finalized_command('build_py')
+ files = [filename
+ for (package, module, filename)
+ in base.find_all_modules()
+ if package not in self.lint_exclude_packages]
if self.lint_output:
stdout, sys.stdout = sys.stdout, self.lint_output
Something went wrong with that request. Please try again.