#NEWLINE# def prune_source_infos( self ) : #NEWLINE# #INDENT# 'Remove all source infos of files that no longer exist.' #NEWLINE# MAX_VARS = 999 #NEWLINE# con = self . connect_to_database ( ) #NEWLINE# to_clean = [ ] #NEWLINE# try : #NEWLINE# #INDENT# cur = con . cursor ( ) #NEWLINE# cur . execute ( '\n                select distinct source from source_info\n            ' ) #NEWLINE# for ( source , ) in cur . fetchall ( ) : #NEWLINE# #INDENT# fs_path = os . path . join ( self . env . root_path , source ) #NEWLINE# if ( not os . path . exists ( fs_path ) ) : #NEWLINE# #INDENT# to_clean . append ( source ) #NEWLINE# #UNINDENT# #UNINDENT# if to_clean : #NEWLINE# #INDENT# for i in range ( 0 , len ( to_clean ) , MAX_VARS ) : #NEWLINE# #INDENT# chunk = to_clean [ source : ( i + MAX_VARS ) ] #NEWLINE# cur . execute ( ( '\n                        delete from source_info\n                         where source in (%s)\n                    ' % ', ' . join ( ( [ '?' ] * len ( chunk ) ) ) ) , chunk ) #NEWLINE# #UNINDENT# con . commit ( ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# con . close ( ) #NEWLINE# #UNINDENT# for source in to_clean : #NEWLINE# #INDENT# reporter . report_prune_source_info ( source )