Skip to content

Instantly share code, notes, and snippets.

@florentx
Created May 2, 2013 07:19
Show Gist options
  • Save florentx/5500654 to your computer and use it in GitHub Desktop.
Save florentx/5500654 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import pep8
class MyReport(pep8.BaseReport):
def __init__(self, options):
super(MyReport, self).__init__(options)
self.all_errors = []
def error(self, line_number, offset, text, check):
code = super(MyReport, self).error(line_number, offset, text, check)
# XXX do something useful
err = (self.filename, line_number, offset, code, text)
self.all_errors.append(err)
return code
pep8style = pep8.StyleGuide(reporter=MyReport)
report = pep8style.check_files(['file1.py', 'file2.py'])
for err in report.all_errors:
print(err)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment