Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def runpep8(package):
# Hook into stdout.
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
# Run Pep8 checks.
pep8.options, pep8.args = pep8.process_options()
pep8.options.repeat = True
pep8.input_dir(package)
# Restore stdout.
sys.stdout = old_stdout
# Save result to pep8.txt.
result = mystdout.getvalue()
output = open('pep8.txt', 'w')
output.write(result)
output.close()
# Return Pep8 result
if result:
return result
else:
def runpep8():
# Hook into stdout.
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
# Run Pep8 checks.
pep8.options, pep8.args = pep8.process_options()
pep8.input_dir(MODULE)
# Restore stdout.
sys.stdout = old_stdout
# Save result to pep8.txt.
result = mystdout.getvalue()
output = open('pep8.txt', 'w')
output.write(result)
output.close()
# Return Pep8 result
return result
def runpep8(package):
# Hook into stdout.
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
# Run Pep8 checks.
pep8.options, pep8.args = pep8.process_options()
pep8.options.repeat = True
pep8.input_dir(package)
# Restore stdout.
sys.stdout = old_stdout
# Save result to pep8.txt.
result = mystdout.getvalue()
output = open('pep8.txt', 'w')
output.write(result)
output.close()
# Return Pep8 result
if result:
return result
else:
return None
if not path:
saveFirst()
return
mark_key = '%s-pep8' % currentDocument.url().path()
# Check the file for errors with PEP8
sys.argv = [path]
pep8.process_options([path])
python_utils_conf = kate.configuration.root.get('python_utils', {})
ignore_pep8_errors = python_utils_conf.get(_IGNORE_PEP8_ERRORS, DEFAULT_IGNORE_PEP8_ERRORS)
if ignore_pep8_errors:
ignore_pep8_errors = ignore_pep8_errors.split(",")
else:
ignore_pep8_errors = []
if pep8.__version__ in OLD_PEP8_VERSIONS:
checker = StoreErrorsChecker(path)
pep8.options.ignore = ignore_pep8_errors
checker.check_all()
errors = checker.get_errors()
else:
checker = pep8.Checker(path, reporter=KateReport, ignore=ignore_pep8_errors)
checker.check_all()
errors = checker.report.get_errors()
if len(errors) == 0:
showOk(i18n('Pep8 Ok'))
return
errors_to_show = []
# Paint errors found
for error in errors:
errors_to_show.append({
"line": error[0],
"column": error[1] + 1,
"message": error[3],
code = text[:4]
msg = text[5:]
if pep8.ignore_code(code):
return
if code.startswith('E'):
messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
else:
messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
pep8.Checker.report_error = report_error
_ignore = ignore + pep8.DEFAULT_IGNORE.split(',')
class FakeOptions:
verbose = 0
select = []
ignore = _ignore
pep8.options = FakeOptions()
pep8.options.physical_checks = pep8.find_checks('physical_line')
pep8.options.logical_checks = pep8.find_checks('logical_line')
pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
good_lines = [l + '\n' for l in _lines]
good_lines[-1] = good_lines[-1].rstrip('\n')
if not good_lines[-1]:
good_lines = good_lines[:-1]
try:
pep8.Checker(filename, good_lines).check_all()
except:
pass
return messages
msg = text[5:]
if pep8.ignore_code(code):
return
if code.startswith('E'):
messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
else:
messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
pep8.Checker.report_error = report_error
_ignore = ignore + pep8.DEFAULT_IGNORE.split(',')
class FakeOptions:
verbose = 0
select = []
ignore = _ignore
pep8.options = FakeOptions()
pep8.options.physical_checks = pep8.find_checks('physical_line')
pep8.options.logical_checks = pep8.find_checks('logical_line')
pep8.options.counters = dict.fromkeys(pep8.BENCHMARK_KEYS, 0)
good_lines = [l + '\n' for l in _lines]
good_lines[-1] = good_lines[-1].rstrip('\n')
if not good_lines[-1]:
good_lines = good_lines[:-1]
try:
pep8.Checker(filename, good_lines).check_all()
except:
pass
return messages
def main():
"""
Parse options and run checks on Python source.
"""
pep8.options = options()
repo = dirname(dirname(abspath(__file__)))
pep8.input_dir(repo)
currentDocument = currentDocument or kate.activeDocument()
if currentDocument.isModified():
saveFirst()
return
path = unicode(currentDocument.url().path())
if not path:
saveFirst()
return
mark_key = '%s-pep8' % unicode(currentDocument.url().path())
# Check the file for errors with PEP8
sys.argv = [path]
pep8.process_options([path])
if pep8.__version__ in OLD_PEP8_VERSIONS:
checker = StoreErrorsChecker(path)
pep8.options.ignore = IGNORE_PEP8_ERRORS
checker.check_all()
errors = checker.get_errors()
else:
checker = pep8.Checker(path, reporter=KateReport, ignore=IGNORE_PEP8_ERRORS)
checker.check_all()
errors = checker.report.get_errors()
if len(errors) == 0:
commons.showOk('Pep8 Ok')
return
errors_to_show = []
# Paint errors found
for error in errors:
errors_to_show.append({
"line": error[0],
"column": error[1] + 1,
"message": error[3],
def main():
"""
Parse options and run checks on Python source.
"""
pep8.options = options()
repo = dirname(dirname(abspath(__file__)))
pep8.input_dir(repo)