Current File : //usr/lib/python3/dist-packages/boto3/s3/__pycache__/inject.cpython-312.pyc
�

��e-n���ddlZddlmZddlmZddlmZmZm	Z	m
Z
d�Zd�Zd�Z
d�Zd	�Zd
�Z	dd�Z	dd�Z	dd
�Z	dd�Z	dd�Z	dd�Z				dd�Z				dd�Z				dd�Z	dd�Z	dd�Z	dd�Z	dd�Z	dd�Z	dd�Zy)�N)�ClientError)�utils)�ProgressCallbackInvoker�
S3Transfer�TransferConfig�create_transfer_managerc��tj|dt�tj|dt�tj|dt�tj|dt
�tj|dt�y�N�upload_file�
download_file�copy�upload_fileobj�download_fileobj)r�inject_attributerrr
rr��class_attributes�kwargss  �1/usr/lib/python3/dist-packages/boto3/s3/inject.py�inject_s3_transfer_methodsrsf��	���+�]�K�H�	���+�_�m�L�	���+�V�T�:�	���+�-=�~�N�	����,�.>��c�H�tj|dt�tj|dt�tj|dt�tj|dt
�tj|dt�tj|dt�y)N�loadrrr
rr)rr�bucket_load�bucket_upload_file�bucket_download_file�bucket_copy�bucket_upload_fileobj�bucket_download_fileobjrs  r�inject_bucket_methodsr$s���	���+�V�[�A�	���+�]�<N�O�	����/�+?��
���+�V�[�A�	����*�,A��
����,�.E�rc��tj|dt�tj|dt�tj|dt�tj|dt
�tj|dt�yr
)rr�object_upload_file�object_download_file�object_copy�object_upload_fileobj�object_download_fileobjrs  r�inject_object_methodsr&3sq��	���+�]�<N�O�	����/�+?��
���+�V�[�A�	����*�,A��
����,�.E�rc�:�tj|dt�y)Nr)rr�object_summary_loadrs  r�inject_object_summary_methodsr)As��	���+�V�5H�Irc�X�i|j_	|jjj�}|dD]'}|d|jk(s�||j_yy#t
$r9}|jjdi�jd�dk(s�Yd}~yd}~wwxYw)z]
    Calls s3.Client.list_buckets() to update the attributes of the Bucket
    resource.
    �Buckets�Name�Error�Code�AccessDeniedN)�meta�data�client�list_buckets�namer�response�get)�self�argsrr5�bucket_data�es      rrrEs����D�I�I�N���9�9�#�#�0�0�2��#�I�.�	�K��6�"�d�i�i�/�!,��	�	���	�����z�z�~�~�g�r�*�.�.�v�6�.�H��I���s#�>A'�A'�%A'�'	B)�0/B$�$B)c���|jjj|j|j��}d|vr|jd�|d<||j_y)za
    Calls s3.Client.head_object to update the attributes of the ObjectSummary
    resource.
    )�Bucket�Key�
ContentLength�SizeN)r0r2�head_object�bucket_name�key�popr1)r7r8rr5s    rr(r(^sZ��
�y�y���+�+����T�X�X�,��H��(�"�#�<�<��8�����D�I�I�Nrc�r�t||�5}|j|||||��cddd�S#1swYyxYw)aMUpload a file to an S3 object.

    Usage::

        import boto3
        s3 = boto3.client('s3')
        s3.upload_file('/tmp/hello.txt', 'mybucket', 'hello.txt')

    Similar behavior as S3Transfer's upload_file() method, except that
    argument names are capitalized. Detailed examples can be found at
    :ref:`S3Transfer's Usage <ref_s3transfer_usage>`.

    :type Filename: str
    :param Filename: The path to the file to upload.

    :type Bucket: str
    :param Bucket: The name of the bucket to upload to.

    :type Key: str
    :param Key: The name of the key to upload to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed upload arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_UPLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the upload.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        transfer.
    )�filename�bucketrB�
extra_args�callbackN)rr)r7�Filenamer<r=�	ExtraArgs�Callback�Config�transfers        rrrksH��J
�D�&�	!�
�X��#�#���� ��$�
�
�
�
���-�6c�r�t||�5}|j|||||��cddd�S#1swYyxYw)apDownload an S3 object to a file.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        s3.meta.client.download_file('mybucket', 'hello.txt', '/tmp/hello.txt')

    Similar behavior as S3Transfer's download_file() method,
    except that parameters are capitalized. Detailed examples can be found at
    :ref:`S3Transfer's Usage <ref_s3transfer_usage>`.

    :type Bucket: str
    :param Bucket: The name of the bucket to download from.

    :type Key: str
    :param Key: The name of the key to download from.

    :type Filename: str
    :param Filename: The path to the file to download to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the download.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        transfer.
    )rFrBrErGrHN)rr)r7r<r=rIrJrKrLrMs        rrr�sH��J
