#NEWLINE# def get_fn( self , fn , max_lines = None ) : #NEWLINE# #INDENT# 'Passes each parsed log line to `fn`\n        This is a better idea than storing a giant log file in memory\n        ' #NEWLINE# stat = os . stat ( self . logfile ) #NEWLINE# if ( ( stat . st_ino == self . lastInode ) and ( stat . st_size == self . lastSize ) ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# if ( ( stat . st_ino != self . lastInode ) or ( stat . st_size < self . lastSize ) ) : #NEWLINE# #INDENT# self . lastSize = 0 #NEWLINE# #UNINDENT# fi = open ( self . logfile , 'rt' ) #NEWLINE# fi . seek ( self . lastSize ) #NEWLINE# self . lastInode = stat . st_ino #NEWLINE# lines = 0 #NEWLINE# for i in fi : #NEWLINE# #INDENT# lines += 1 #NEWLINE# if ( max_lines and ( lines > max_lines ) ) : #NEWLINE# #INDENT# self . storeLast ( ) #NEWLINE# fi . close ( ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( '\n' in i ) : #NEWLINE# #INDENT# self . lastSize += len ( i ) #NEWLINE# if self . parser : #NEWLINE# #INDENT# line = self . parser ( i . strip ( '\n' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# line = i . strip ( '\n' ) #NEWLINE# #UNINDENT# fn ( line ) #NEWLINE# #UNINDENT# #UNINDENT# self . storeLast ( ) #NEWLINE# fi . close ( )