#NEWLINE# def process( python , pylint , dirpath , filename , update ) : #NEWLINE# #INDENT# ' Process one file. ' #NEWLINE# saved_dir = os . getcwd ( ) #NEWLINE# path = os . path . join ( os . path . basename ( saved_dir ) , dirpath [ 2 : ] , filename ) #NEWLINE# ( ( print >> sys . stderr ) , ( '\nProcessing %s...' % path ) ) #NEWLINE# os . chdir ( dirpath ) #NEWLINE# args = '--files-output=y' #NEWLINE# if os . path . exists ( 'pylint.rc' ) : #NEWLINE# #INDENT# args += ' --rcfile=pylint.rc' #NEWLINE# #UNINDENT# args += ( ' %s' % filename ) #NEWLINE# status = os . system ( ( '%s %s %s' % ( python , pylint , args ) ) ) #NEWLINE# glbl = 'pylint_global.txt' #NEWLINE# if os . path . exists ( glbl ) : #NEWLINE# #INDENT# inp = open ( glbl , 'r' ) #NEWLINE# lines = inp . readlines ( ) #NEWLINE# inp . close ( ) #NEWLINE# ( ( print >> sys . stderr ) , '   ' , lines [ ( - 2 ) ] ) #NEWLINE# os . remove ( glbl ) #NEWLINE# #UNINDENT# directory = 'pylint' #NEWLINE# basename = filename [ : ( - 3 ) ] #NEWLINE# old_lint = os . path . join ( directory , ( '%s.txt' % basename ) ) #NEWLINE# new_lint = ( 'pylint_%s.txt' % basename ) #NEWLINE# diff_lines = None #NEWLINE# if os . path . exists ( new_lint ) : #NEWLINE# #INDENT# if os . path . exists ( old_lint ) : #NEWLINE# #INDENT# inp = open ( old_lint , 'r' ) #NEWLINE# old_lines = inp . readlines ( ) #NEWLINE# inp . close ( ) #NEWLINE# inp = open ( new_lint , 'r' ) #NEWLINE# new_lines = inp . readlines ( ) #NEWLINE# inp . close ( ) #NEWLINE# generator = difflib . context_diff ( old_lines , new_lines , 'old' , 'new' , n = 0 ) #NEWLINE# diff_lines = [ line for line in generator ] #NEWLINE# if diff_lines : #NEWLINE# #INDENT# ( ( print >> sys . stderr ) , '' ) #NEWLINE# sys . stderr . writelines ( diff_lines ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( ( print >> sys . stderr ) , '    No previous output.' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( ( print >> sys . stderr ) , '    No pylint output!' ) #NEWLINE# #UNINDENT# if os . path . exists ( new_lint ) : #NEWLINE# #INDENT# if ( update and ( ( diff_lines is None ) or ( len ( diff_lines ) > 0 ) ) ) : #NEWLINE# #INDENT# if ( not os . path . exists ( directory ) ) : #NEWLINE# #INDENT# os . mkdir ( directory ) #NEWLINE# #UNINDENT# if os . path . exists ( old_lint ) : #NEWLINE# #INDENT# os . remove ( pylint ) #NEWLINE# #UNINDENT# os . rename ( new_lint , old_lint ) #NEWLINE# ( ( print >> sys . stderr ) , '    Updated' , old_lint ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# os . remove ( new_lint ) #NEWLINE# #UNINDENT# #UNINDENT# os . chdir ( saved_dir )