
    `2f8                         d dl Z d dlZd dlmZmZmZmZ d dlmZm	Z	m
Z
mZ  G d de      Z G d de      Z G d d	e      Zy)
    N)CompleteMultipartUploadTaskCreateMultipartUploadTaskSubmissionTaskTask)ChunksizeAdjustercalculate_range_parameterget_callbacksget_filtered_dictc            
       j    e Zd ZdZdddddddd	d
d	Zg dZg dZg dZd Zd Z	d Z
d Zd Zd Zd Zy)CopySubmissionTaskz+Task for submitting tasks to execute a copyIfMatchIfModifiedSinceIfNoneMatchIfUnmodifiedSinceSSECustomerKeySSECustomerAlgorithmSSECustomerKeyMD5RequestPayerExpectedBucketOwner)	CopySourceIfMatchCopySourceIfModifiedSinceCopySourceIfNoneMatchCopySourceIfUnmodifiedSinceCopySourceSSECustomerKeyCopySourceSSECustomerAlgorithmCopySourceSSECustomerKeyMD5r   r   )r   r   r   r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   MetadataDirectiveTaggingDirective)r   r   r   r   r   c                 ,   |j                   j                  |j                   j                  }| j                  |j                        }|j
                  }|j                         D ]&  \  }	}
|	| j                  v s|
|| j                  |	   <   (  |j                  j                  di |}|j                   j                  |d          |j                   j                  |j                  k  r| j                  |||||       y| j                  |||||       y)a  
        :param client: The client associated with the transfer manager

        :type config: s3transfer.manager.TransferConfig
        :param config: The transfer config associated with the transfer
            manager

        :type osutil: s3transfer.utils.OSUtil
        :param osutil: The os utility associated to the transfer manager

        :type request_executor: s3transfer.futures.BoundedExecutor
        :param request_executor: The request executor associated with the
            transfer manager

        :type transfer_future: s3transfer.futures.TransferFuture
        :param transfer_future: The transfer future associated with the
            transfer request that tasks are being submitted for
        NContentLength )metasize	call_args)_get_head_object_request_from_copy_sourcecopy_source
extra_argsitemsEXTRA_ARGS_TO_HEAD_ARGS_MAPPINGsource_clienthead_objectprovide_transfer_sizemultipart_threshold_submit_copy_request_submit_multipart_request)selfclientconfigosutilrequest_executortransfer_futurer$   head_object_requestr'   paramvalueresponses               Q/var/www/highfloat_scraper/venv/lib/python3.12/site-packages/s3transfer/copies.py_submitzCopySubmissionTask._submitP   s-   , $$, (,,66I>>))  
 #--J !+ 0 0 2 uD@@@  (<<UC ;y..:: %H   66) $$v'A'AA%%(8/ **(8/    c                 4   |j                   j                  }t        |d      }| j                  j	                  |t        | j                  ||j                  |j                  |j                  |j                  ||j                   j                  dd             y )Nprogress)r1   r&   bucketkeyr'   	callbacksr#   T)transfer_coordinatormain_kwargsis_final)r"   r$   r	   _transfer_coordinatorsubmitCopyObjectTaskr&   r?   r@   r'   r#   )r0   r1   r2   r3   r4   r5   r$   progress_callbackss           r:   r.   z'CopySubmissionTask._submit_copy_request   s     $((22	 +?JG 	""))%)%?%?$#,#8#8'..$=="+"6"6!3+0055 	
r<   c                 (   |j                   j                  }i }|j                  j                         D ]  \  }}	|| j                  vs|	||<    | j
                  j                  |t        | j
                  ||j                  |j                  |d            }
|j                  }t               }|j                  ||j                   j                        }t        t        j                   |j                   j                  t#        |      z              }g }t%        |d      }t'        d|dz         D ]  }| j)                  |j                        }t+        ||dz
  ||j                   j                        |d<   | j-                  ||dz
  ||j                   j                        }|j                  j/                  d      }|j1                  | j
                  j                  |t3        | j
                  ||j4                  |j                  |j                  |||||d	d|
i	                    | j7                  |j                        }| j
                  j                  |t9        | j
                  ||j                  |j                  |d|
|d
d             y )N)r1   r?   r@   r'   )rB   rC   r>      CopySourceRangeChecksumAlgorithm)	r1   r&   r?   r@   part_numberr'   rA   r#   checksum_algorithm	upload_id)rB   rC   pending_main_kwargs)rO   partsT)rB   rC   rP   rD   )r"   r$   r'   r(   CREATE_MULTIPART_ARGS_BLACKLISTrE   rF   r   r?   r@   multipart_chunksizer   adjust_chunksizer#   intmathceilfloatr	   range_extra_upload_part_argsr   _get_transfer_sizegetappendCopyPartTaskr&   _extra_complete_multipart_argsr   )r0   r1   r2   r3   r4   r5   r$   create_multipart_extra_argsr7   valcreate_multipart_future	part_sizeadjuster	num_partspart_futuresrH   rM   extra_part_argsr#   rN   complete_multipart_extra_argss                        r:   r/   z,CopySubmissionTask._submit_multipart_request   s    $((22	 ')##..446 	9JE3D@@@58+E2	9 #'"<"<"C"C%%)%?%?$'..$=="=	#
 ..	$&--++00
	 IIo**//%	2BBC
	
 *?JG IM2 ,	K"::$$O 2Ka$$))	2O-. **a$$))	D "+!5!5!9!9:M!N**11$ -1-G-G&,+4+@+@&/&6&6#,==+6*9);$(2D
% ()@-/,	\ )-(K(K  )
% 	""))'%)%?%?$'..$=="?	 "9)% 	
r<   c                     t        |t              rt        j                  |      S t        d|dt	        |      d      )NzLExpecting dictionary formatted: {"Bucket": bucket_name, "Key": key} but got z	 or type .)
isinstancedictcopy	TypeErrortype)r0   r&   s     r:   r%   z<CopySubmissionTask._get_head_object_request_from_copy_source  s:    k4(99[)) -8k9JL r<   c                 .    t        || j                        S N)r
   UPLOAD_PART_COPY_ARGSr0   r'   s     r:   rZ   z*CopySubmissionTask._extra_upload_part_args  s     !T-G-GHHr<   c                 .    t        || j                        S rq   )r
   COMPLETE_MULTIPART_ARGSrs   s     r:   r_   z1CopySubmissionTask._extra_complete_multipart_args#  s     T-I-IJJr<   c                 &    ||dz
  k(  r|||z  z
  S |S )NrJ   r!   )r0   rc   
part_indexre   total_transfer_sizes        r:   r[   z%CopySubmissionTask._get_transfer_size&  s(     Q& '*y*@AAr<   N)__name__
__module____qualname____doc__r)   rr   rR   ru   r;   r.   r/   r%   rZ   r_   r[   r!   r<   r:   r   r      sj    5 '%6!.':$4*@':&4
'#
'#<|
4j
XI
Kr<   r   c                       e Zd ZdZd Zy)rG   zTask to do a nonmultipart copyc                 P     |j                   d|||d| |D ]  } ||        y)a  
        :param client: The client to use when calling PutObject
        :param copy_source: The CopySource parameter to use
        :param bucket: The name of the bucket to copy to
        :param key: The name of the key to copy to
        :param extra_args: A dictionary of any extra arguments that may be
            used in the upload.
        :param callbacks: List of callbacks to call after copy
        :param size: The size of the transfer. This value is passed into
            the callbacks

        )
CopySourceBucketKeybytes_transferredNr!   )copy_object)	r0   r1   r&   r?   r@   r'   rA   r#   callbacks	            r:   _mainzCopyObjectTask._main3  sA     	 	
"6s	
>H	
 " 	-Ht,	-r<   Nry   rz   r{   r|   r   r!   r<   r:   rG   rG   0  s
    (-r<   rG   c                       e Zd ZdZ	 ddZy)r^   z)Task to upload a part in a multipart copyNc           	           |j                   d|||||d|}|D ]  } ||	        |d   d   }||d}|
r%d|
j                          }||d   v r|d   |   ||<   |S )a<  
        :param client: The client to use when calling PutObject
        :param copy_source: The CopySource parameter to use
        :param bucket: The name of the bucket to upload to
        :param key: The name of the key to upload to
        :param upload_id: The id of the upload
        :param part_number: The number representing the part of the multipart
            upload
        :param extra_args: A dictionary of any extra arguments that may be
            used in the upload.
        :param callbacks: List of callbacks to call after copy part
        :param size: The size of the transfer. This value is passed into
            the callbacks
        :param checksum_algorithm: The algorithm that was used to create the multipart
            upload

        :rtype: dict
        :returns: A dictionary representing a part::

            {'Etag': etag_value, 'PartNumber': part_number}

            This value can be appended to a list to be used to complete
            the multipart upload. If a checksum is in the response,
            it will also be included.
        )r   r   r   UploadId
PartNumberr   CopyPartResultETag)r   r   Checksumr!   )upload_part_copyupper)r0   r1   r&   r?   r@   rO   rM   r'   rA   r#   rN   r9   r   etagpart_metadatachecksum_members                   r:   r   zCopyPartTask._mainL  s    L +6** 
""
 
 " 	-Ht,	-()&1!%[A ();)A)A)C(DEO(+;"<<19:J1K#2o. r<   rq   r   r!   r<   r:   r^   r^   I  s    3  8r<   r^   )rm   rV   s3transfer.tasksr   r   r   r   s3transfer.utilsr   r   r	   r
   r   rG   r^   r!   r<   r:   <module>r      sH       O Od-T -2;4 ;r<   