pycodestyle: Use module instead of executable

The `pycodestyle-3` executable is provided by the
`python3-pycodestyle` rpm package.
On Debian the corresponding executable is called `pycodestyle3`.
Arch Linux uses Python 3 by default and `python2-pycodestyle`
package is used for the py2 version.

To get around this inconsistency, import the `pycodestyle` module and
call the corresponding methods. The implementation has similar
behaviour to what happens when `pycodestyle` [1] is executed from the
command-line.

[1] https://github.com/PyCQA/pycodestyle/blob/master/pycodestyle.py

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
This commit is contained in:
Radostin Stoyanov 2018-03-02 08:01:25 +00:00 committed by Cole Robinson
parent b8b997fc3a
commit a52c282ed3

View File

@ -582,6 +582,7 @@ class CheckPylint(distutils.core.Command):
def run(self):
import pylint.lint
import pycodestyle
files = ["setup.py", "virt-install", "virt-clone",
"virt-convert", "virt-xml", "virt-manager",
@ -592,11 +593,16 @@ class CheckPylint(distutils.core.Command):
exclude = ["virtinst/progress.py"]
print("running pycodestyle")
cmd = "pycodestyle-3 "
cmd += "--config tests/pycodestyle.cfg "
cmd += "--exclude %s " % ",".join(exclude)
cmd += " ".join(files)
os.system(cmd)
style_guide = pycodestyle.StyleGuide(
config_file='tests/pycodestyle.cfg',
paths=files
)
style_guide.options.exclude = pycodestyle.normalize_paths(
','.join(exclude)
)
report = style_guide.check_files()
if style_guide.options.count:
sys.stderr.write(str(report.total_errors) + '\n')
print("running pylint")
pylint_opts = [