U n^3@sddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm Z dd lm Z Gd d d eZ Gd d d eZ GdddeZdS)N)Task)SubmissionTask)CreateMultipartUploadTask)CompleteMultipartUploadTask) get_callbacks)calculate_range_parameter)get_filtered_dict)ChunksizeAdjusterc @seZdZdZdddddddd d Zd d d dddddddd g Zd d d dddddgZd gZddZddZ ddZ ddZ ddZ ddZ dd Zd!S)"CopySubmissionTaskz+Task for submitting tasks to execute a copyZIfMatchZIfModifiedSinceZ IfNoneMatchZIfUnmodifiedSinceZSSECustomerKeyZSSECustomerAlgorithmZSSECustomerKeyMD5 RequestPayer)CopySourceIfMatchCopySourceIfModifiedSinceCopySourceIfNoneMatchCopySourceIfUnmodifiedSinceCopySourceSSECustomerKeyCopySourceSSECustomerAlgorithmCopySourceSSECustomerKeyMD5r r r rrrrrZMetadataDirectivec Cs|jjdkrn|jj}||j}|j}|D] \} } | |jkr.| ||j| <q.|jj f|} |j | d|jj|j kr| |||||n| |||||dS)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 NZ ContentLength)metasize call_args)_get_head_object_request_from_copy_source copy_source extra_argsitemsEXTRA_ARGS_TO_HEAD_ARGS_MAPPINGZ source_clientZ head_objectZprovide_transfer_sizeZmultipart_threshold_submit_copy_request_submit_multipart_request) selfclientconfigosutilrequest_executortransfer_futurerZhead_object_requestrparamvalueresponser&m/private/var/folders/sd/whlwsn6x1_qgglc0mjv25_695qk2gl/T/pip-install-4zq3fp6i/s3transfer/s3transfer/copies.py_submitEsD  zCopySubmissionTask._submitc CsL|jj}t|d}|j|t|j||j|j|j|j ||jj ddddS)Nprogress)rrbucketkeyr callbacksrT)transfer_coordinator main_kwargsis_final) rrr_transfer_coordinatorsubmitCopyObjectTaskrr*r+rr)rrrr r!r"rprogress_callbacksr&r&r'r{s"  z'CopySubmissionTask._submit_copy_requestcCsj|jj}i}|jD]\}} ||jkr| ||<q|j|t|j||j|j |dd} |j } t } | | |jj } tt|jj t| } g}t|d}td| dD]~}||j}t| |d| |jj |d<|| |d| |jj }||j|t|j||j|j|j ||||dd| idq||j}|j|t|j||j|j |d| |d d d dS) N)rr*r+r)r-r.r)ZCopySourceRange)rrr*r+ part_numberrr,r upload_id)r-r.pending_main_kwargs)r6partsT)r-r.r7r/)rrrrCREATE_MULTIPART_ARGS_BLACKLISTr0r1rr*r+Zmultipart_chunksizer Zadjust_chunksizerintmathceilfloatrrange_extra_upload_part_argsr_get_transfer_sizeappend CopyPartTaskr_extra_complete_multipart_argsr)rrrr r!r"rZcreate_multipart_extra_argsr#valZcreate_multipart_future part_sizeZadjuster num_partsZ part_futuresr3r5Zextra_part_argsrZcomplete_multipart_extra_argsr&r&r'rs    z,CopySubmissionTask._submit_multipart_requestcCs,t|trt|Std|t|fdS)NzZExpecting dictionary formatted: {"Bucket": bucket_name, "Key": key} but got %s or type %s.) isinstancedictcopy TypeErrortype)rrr&r&r'rs   z s        t