�D�&�	!�
�X��%�%���� ��&�
�
�
�
�rNc�l�|jjj||j||||��S)aUpload a file to an S3 object.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        s3.Bucket('mybucket').upload_file('/tmp/hello.txt', 'hello.txt')

    Similar behavior as S3Transfer's upload_file() method,
    except that parameters are capitalized. Detailed examples can be found at
    :ref:`S3Transfer's Usage <ref_s3transfer_usage>`.

    :type Filename: str
    :param Filename: The path to the file to upload.

    :type Key: str
    :param Key: The name of the key to upload to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed upload arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_UPLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the upload.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        transfer.
    �rIr<r=rJrKrL)r0r2rr4)r7rIr=rJrKrLs      rrr�s=��D�9�9���'�'���y�y�����
(��rc�l�|jjj|j|||||��S)aDownload an S3 object to a file.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        s3.Bucket('mybucket').download_file('hello.txt', '/tmp/hello.txt')

    Similar behavior as S3Transfer's download_file() method,
    except that parameters are capitalized. Detailed examples can be found at
    :ref:`S3Transfer's Usage <ref_s3transfer_usage>`.

    :type Key: str
    :param Key: The name of the key to download from.

    :type Filename: str
    :param Filename: The path to the file to download to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the download.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        transfer.
    �r<r=rIrJrKrL)r0r2rr4)r7r=rIrJrKrLs      rrr�s=��D�9�9���)�)��y�y������
*��rc��|jjj||j|j|||��S)a�Upload a file to an S3 object.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        s3.Object('mybucket', 'hello.txt').upload_file('/tmp/hello.txt')

    Similar behavior as S3Transfer's upload_file() method,
    except that parameters are capitalized. Detailed examples can be found at
    :ref:`S3Transfer's Usage <ref_s3transfer_usage>`.

    :type Filename: str
    :param Filename: The path to the file to upload.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed upload arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_UPLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the upload.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        transfer.
    rQ)r0r2rrArB�r7rIrJrKrLs     rr!r!!sB��>�9�9���'�'������H�H����
(��rc��|jjj|j|j||||��S)a�Download an S3 object to a file.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        s3.Object('mybucket', 'hello.txt').download_file('/tmp/hello.txt')

    Similar behavior as S3Transfer's download_file() method,
    except that parameters are capitalized. Detailed examples can be found at
    :ref:`S3Transfer's Usage <ref_s3transfer_usage>`.

    :type Filename: str
    :param Filename: The path to the file to download to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the download.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        transfer.
    rS)r0r2rrArBrUs     rr"r"JsB��>�9�9���)�)�����H�H�����
*��rc	��d}|�t|�g}|}	|	�
t�}	tj|	�}
d|
_t||
�5}|j||||||��}|j
�cddd�S#1swYyxYw)a�Copy an object from one S3 location to another.

    This is a managed transfer which will perform a multipart copy in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        copy_source = {
            'Bucket': 'mybucket',
            'Key': 'mykey'
        }
        s3.meta.client.copy(copy_source, 'otherbucket', 'otherkey')

    :type CopySource: dict
    :param CopySource: The name of the source bucket, key name of the
        source object, and optional version ID of the source object. The
        dictionary format is:
        ``{'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}``. Note
        that the ``VersionId`` key is optional and may be omitted.

    :type Bucket: str
    :param Bucket: The name of the bucket to copy to

    :type Key: str
    :param Key: The name of the key to copy to

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the copy.

    :type SourceClient: botocore or boto3 Client
    :param SourceClient: The client to be used for operation that
        may happen at the source object. For example, this client is
        used for the head_object that determines the size of the copy.
        If no client is provided, the current client is used as the client
        for the source object.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        copy.
    N�classic)�copy_sourcerFrBrG�subscribers�
