[virt-tools-list] [virt-manager] [PATCH 5/5] pycodestyle: Use module instead of executable
Radostin Stoyanov
rstoyanov1 at gmail.com
Fri Mar 2 08:01:25 UTC 2018
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 at gmail.com>
---
setup.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/setup.py b/setup.py
index 33a1b478..b545dd85 100755
--- a/setup.py
+++ b/setup.py
@@ -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 = [
--
2.14.3
More information about the virt-tools-list
mailing list