#NEWLINE# @ retry . with_exponential_backoff ( ) #NEWLINE# def glob( self , pattern ) : #NEWLINE# #INDENT# 'Return the GCS path names matching a given path name pattern.\n\n    Path name patterns are those recognized by fnmatch.fnmatch().  The path\n    can contain glob characters (*, ?, and [...] sets).\n\n    Args:\n      pattern: GCS file path pattern in the form gs://<bucket>/<name_pattern>.\n\n    Returns:\n      list of GCS file paths matching the given pattern.\n    ' #NEWLINE# ( bucket , name_pattern ) = parse_gcs_path ( pattern ) #NEWLINE# prefix = re . match ( '^[^[*?]*' , name_pattern ) . group ( 0 ) #NEWLINE# request = storage . StorageObjectsListRequest ( bucket = bucket , prefix = prefix ) #NEWLINE# object_paths = [ ] #NEWLINE# while True : #NEWLINE# #INDENT# response = self . client . objects . List ( request ) #NEWLINE# for item in response . items : #NEWLINE# #INDENT# if fnmatch . fnmatch ( item . name , name_pattern ) : #NEWLINE# #INDENT# object_paths . append ( ( 'gs://%s/%s' % ( item . bucket , item . name ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if pattern . nextPageToken : #NEWLINE# #INDENT# request . pageToken = response . nextPageToken #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# return object_paths