source_client)rr�python_copyr
�preferred_transfer_clientr�result)
r7�
CopySourcer<r=rJrK�SourceClientrLrZ�config�
new_config�manager�futures
             rr
r
ss���t�K���.�x�8�9��
�F�
�~��!���!�!�&�)�J�+4�J�(�	 ��z�	2�	�g����"��� �#�&�
�
���}�}��	�	�	�s�'A8�8Bc	�n�|jjj||j|||||��S)a�Copy an object from one S3 location to an object in this bucket.

    This is a managed transfer which will perform a multipart copy in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        copy_source = {
            'Bucket': 'mybucket',
            'Key': 'mykey'
        }
        bucket = s3.Bucket('otherbucket')
        bucket.copy(copy_source, 'otherkey')

    :type CopySource: dict
    :param CopySource: The name of the source bucket, key name of the
        source object, and optional version ID of the source object. The
        dictionary format is:
        ``{'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}``. Note
        that the ``VersionId`` key is optional and may be omitted.

    :type Key: str
    :param Key: The name of the key to copy to

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the copy.

    :type SourceClient: botocore or boto3 Client
    :param SourceClient: The client to be used for operation that
        may happen at the source object. For example, this client is
        used for the head_object that determines the size of the copy.
        If no client is provided, the current client is used as the client
        for the source object.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        copy.
    �r_r<r=rJrKr`rL)r0r2r
r4)r7r_r=rJrKr`rLs       rrr�s@��n�9�9��� � ���y�y����!��!��rc	��|jjj||j|j||||��S)apCopy an object from one S3 location to this object.

    This is a managed transfer which will perform a multipart copy in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        copy_source = {
            'Bucket': 'mybucket',
            'Key': 'mykey'
        }
        bucket = s3.Bucket('otherbucket')
        obj = bucket.Object('otherkey')
        obj.copy(copy_source)

    :type CopySource: dict
    :param CopySource: The name of the source bucket, key name of the
        source object, and optional version ID of the source object. The
        dictionary format is:
        ``{'Bucket': 'bucket', 'Key': 'key', 'VersionId': 'id'}``. Note
        that the ``VersionId`` key is optional and may be omitted.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the copy.

    :type SourceClient: botocore or boto3 Client
    :param SourceClient: The client to be used for operation that
        may happen at the source object. For example, this client is
        used for the head_object that determines the size of the copy.
        If no client is provided, the current client is used as the client
        for the source object.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        copy.
    rf)r0r2r
