
    hh                         d dl Z d dlmZmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ  e j        e          Z edd	d
           G d de
                      ZdS )    N)CallableListOptional)
deprecated)Document)
BaseLoader)GCSFileLoader)get_client_infoz0.0.32z1.0z-langchain_google_community.GCSDirectoryLoader)sinceremovalalternative_importc                   l    e Zd ZdZ	 	 	 ddedededeeegef                  d	ef
d
Z	de
e         fdZdS )GCSDirectoryLoaderzLoad from GCS directory. NFproject_namebucketprefixloader_funccontinue_on_failurec                 L    || _         || _        || _        || _        || _        dS )a{  Initialize with bucket and key name.

        Args:
            project_name: The ID of the project for the GCS bucket.
            bucket: The name of the GCS bucket.
            prefix: The prefix of the GCS bucket.
            loader_func: A loader function that instantiates a loader based on a
                file_path argument. If nothing is provided, the  GCSFileLoader
                would use its default loader.
            continue_on_failure: To use try-except block for each file within the GCS
                directory. If set to `True`, then failure to process a file will not
                cause an error.
        N)r   r   r   _loader_funcr   )selfr   r   r   r   r   s         o/var/www/FlaskApp/flask-venv/lib/python3.11/site-packages/langchain_community/document_loaders/gcs_directory.py__init__zGCSDirectoryLoader.__init__   s0    * )'#6       returnc                 N   	 ddl m} n# t          $ r t          d          w xY w|                    | j        t          d                    }g }|                    | j        | j                  D ]}|j	        
                    d          r	 t          | j        | j        |j	        | j        	          }|                    |                                           m# t          $ r8}| j        r*t"                              d
|j	         d|            Y d}~|d}~ww xY w|S )zLoad documents.r   )storagezpCould not import google-cloud-storage python package. Please install it with `pip install google-cloud-storage`.zgoogle-cloud-storage)module)projectclient_info)r   /)r   zProblem processing blob z, message: N)google.cloudr   ImportErrorClientr   r
   
list_blobsr   r   nameendswithr	   r   extendload	Exceptionr   loggerwarning)r   r   clientdocsblobloaderes          r   r*   zGCSDirectoryLoader.load1   s}   	,,,,,,, 	 	 	M  	
 %'/EFFF   
 
 %%dk$+%FF 	 	D y!!#&& &%KI $ 1	   FKKMM****   + NN#Wdi#W#WTU#W#WXXXHHHHG s'   	 #AC  
D"*,DDD")r   NF)__name__
__module____qualname____doc__strr   r   r   boolr   r   r   r*    r   r   r   r      s         #" =A$)7 77 7 	7
 huj'89:7 "7 7 7 76"d8n " " " " " "r   r   )loggingtypingr   r   r   langchain_core._api.deprecationr   langchain_core.documentsr   )langchain_community.document_loaders.baser   -langchain_community.document_loaders.gcs_filer	   &langchain_community.utilities.vertexair
   	getLoggerr3   r,   r   r9   r   r   <module>rB      s     + + + + + + + + + + 6 6 6 6 6 6 - - - - - - @ @ @ @ @ @ G G G G G G B B B B B B		8	$	$ 
F  
@ @ @ @ @ @ @ 
@ @ @r   