diff options
author | Radostin Stoyanov <rstoyanov1@gmail.com> | 2018-03-10 13:58:48 +0000 |
---|---|---|
committer | Radostin Stoyanov <rstoyanov1@gmail.com> | 2018-03-12 09:50:06 +0000 |
commit | 516b65749d722f04a260344aa9e6475b22609d27 (patch) | |
tree | eeafe6e45ecd5d2a2b0970464b949288e3250a1f /setup.py | |
parent | 0315eacb1ffda7cb0cceb2da51fa635c28203438 (diff) | |
download | virt-bootstrap.git-516b65749d722f04a260344aa9e6475b22609d27.tar.gz virt-bootstrap.git-516b65749d722f04a260344aa9e6475b22609d27.tar.xz virt-bootstrap.git-516b65749d722f04a260344aa9e6475b22609d27.zip |
setup: Use pylint/pycodestyle modules
Use pylint/pycodestyle modules instead of calling the executables
to ensure that Python 3 code is checked with Py 3 version of
pylint/pycodestyle.
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 36 |
1 files changed, 14 insertions, 22 deletions
@@ -38,8 +38,6 @@ from setuptools.command.sdist import sdist sys.path.insert(0, 'src') # noqa: E402 import virtBootstrap -IS_PI3 = (sys.version_info.major == 3) - def read(fname): """ @@ -96,36 +94,30 @@ class CheckPylint(setuptools.Command): """ Call pycodestyle and pylint here. """ + import pylint.lint + import pycodestyle - res = 0 - files = ' '.join(["setup.py", "src/virtBootstrap/", "tests/"]) + files = ["setup.py", "src/virtBootstrap/", "tests/"] output_format = "colorized" if sys.stdout.isatty() else "text" print(">>> Running pycodestyle ...") - if IS_PI3 and virtBootstrap.utils.is_installed('pycodestyle-3'): - cmd = "pycodestyle-3 " - else: - cmd = "pycodestyle " - - if (subprocess.call(cmd + files, shell=True) != 0): - res = 1 + style_guide = pycodestyle.StyleGuide(paths=files) + report = style_guide.check_files() + if style_guide.options.count: + sys.stderr.write(str(report.total_errors) + '\n') print(">>> Running pylint ...") - args = "" - if self.errors_only: - args = "-E" - if IS_PI3 and virtBootstrap.utils.is_installed('pylint-3'): - cmd = "pylint-3 " - else: - cmd = "pylint " + pylint_opts = [ + "--rcfile", "pylintrc", + "--output-format=%s" % output_format + ] - cmd += "%s --output-format=%s " % (args, format(output_format)) - if (subprocess.call(cmd + files, shell=True) != 0): - res = 1 + if self.errors_only: + pylint_opts.append("-E") - sys.exit(res) + pylint.lint.Run(files + pylint_opts) # SdistCommand is reused from the libvirt python binding (GPLv2+) |