/usr/share/kdevpythonsupport/codestyle.py is in kdevelop-python-data 5.2.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #!/usr/bin/env python3
from contextlib import redirect_stdout
from io import StringIO
from sys import stdin, stdout, stderr
import sys
try:
from pycodestyle import Checker, StyleGuide
except ImportError:
try:
from pep8 import Checker, StyleGuide
except ImportError:
Checker = None
while True:
size = stdin.buffer.read(10)
size = int(size)
if not size > 0:
continue
buf = bytes()
while len(buf) < size:
buf += stdin.buffer.read(min(1024, size - len(buf)))
lines = buf.decode("utf-8").splitlines()
opts, text = lines[:3], [l + "\n" for l in lines[3:]]
if Checker is not None:
style_guide = StyleGuide()
options = style_guide.options
select = [x for x in opts[0].strip().split(',') if len(x) > 0]
ignore = [x for x in opts[1].strip().split(',') if len(x) > 0]
options.select = tuple(select)
options.ignore = tuple(ignore)
options.max_line_length = int(opts[2])
stderr.flush()
c = Checker(lines=text, options=options)
output = StringIO()
with redirect_stdout(output):
# writes directly to stdout, so catch it ...
c.check_all()
output = output.getvalue()
output = output[:2**15]
stdout.write("{0:>10}".format(len(output)))
stdout.write(output)
stdout.flush()
else:
stderr.write("The `pycodestyle` (previously `pep8`) module is not installed.")
stderr.flush()
|