#NEWLINE# @ transaction . commit_on_success #NEWLINE# def __getitem__( self , idx ) : #NEWLINE# #INDENT# queryset = self . transitions . order_by ( 'start_time' ) #NEWLINE# if isinstance ( idx , slice ) : #NEWLINE# #INDENT# if ( idx . step is not None ) : #NEWLINE# #INDENT# raise IndexError ( 'Index stepping is not supported.' ) #NEWLINE# #UNINDENT# if ( ( idx . start is None ) and ( idx . stop is None ) ) : #NEWLINE# #INDENT# raise ValueError ( 'List cloning is not supported.' ) #NEWLINE# #UNINDENT# if ( ( idx . start is not None ) and ( idx . stop is not None ) ) : #NEWLINE# #INDENT# if ( ( idx . stop < idx . start ) or ( ( idx . start < 0 ) and ( idx . stop > 0 ) ) ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# if ( idx . stop == idx . start ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# #UNINDENT# if ( ( idx . start is not None ) and ( idx . start < 0 ) ) : #NEWLINE# #INDENT# if ( idx . stop is None ) : #NEWLINE# #INDENT# start = None #NEWLINE# stop = abs ( idx . start ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start = abs ( idx . stop ) #NEWLINE# stop = abs ( ( idx . stop + idx . start ) ) #NEWLINE# #UNINDENT# idx = slice ( start , stop ) #NEWLINE# trans = list ( queryset . order_by ( '-start_time' ) [ idx ] ) #NEWLINE# trans . reverse ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( idx . stop is not None ) and ( idx . stop < 0 ) ) : #NEWLINE# #INDENT# start = idx . start #NEWLINE# stop = ( self . length + idx . stop ) #NEWLINE# idx = slice ( start , idx ) #NEWLINE# trans = list ( queryset [ idx ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# trans = list ( queryset [ idx ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( idx < 0 ) : #NEWLINE# #INDENT# trans = queryset . order_by ( '-start_time' ) [ ( abs ( idx ) - 1 ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# trans = queryset [ idx ] #NEWLINE# #UNINDENT# except Transition . DoesNotExist : #NEWLINE# #INDENT# raise IndexError #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return trans