2018-08-05 00:15:53 +02:00
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
|
|
|
import subprocess
|
2018-12-17 19:58:33 +01:00
|
|
|
if False:
|
|
|
|
from typing import List
|
2018-08-05 00:15:53 +02:00
|
|
|
|
|
|
|
from zulint.printer import print_err, colors
|
|
|
|
|
|
|
|
def run_pycodestyle(files, ignored_rules):
|
|
|
|
# type: (List[str], List[str]) -> bool
|
|
|
|
if len(files) == 0:
|
|
|
|
return False
|
|
|
|
|
|
|
|
failed = False
|
|
|
|
color = next(colors)
|
|
|
|
pep8 = subprocess.Popen(
|
|
|
|
['pycodestyle'] + files + ['--ignore={rules}'.format(rules=','.join(ignored_rules))],
|
|
|
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
|
|
assert pep8.stdout is not None # Implied by use of subprocess.PIPE
|
|
|
|
for line in iter(pep8.stdout.readline, b''):
|
|
|
|
print_err('pep8', color, line)
|
|
|
|
failed = True
|
|
|
|
return failed
|