rArB)r7r_rJrKr`rLs      rr#r#sF��h�9�9��� � ������H�H���!��!��rc��t|d�std��d}|�t|�g}|}|�
t�}t	||�5}	|	j|||||��}
|
j
�cddd�S#1swYyxYw)a�Upload a file-like object to S3.

    The file-like object must be in binary mode.

    This is a managed transfer which will perform a multipart upload in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.client('s3')

        with open('filename', 'rb') as data:
            s3.upload_fileobj(data, 'mybucket', 'mykey')

    :type Fileobj: a file-like object
    :param Fileobj: A file-like object to upload. At a minimum, it must
        implement the `read` method, and must return bytes.

    :type Bucket: str
    :param Bucket: The name of the bucket to upload to.

    :type Key: str
    :param Key: The name of the key to upload to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed upload arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_UPLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the upload.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        upload.
    �readzFileobj must implement readN)�fileobjrFrBrGrZ)�hasattr�
ValueErrorrrr�uploadr^)r7�Fileobjr<r=rJrKrLrZrarcrds           rrrFs���R�7�F�#��6�7�7��K���.�x�8�9��
�F�
�~��!��	 ��v�	.��'������� �#� �
���}�}�������&A2�2A;c�l�|jjj||j||||��S)a�Upload a file-like object to this bucket.

    The file-like object must be in binary mode.

    This is a managed transfer which will perform a multipart upload in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        bucket = s3.Bucket('mybucket')

        with open('filename', 'rb') as data:
            bucket.upload_fileobj(data, 'mykey')

    :type Fileobj: a file-like object
    :param Fileobj: A file-like object to upload. At a minimum, it must
        implement the `read` method, and must return bytes.

    :type Key: str
    :param Key: The name of the key to upload to.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed upload arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_UPLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the upload.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        upload.
    �rnr<r=rJrKrL)r0r2rr4)r7rnr=rJrKrLs      rrr�s=��N�9�9���*�*���y�y�����
+��rc��|jjj||j|j|||��S)aWUpload a file-like object to this object.

    The file-like object must be in binary mode.

    This is a managed transfer which will perform a multipart upload in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        bucket = s3.Bucket('mybucket')
        obj = bucket.Object('mykey')

        with open('filename', 'rb') as data:
            obj.upload_fileobj(data)

    :type Fileobj: a file-like object
    :param Fileobj: A file-like object to upload. At a minimum, it must
        implement the `read` method, and must return bytes.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed upload arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_UPLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the upload.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        upload.
    rq)r0r2rrArB�r7rnrJrKrLs     rr$r$�sC��J�9�9���*�*������H�H����
+��rc��t|d�std��d}|�t|�g}|}|�
t�}t	||�5}	|	j|||||��}
|
j
�cddd�S#1swYyxYw)a�Download an object from S3 to a file-like object.

    The file-like object must be in binary mode.

    This is a managed transfer which will perform a multipart download in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.client('s3')

        with open('filename', 'wb') as data:
            s3.download_fileobj('mybucket', 'mykey', data)

    :type Bucket: str
    :param Bucket: The name of the bucket to download from.

    :type Key: str
    :param Key: The name of the key to download from.

    :type Fileobj: a file-like object
    :param Fileobj: A file-like object to download into. At a minimum, it must
        implement the `write` method and must accept bytes.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the download.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        download.
    �writezFileobj must implement writeN)rFrBrjrGrZ)rkrlrrr�downloadr^)r7r<r=rnrJrKrLrZrarcrds           rrr�s���R�7�G�$��7�8�8��K���.�x�8�9��
�F�
�~��!��	 ��v�	.��'��!�!���� �#�"�
���}�}�����roc�l�|jjj|j|||||��S)a�Download an object from this bucket to a file-like-object.

    The file-like object must be in binary mode.

    This is a managed transfer which will perform a multipart download in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        bucket = s3.Bucket('mybucket')

        with open('filename', 'wb') as data:
            bucket.download_fileobj('mykey', data)

    :type Fileobj: a file-like object
    :param Fileobj: A file-like object to download into. At a minimum, it must
        implement the `write` method and must accept bytes.

    :type Key: str
    :param Key: The name of the key to download from.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the download.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        download.
    �r<r=rnrJrKrL)r0r2rr4)r7r=rnrJrKrLs      rrr$s=��N�9�9���,�,��y�y������
-��rc��|jjj|j|j||||��S)atDownload this object from S3 to a file-like object.

    The file-like object must be in binary mode.

    This is a managed transfer which will perform a multipart download in
    multiple threads if necessary.

    Usage::

        import boto3
        s3 = boto3.resource('s3')
        bucket = s3.Bucket('mybucket')
        obj = bucket.Object('mykey')

        with open('filename', 'wb') as data:
            obj.download_fileobj(data)

    :type Fileobj: a file-like object
    :param Fileobj: A file-like object to download into. At a minimum, it must
        implement the `write` method and must accept bytes.

    :type ExtraArgs: dict
    :param ExtraArgs: Extra arguments that may be passed to the
        client operation. For allowed download arguments see
        boto3.s3.transfer.S3Transfer.ALLOWED_DOWNLOAD_ARGS.

    :type Callback: function
    :param Callback: A method which takes a number of bytes transferred to
        be periodically called during the download.

    :type Config: boto3.s3.transfer.TransferConfig
    :param Config: The transfer configuration to be used when performing the
        download.
    rx)r0r2rrArBrss     rr%r%UsC��J�9�9���,�,�����H�H�����
-��r)NNN)NNNN)r
r\�botocore.exceptionsr�boto3r�boto3.s3.transferrrrrrrr&r)rr(rrrrr!r"rr#rrr$rrr%�rr�<module>r~s���+�������J��2
�HL�,
�`HL�,
�`@D�)�Z@D�)�Z;?�&�T;?�&�\�
���O�l�
���?�J�
���
<�@GK�<�@?C�.�d:>�,�`GK�<�@?C�.�d:>�,r