#NEWLINE# def append_middle( self , event ) : #NEWLINE# #INDENT# ' Attempt to place the event in the correct location in our deque.\n        Returns True if successful, otherwise False. ' #NEWLINE# rotation = 0 #NEWLINE# ts = self . get_ts ( event ) #NEWLINE# if ( self . get_ts ( self . data [ 0 ] ) > ts ) : #NEWLINE# #INDENT# self . data . appendleft ( event ) #NEWLINE# self . running_count += self [ 1 ] #NEWLINE# return #NEWLINE# #UNINDENT# while ( self . get_ts ( self . data [ ( - 1 ) ] ) > ts ) : #NEWLINE# #INDENT# self . data . rotate ( 1 ) #NEWLINE# rotation += 1 #NEWLINE# if ( rotation == len ( self . data ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# #UNINDENT# self . data . append ( event ) #NEWLINE# self . running_count += event [ 1 ] #NEWLINE# self . data . rotate ( ( - rotation ) )