#NEWLINE# def next( self ) : #NEWLINE# #INDENT# "\n        Interface for 'open' mode. For generators, this simply calls the\n        next() method. For callables callback, the counter is supplied\n        as a single argument.\n        " #NEWLINE# if ( self . mode == 'bounded' ) : #NEWLINE# #INDENT# raise Exception ( 'The next() method should only be called in one of the open modes.' ) #NEWLINE# #UNINDENT# args = ( ( ) if ( self . call_mode == 'generator' ) else ( self . counter , ) ) #NEWLINE# retval = self . _execute_callback ( * args ) #NEWLINE# ( key , val ) = ( retval if isinstance ( retval , tuple ) else ( self . counter , retval ) ) #NEWLINE# key = util . wrap_tuple ( key ) #NEWLINE# if ( len ( key ) != len ( self . key_dimensions ) ) : #NEWLINE# #INDENT# raise Exception ( 'Generated key does not match the number of key dimensions' ) #NEWLINE# #UNINDENT# self . _cache ( key , val ) #NEWLINE# self . counter += 1 #NEWLINE# return val