#NEWLINE# def run_pep8_for_package( package_name , extra_ignore = None ) : #NEWLINE# #INDENT# '\n    If pep8 is installed, run it across the given package name\n    returning any warnings or errors found.\n    ' #NEWLINE# import pep8 #NEWLINE# class Checker ( pep8 . Checker ) : #NEWLINE# #INDENT# "\n        Subclass pep8's Checker to hook into error reporting.\n        " #NEWLINE# def __init__( self , * args , **kwargs ) : #NEWLINE# #INDENT# super ( Checker , self ) . __init__ ( * args , ** kwargs ) #NEWLINE# self . report_error = self . _report_error #NEWLINE# #UNINDENT# def _report_error( self , line_number , offset , text , check ) : #NEWLINE# #INDENT# '\n            Store pairs of line numbers and errors.\n            ' #NEWLINE# self . errors . append ( ( line_number , text . split ( ' ' , 1 ) [ 1 ] ) ) #NEWLINE# #UNINDENT# def check_all( self , * args , **kwargs ) : #NEWLINE# #INDENT# '\n            Assign the errors attribute and return it after running.\n            ' #NEWLINE# self . errors = [ ] #NEWLINE# super ( Checker , self ) . check_all ( * args , ** kwargs ) #NEWLINE# return self . errors #NEWLINE# #UNINDENT# #UNINDENT# def pep8_checker( path ) : #NEWLINE# #INDENT# for ( line_number , text ) in Checker ( path ) . check_all ( ) : #NEWLINE# #INDENT# ( yield ( '%s:%s: %s' % ( path , line_number , text ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# args = ( pep8_checker , package_name , extra_ignore ) #NEWLINE# return _run_checker_for_package ( * args )