#NEWLINE# def search( self , text ) : #NEWLINE# #INDENT# '\n        Find text in log file from current position\n\n        returns a tuple containing:\n            absolute position,\n            position in result buffer,\n            result buffer (the actual file contents)\n        ' #NEWLINE# key = hash ( text ) #NEWLINE# searcher = self . _searchers . get ( key ) #NEWLINE# if ( not searcher ) : #NEWLINE# #INDENT# searcher = ReverseFileSearcher ( self . filename , text ) #NEWLINE# self . _searchers [ key ] = searcher #NEWLINE# #UNINDENT# position = searcher . find ( ) #NEWLINE# if ( position < 0 ) : #NEWLINE# #INDENT# searcher . reset ( ) #NEWLINE# return ( ( - 1 ) , ( - 1 ) , '' ) #NEWLINE# #UNINDENT# read_before = ( self . buffer_size / 2 ) #NEWLINE# offset = max ( ( position - read_before ) , 0 ) #NEWLINE# bufferpos = ( position if ( offset == 0 ) else read_before ) #NEWLINE# self . fp . seek ( offset ) #NEWLINE# return ( self , bufferpos , self . read ( ) )