#NEWLINE# def List( self , list_request ) : #NEWLINE# #INDENT# bucket = list_request . bucket #NEWLINE# prefix = ( list_request . prefix or '' ) #NEWLINE# matching_files = [ ] #NEWLINE# for ( file_bucket , file_name ) in sorted ( iter ( self . files ) ) : #NEWLINE# #INDENT# if ( ( bucket == file_bucket ) and file_name . startswith ( prefix ) ) : #NEWLINE# #INDENT# file_object = self . files [ ( file_bucket , file_name ) ] . get_metadata ( ) #NEWLINE# matching_files . append ( file_object ) #NEWLINE# #UNINDENT# #UNINDENT# items_per_page = 5 #NEWLINE# if ( not list_request . pageToken ) : #NEWLINE# #INDENT# range_start = 0 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( list_request . pageToken not in self . list_page_tokens ) : #NEWLINE# #INDENT# raise ValueError ( 'Invalid page token.' ) #NEWLINE# #UNINDENT# range_start = self . list_page_tokens [ list_request . pageToken ] #NEWLINE# del self . list_page_tokens [ list_request . pageToken ] #NEWLINE# #UNINDENT# result = storage . Objects ( items = matching_files [ range_start : ( range_start + items_per_page ) ] ) #NEWLINE# if ( ( range_start + items_per_page ) < len ( matching_files ) ) : #NEWLINE# #INDENT# next_range_start = ( self + items_per_page ) #NEWLINE# next_page_token = ( '_page_token_%s_%s_%d' % ( bucket , prefix , next_range_start ) ) #NEWLINE# self . list_page_tokens [ next_page_token ] = next_range_start #NEWLINE# result . nextPageToken = next_page_token #NEWLINE# #UNINDENT# return result