
    dhD                    x    S SK Jr  S SKrS SKrS SKJrJrJrJrJ	r	J
r
  S SKJr  \(       a  S SKr " S S\5      rg)    )annotationsN)TYPE_CHECKINGAnyCallableListOptionalUnion)UnstructuredBaseLoaderc                     ^  \ rS rSrSrSSSSSSSSSSSS.                           SU 4S jjjrSS jrSS	 jrS
rU =r	$ )S3FileLoader   zLoad from `Amazon AWS S3` file.NTsingle)region_nameapi_versionuse_sslverifyendpoint_urlaws_access_key_idaws_secret_access_keyaws_session_tokenboto_configmodepost_processorsc                  > [         TU ]  " X40 UD6  Xl        X l        X0l        X@l        XPl        X`l        Xpl        Xl	        Xl
        Xl        Xl        g)a  Initialize with bucket and key name.

:param bucket: The name of the S3 bucket.
:param key: The key of the S3 object.

:param region_name: The name of the region associated with the client.
    A client is associated with a single region.

:param api_version: The API version to use.  By default, botocore will
    use the latest API version when creating a client.  You only need
    to specify this parameter if you want to use a previous API version
    of the client.

:param use_ssl: Whether or not to use SSL.  By default, SSL is used.
    Note that not all services support non-ssl connections.

:param verify: Whether or not to verify SSL certificates.
    By default SSL certificates are verified.  You can provide the
    following values:

    * False - do not validate SSL certificates.  SSL will still be
      used (unless use_ssl is False), but SSL certificates
      will not be verified.
    * path/to/cert/bundle.pem - A filename of the CA cert bundle to
      uses.  You can specify this argument if you want to use a
      different CA cert bundle than the one used by botocore.

:param endpoint_url: The complete URL to use for the constructed
    client.  Normally, botocore will automatically construct the
    appropriate URL to use when communicating with a service.  You can
    specify a complete URL (including the "http/https" scheme) to
    override this behavior.  If this value is provided, then
    ``use_ssl`` is ignored.

:param aws_access_key_id: The access key to use when creating
    the client.  This is entirely optional, and if not provided,
    the credentials configured for the session will automatically
    be used.  You only need to provide this argument if you want
    to override the credentials used for this specific client.

:param aws_secret_access_key: The secret key to use when creating
    the client.  Same semantics as aws_access_key_id above.

:param aws_session_token: The session token to use when creating
    the client.  Same semantics as aws_access_key_id above.

:type boto_config: botocore.client.Config
:param boto_config: Advanced boto3 client configuration options. If a value
    is specified in the client config, its value will take precedence
    over environment variables and configuration values, but not over
    a value passed explicitly to the method. If a default config
    object is set on the session, the config object used when creating
    the client will be the result of calling ``merge()`` on the
    default config with the config provided to this call.
:param mode: Mode in which to read the file. Valid options are: single,
    paged and elements.
:param post_processors: Post processing functions to be applied to
    extracted elements.
:param **unstructured_kwargs: Arbitrary additional kwargs to pass in when
    calling `partition`
N)super__init__bucketkeyr   r   r   r   r   r   r   r   r   )selfr   r   r   r   r   r   r   r   r   r   r   r   r   unstructured_kwargs	__class__s                  d/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/document_loaders/s3_file.pyr   S3FileLoader.__init__   sW    ^ 	F2EF&&(!2%:"!2&    c                   SSK Jn   SSKnUR	                  SU R
                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                  S9
n[        R                  " 5        nU SU R                    3n["        R$                  " ["        R&                  R)                  U5      SS	9  UR+                  U R,                  U R                   U5        U" SS
U0U R.                  D6sSSS5        $ ! [         a    [        S5      ef = f! , (       d  f       g= f)zGet elements.r   )	partitionNzTCould not import `boto3` python package. Please install it with `pip install boto3`.s3)	r   r   r   r   r   r   r   r   config/T)exist_okfilename )unstructured.partition.autor&   boto3ImportErrorclientr   r   r   r   r   r   r   r   r   tempfileTemporaryDirectoryr   osmakedirspathdirnamedownload_filer   r    )r   r&   r.   r'   temp_dir	file_paths         r"   _get_elementsS3FileLoader._get_elementsl   s   9	 \\((((LL;;**"44"&"<"<"44##  
 ((*h#*AdhhZ0IKK	2TBT[[$((I>LiL43K3KL	 +*#  	> 	" +*s   D A>D4D14
Ec                >    SSU R                    SU R                   30$ )Nsourcezs3://r)   )r   r   )r   s    r"   _get_metadataS3FileLoader._get_metadata   s"    E$++az:;;r$   )r   r   r   r   r   r   r   r   r   r   r   )r   strr   r@   r   Optional[str]r   rA   r   zOptional[bool]r   zUnion[str, bool, None]r   rA   r   rA   r   rA   r   rA   r   z Optional[botocore.client.Config]r   r@   r   zOptional[List[Callable]]r    r   )returnr   )rB   dict)
__name__
__module____qualname____firstlineno____doc__r   r:   r>   __static_attributes____classcell__)r!   s   @r"   r   r      s    ) &*%)"&)-&*+//3+/8<48Z'Z' Z'
 #Z' #Z'  Z' 'Z' $Z' )Z'  -Z' )Z' 6Z' Z' 2Z'   #!Z' Z'xM:< <r$   r   )
__future__r   r3   r1   typingr   r   r   r   r   r	   1langchain_community.document_loaders.unstructuredr
   botocorer   r,   r$   r"   <module>rO      s,    " 	  F F T}<) }<r$   