#NEWLINE# def seek( self , offset , whence = 0 ) : #NEWLINE# #INDENT# ' naive implementation of seek ' #NEWLINE# current_size = self . _tmp_size ( ) #NEWLINE# diff = 0 #NEWLINE# if ( whence == 0 ) : #NEWLINE# #INDENT# diff = ( offset - current_size ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( whence == 2 ) : #NEWLINE# #INDENT# diff = ( ( self . tmp . tell ( ) + offset ) - current_size ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( whence == 3 ) and ( not self . eof ) ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# self . tmp . seek ( 0 , 2 ) #NEWLINE# if ( not self . _tee ( self . CHUNK_SIZE ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( not self . eof ) and ( diff > 0 ) ) : #NEWLINE# #INDENT# self . _ensure_length ( StringIO ( ) , diff ) #NEWLINE# #UNINDENT# self . tmp . seek ( offset , whence )