
    3fi                         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y)    N)CallableListOptional)
deprecated)Document)
BaseLoader)GCSFileLoader)get_client_infoz0.0.32z1.0z-langchain_google_community.GCSDirectoryLoader)sinceremovalalternative_importc                   X    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y)GCSDirectoryLoaderzLoad from GCS directory.Nproject_namebucketprefixloader_funccontinue_on_failurec                 J    || _         || _        || _        || _        || _        y)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         p/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_community/document_loaders/gcs_directory.py__init__zGCSDirectoryLoader.__init__   s*    * )'#6     returnc                 f   	 ddl m} |j                  | j                  t        d            }g }|j                  | j                  | j                        D ]u  }|j                  j                  d      r	 t        | j                  | j                  |j                  | j                  	      }|j                  |j                                w |S # t        $ r t        d      w xY w# t        $ r=}| j                   r*t"        j%                  d
|j                   d|        Y d}~|d}~ww xY w)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&   	, %%'/EF   
 %%dkk$++%F 	D yy!!#&&%%KKII $ 1 1	 FKKM*	( =  	M 	0  ++NN%=dii[TUSV#WXGs*   C 8AC*C'*	D031D+)D++D0) NF)__name__
__module____qualname____doc__strr   r   r   boolr   r   r   r)    r   r   r   r      sh     # =A$)77 7 	7
 huj'89: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 - @ G B			8	$ 
F
@ @
@r   