#NEWLINE# def next( self ) : #NEWLINE# #INDENT# "\n        Return the next available item. If there are no more items in the\n        local 'results' list, check if there is a 'next_uri' value. If so,\n        use that to get the next page of results from the API, and return\n        the first item from that query.\n        " #NEWLINE# try : #NEWLINE# #INDENT# return self . results . pop ( 0 ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# if ( self . next_uri is None ) : #NEWLINE# #INDENT# raise StopIteration ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . next_uri ) : #NEWLINE# #INDENT# if self . domain : #NEWLINE# #INDENT# self . results = self . list_method ( self . domain ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . results = self . list_method ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# args = self . extra_args #NEWLINE# self . results = self . _list_method ( self . next_uri , * args ) #NEWLINE# #UNINDENT# self . next_uri = self . manager . _paging . get ( self . paging_service , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) . get ( 'next_uri' ) #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# return self . results . pop ( 0 ) #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# raise StopIteration ( )