ó
    &ÝNj¡  ã                   ó  • S SK r S SKrS SKrS SKJr  S SKJr  S SKJrJ	r	J
r
  S SKJr  S SKJrJr  S SKJrJrJrJrJrJrJrJrJr  \R4                  " \5      r " S S	5      r " S
 S\5      r " S S\5      r " S S\5      r  " S S\ 5      r! " S S\5      r" " S S5      r# " S S\5      r$ " S S\$5      r% " S S\5      r& " S S\5      r' " S S\5      r( " S  S!\5      r) " S" S#\5      r* " S$ S%5      r+ " S& S'5      r,g)(é    N)ÚClientError©Úseekable)ÚRetriesExceededErrorÚS3DownloadFailedErrorÚS3ValidationError©ÚIN_MEMORY_DOWNLOAD_TAG)ÚSubmissionTaskÚTask)	ÚS3_RETRYABLE_DOWNLOAD_ERRORSÚCountCallbackInvokerÚDeferredOpenFileÚFunctionContainerÚStreamReaderProgressÚcalculate_num_partsÚcalculate_range_parameterÚget_callbacksÚinvoke_progress_callbacksc                   óR   • \ rS rSrSrS r\S 5       rS rS r	S r
S rS	 rS
 rSrg)ÚDownloadOutputManageré*   aÖ  Base manager class for handling various types of files for downloads

This class is typically used for the DownloadSubmissionTask class to help
determine the following:

    * Provides the fileobj to write to downloads to
    * Get a task to complete once everything downloaded has been written

The answers/implementations differ for the various types of file outputs
that may be accepted. All implementations must subclass and override
public methods from this class.
c                 ó(   • Xl         X l        X0l        g ©N)Ú_osutilÚ_transfer_coordinatorÚ_io_executor)ÚselfÚosutilÚtransfer_coordinatorÚio_executors       ÚP/home/mande/repo/quber/.venv/lib/python3.13/site-packages/s3transfer/download.pyÚ__init__ÚDownloadOutputManager.__init__8   s   € ØŒØ%9Ô"Ø'Õó    c                 ó   • [        S5      e)a5  Determines if the target for the download is compatible with manager

:param download_target: The target for which the upload will write
    data to.

:param osutil: The os utility to be used for the transfer

:returns: True if the manager can handle the type of target specified
    otherwise returns False.
zmust implement is_compatible()©ÚNotImplementedError©ÚclsÚdownload_targetr   s      r"   Úis_compatibleÚ#DownloadOutputManager.is_compatible=   s   € ô "Ð"BÓCÐCr%   c                 ó   • g)z�Get the tag (if any) to associate all GetObjectTasks

:rtype: s3transfer.futures.TaskTag
:returns: The tag to associate all GetObjectTasks with
N© ©r   s    r"   Úget_download_task_tagÚ+DownloadOutputManager.get_download_task_tagK   s   € ð r%   c                 ó   • [        S5      e)zâGet file-like object to use for io writes in the io executor

:type transfer_future: s3transfer.futures.TransferFuture
:param transfer_future: The future associated with upload request

returns: A file-like object to write to
z*must implement get_fileobj_for_io_writes()r'   ©r   Útransfer_futures     r"   Úget_fileobj_for_io_writesÚ/DownloadOutputManager.get_fileobj_for_io_writesS   s   € ô "Ð"NÓOÐOr%   c                 óp   • U R                   R                  U R                  U R                  XU5      5        g)zõQueue IO write for submission to the IO executor.

This method accepts an IO executor and information about the
downloaded data, and handles submitting this to the IO executor.

This method may defer submission to the IO executor if necessary.

N)r   Úsubmitr   Úget_io_write_task©r   ÚfileobjÚdataÚoffsets       r"   Úqueue_file_io_taskÚ(DownloadOutputManager.queue_file_io_task]   s0   € ð 	×"Ñ"×)Ñ)Ø×Ñ˜t×5Ñ5°gÀVÓLõ	
r%   c                 ó2   • [        U R                  UUUS.S9$ )a²  Get an IO write task for the requested set of data

This task can be ran immediately or be submitted to the IO executor
for it to run.

:type fileobj: file-like object
:param fileobj: The file-like object to write to

:type data: bytes
:param data: The data to write out

:type offset: integer
:param offset: The offset to write the data to in the file-like object

:returns: An IO task to be used to write data to a file-like object
)r<   r=   r>   ©Úmain_kwargs)ÚIOWriteTaskr   r;   s       r"   r:   Ú'DownloadOutputManager.get_io_write_taskj   s(   € ô" Ø×&Ñ&à"ØØ ññ
ð 	
r%   c                 ó   • [        S5      e)aq  Get the final io task to complete the download

This is needed because based on the architecture of the TransferManager
the final tasks will be sent to the IO executor, but the executor
needs a final task for it to signal that the transfer is done and
all done callbacks can be run.

:rtype: s3transfer.tasks.Task
:returns: A final task to completed in the io executor
z"must implement get_final_io_task()r'   r0   s    r"   Úget_final_io_taskÚ'DownloadOutputManager.get_final_io_task„   s   € ô "Ð"FÓGÐGr%   c                 óŽ   • [        USU R                  R                  S9nU R                  R	                  UR
                  5        U$ )NÚwb)ÚmodeÚopen_function)r   r   Úopenr   Úadd_failure_cleanupÚclose)r   ÚfilenameÚfs      r"   Ú_get_fileobj_from_filenameÚ0DownloadOutputManager._get_fileobj_from_filename‘   s<   € ÜØ˜4¨t¯|©|×/@Ñ/@ñ
ˆð
 	×"Ñ"×6Ñ6°q·w±wÔ?Øˆr%   )r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r#   Úclassmethodr,   r1   r6   r?   r:   rG   rR   Ú__static_attributes__r/   r%   r"   r   r   *   sB   † ñò(ð
 ñDó ðDòòPò
ò
ò4Hõr%   r   c                   óJ   ^ • \ rS rSrU 4S jr\S 5       rS rS rS r	Sr
U =r$ )ÚDownloadFilenameOutputManageré›   c                 óP   >• [         TU ]  XU5        S U l        S U l        S U l        g r   )Úsuperr#   Ú_final_filenameÚ_temp_filenameÚ_temp_fileobj)r   r   r    r!   Ú	__class__s       €r"   r#   Ú&DownloadFilenameOutputManager.__init__œ   s*   ø€ Ü‰Ñ˜°{ÔCØ#ˆÔØ"ˆÔØ!ˆÕr%   c                 ó"   • [        U[        5      $ r   )Ú
isinstanceÚstrr)   s      r"   r,   Ú+DownloadFilenameOutputManager.is_compatible¢   s   € ä˜/¬3Ó/Ð/r%   c                 óÐ   • UR                   R                  R                  nX l        U R                  R                  U5      U l        U R                  5       U l        U R                  $ r   )	ÚmetaÚ	call_argsr<   r`   r   Úget_temp_filenamera   Ú_get_temp_fileobjrb   )r   r5   r<   s      r"   r6   Ú7DownloadFilenameOutputManager.get_fileobj_for_io_writes¦   sS   € Ø!×&Ñ&×0Ñ0×8Ñ8ˆØ&ÔØ"Ÿl™l×<Ñ<¸WÓEˆÔØ!×3Ñ3Ó5ˆÔØ×!Ñ!Ð!r%   c                 óp   • [        U R                  U R                  U R                  U R                  S.SS9$ )N)r<   Úfinal_filenamer   T)r    rC   Úis_final)ÚIORenameFileTaskr   rb   r`   r   r0   s    r"   rG   Ú/DownloadFilenameOutputManager.get_final_io_task­   s=   € ô  Ø!%×!;Ñ!;à×-Ñ-Ø"&×"6Ñ"6ØŸ,™,ñð
 ñ
ð 	
r%   c                 ó°   • U R                  U R                  5      nU R                  R                  U R                  R
                  U R                  5        U$ r   )rR   ra   r   rN   r   Úremove_file)r   rQ   s     r"   rm   Ú/DownloadFilenameOutputManager._get_temp_fileobj»   sH   € Ø×+Ñ+¨D×,?Ñ,?Ó@ˆØ×"Ñ"×6Ñ6Ø�L‰L×$Ñ$ d×&9Ñ&9ô	
ð ˆr%   )r`   ra   rb   )rT   rU   rV   rW   r#   rY   r,   r6   rG   rm   rZ   Ú__classcell__©rc   s   @r"   r\   r\   ›   s0   ø† õ"ð ñ0ó ð0ò"ò
÷ð r%   r\   c                   ó0   • \ rS rSr\S 5       rS rS rSrg)ÚDownloadSeekableOutputManageréÃ   c                 ó   • [        U5      $ r   r   r)   s      r"   r,   Ú+DownloadSeekableOutputManager.is_compatibleÄ   s   € ä˜Ó(Ð(r%   c                 óB   • UR                   R                  R                  $ r   ©rj   rk   r<   r4   s     r"   r6   Ú7DownloadSeekableOutputManager.get_fileobj_for_io_writesÈ   s   € à×#Ñ#×-Ñ-×5Ñ5Ð5r%   c                 ó(   • [        U R                  S9$ ©N)r    ©ÚCompleteDownloadNOOPTaskr   r0   s    r"   rG   Ú/DownloadSeekableOutputManager.get_final_io_taskÌ   s   € ô (Ø!%×!;Ñ!;ñ
ð 	
r%   r/   N)	rT   rU   rV   rW   rY   r,   r6   rG   rZ   r/   r%   r"   rz   rz   Ã   s   † Øñ)ó ð)ò6õ
r%   rz   c                   ób   ^ • \ rS rSr S
U 4S jjr\S 5       rS rS rS r	U 4S jr
S rS	rU =r$ )Ú DownloadNonSeekableOutputManageréÔ   c                 ó€   >• [         TU ]  XU5        Uc
  [        5       nX@l        [        R
                  " 5       U l        g r   )r_   r#   Ú
DeferQueueÚ_defer_queueÚ	threadingÚLockÚ_io_submit_lock©r   r   r    r!   Údefer_queuerc   s        €r"   r#   Ú)DownloadNonSeekableOutputManager.__init__Õ   s6   ø€ ô 	‰Ñ˜°{ÔCØÑÜ$›,ˆKØ'ÔÜ(Ÿ~š~Ó/ˆÕr%   c                 ó   • [        US5      $ )NÚwrite)Úhasattrr)   s      r"   r,   Ú.DownloadNonSeekableOutputManager.is_compatibleÞ   s   € ä�¨Ó0Ð0r%   c                 ó   • [         $ r   r	   r0   s    r"   r1   Ú6DownloadNonSeekableOutputManager.get_download_task_tagâ   s   € Ü%Ð%r%   c                 óB   • UR                   R                  R                  $ r   r   r4   s     r"   r6   Ú:DownloadNonSeekableOutputManager.get_fileobj_for_io_writeså   s   € Ø×#Ñ#×-Ñ-×5Ñ5Ð5r%   c                 ó(   • [        U R                  S9$ r‚   rƒ   r0   s    r"   rG   Ú2DownloadNonSeekableOutputManager.get_final_io_taskè   s   € Ü'Ø!%×!;Ñ!;ñ
ð 	
r%   c                 óø   >• U R                      U R                  R                  X25      nU H2  nUS   n[        R	                  SUS   U5        [
        TU ]  XU5        M4     S S S 5        g ! , (       d  f       g = f)Nr=   z%Queueing IO offset %s for fileobj: %sr>   )rŽ   r‹   Úrequest_writesÚloggerÚdebugr_   r?   )r   r<   r=   r>   Úwritesr“   rc   s         €r"   r?   Ú3DownloadNonSeekableOutputManager.queue_file_io_taskí   sk   ø€ Ø×!Ó!Ø×&Ñ&×5Ñ5°fÓCˆFÛ�Ø˜V‘}�Ü—‘Ø;Ø˜(‘OØôô
 ‘Ñ*¨7¸&ÖAñ  ÷ "×!Ö!ús   ŽAA+Á+
A9c                 ó0   • [        U R                  UUS.S9$ )N)r<   r=   rB   )ÚIOStreamingWriteTaskr   r;   s       r"   r:   Ú2DownloadNonSeekableOutputManager.get_io_write_taskù   s#   € Ü#Ø×&Ñ&à"Øññ
ð 	
r%   )r‹   rŽ   r   )rT   rU   rV   rW   r#   rY   r,   r1   r6   rG   r?   r:   rZ   rw   rx   s   @r"   r‡   r‡   Ô   s>   ø† àEI÷0ð ñ1ó ð1ò&ò6ò
õ

B÷
ð 
r%   r‡   c                   óJ   ^ • \ rS rSr SU 4S jjr\S 5       rS rS rSr	U =r
$ )Ú$DownloadSpecialFilenameOutputManageri  c                 ó4   >• [         TU ]  XX45        S U l        g r   )r_   r#   Ú_fileobjr�   s        €r"   r#   Ú-DownloadSpecialFilenameOutputManager.__init__  s    ø€ ô 	‰ÑØ¨+ô	
ð ˆ�r%   c                 óR   • [        U[        5      =(       a    UR                  U5      $ r   )rf   rg   Úis_special_filer)   s      r"   r,   Ú2DownloadSpecialFilenameOutputManager.is_compatible  s&   € ä˜/¬3Ó/÷ 
°F×4JÑ4JØó5
ð 	
r%   c                 ó†   • UR                   R                  R                  nU R                  U5      U l        U R                  $ r   )rj   rk   r<   rR   r¨   )r   r5   rP   s      r"   r6   Ú>DownloadSpecialFilenameOutputManager.get_fileobj_for_io_writes  s5   € Ø"×'Ñ'×1Ñ1×9Ñ9ˆØ×7Ñ7¸ÓAˆŒØ�}‰}Ðr%   c                 óD   • [        U R                  SSU R                  0S9$ )NTr<   )r    rq   rC   )ÚIOCloseTaskr   r¨   r0   s    r"   rG   Ú6DownloadSpecialFilenameOutputManager.get_final_io_task  s'   € äØ!%×!;Ñ!;ØØ" D§M¡MÐ2ñ
ð 	
r%   )r¨   r   )rT   rU   rV   rW   r#   rY   r,   r6   rG   rZ   rw   rx   s   @r"   r¦   r¦     s.   ø† àEI÷ð ñ
ó ð
ò
÷

ð 
r%   r¦   c                   óH   • \ rS rSrSrS r SS jrS rS rS r	S	 r
S
 rSrg)ÚDownloadSubmissionTaski   z/Task for submitting tasks to execute a downloadc                 óê   • [         [        [        [        /nUR                  R
                  R                  nU H  nUR                  XB5      (       d  M  Us  $    [        SU S[        U5       S35      e)a”  Retrieves a class for managing output for a download

:type transfer_future: s3transfer.futures.TransferFuture
:param transfer_future: The transfer future for the request

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

:rtype: class of DownloadOutputManager
:returns: The appropriate class to use for managing a specific type of
    input for downloads.
zOutput z
 of type: z is not supported.)
r¦   r\   rz   r‡   rj   rk   r<   r,   ÚRuntimeErrorÚtype)r   r5   r   Údownload_manager_resolver_chainr<   Údownload_manager_clss         r"   Ú _get_download_output_manager_clsÚ7DownloadSubmissionTask._get_download_output_manager_cls#  sz   € ô 1Ü)Ü)Ü,ð	+
Ð'ð "×&Ñ&×0Ñ0×8Ñ8ˆÛ$CÐ Ø#×1Ñ1°'×BÓBØ+Ò+ñ %Dô Ø�g�Y˜j¬¨g«¨Ð7IÐJó
ð 	
r%   Nc           
      ó6  • U R                  Xc5      " X0R                  U5      nUR                  R                  R                  S:X  a  U R                  UUUUUUUU5        gUR                  R                  b  UR                  R                  c·  UR                  " SUR                  R                  R                  UR                  R                  R                  S.UR                  R                  R                  D6n	UR                  R                  U	S   5        UR                  R                  U	R                  S5      5        UR                  R                  UR                   :  a  U R#                  UUUUUUUU5        gU R%                  UUUUUUUU5        g)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 io_executor: s3transfer.futures.BoundedExecutor
:param io_executor: The io 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

:type bandwidth_limiter: s3transfer.bandwidth.BandwidthLimiter
:param bandwidth_limiter: The bandwidth limiter to use when
    downloading streams
Úwhen_requiredN©ÚBucketÚKeyÚContentLengthÚETagr/   )r¹   r   rj   ÚconfigÚresponse_checksum_validationÚ_submit_first_chunk_requestÚsizeÚetagÚhead_objectrk   ÚbucketÚkeyÚ
extra_argsÚprovide_transfer_sizeÚprovide_object_etagÚgetÚmultipart_thresholdÚ_submit_download_requestÚ_submit_ranged_download_request)
r   ÚclientrÂ   r   Úrequest_executorr!   r5   Úbandwidth_limiterÚdownload_output_managerÚresponses
             r"   Ú_submitÚDownloadSubmissionTask._submit?  s–  € ðH #'×"GÑ"GØô#
à
×,Ñ,¨kó#;Ðð �;‰;×Ñ×:Ñ:¸oÓMØ×,Ñ,ØØØØ ØØ'ØØ!ô	ð ð × Ñ ×%Ñ%Ñ-Ø×#Ñ#×(Ñ(Ñ0à×)Ò)ð Ø&×+Ñ+×5Ñ5×<Ñ<Ø#×(Ñ(×2Ñ2×6Ñ6ñð "×&Ñ&×0Ñ0×;Ñ;ñˆHð × Ñ ×6Ñ6Ø˜Ñ)ôð
 × Ñ ×4Ñ4°X·\±\À&Ó5IÔJð ×Ñ×$Ñ$ v×'AÑ'AÓAØ×)Ñ)ØØØØ ØØ'ØØ!õ	ð ×0Ñ0ØØØØ ØØ'ØØ!õ	r%   c	                 ó‚  • UR                   R                  n	UR                  U5      n
[        US5      nUR	                  5       nUR                  5       nU R                  R                  U[        U R                  UU	R                  U	R                  U
U	R                  UUR                  UUR                  US.
U/S9US9  g )NÚprogress)
rÑ   rÈ   rÉ   r<   rÊ   Ú	callbacksÚmax_attemptsrÔ   Úio_chunksizerÓ   ©r    rC   Údone_callbacks©Útag)rj   rk   r6   r   r1   rG   r   r9   ÚImmediatelyWriteIOGetObjectTaskrÈ   rÉ   rÊ   Únum_download_attemptsrÜ   )r   rÑ   rÂ   r   rÒ   r!   rÔ   r5   rÓ   rk   r<   Úprogress_callbacksÚget_object_tagÚ
final_tasks                 r"   rÏ   Ú/DownloadSubmissionTask._submit_download_request¢  sÓ   € ð $×(Ñ(×2Ñ2ˆ	ð *×CÑCØó
ˆô
 +¨?¸JÓGÐð 1×FÑFÓHˆð -×>Ñ>Ó@ˆ
ð 	×"Ñ"×)Ñ)ØÜ+Ø%)×%?Ñ%?à$Ø'×.Ñ.Ø$Ÿ=™=Ø&Ø"+×"6Ñ"6Ø!3Ø$*×$@Ñ$@Ø/FØ$*×$7Ñ$7Ø):ñð !+˜|ñð  ð% 	*ò 	
r%   c	                 ó  • UR                   R                  n	[        US5      n
UR                  U5      nUR                  n[        UR                   R                  U5      nUR                  5       n[        U R                  Xe5      5      n[        U5       Hß  n[        UUU5      nSU0nUR                   R                  b  UR                   R                  US'   UR                  U	R                  5        UR                  5         U R                   R#                  U[%        U R                   UU	R&                  U	R(                  UUU
UR*                  UU-  UUR,                  US.UR.                  /S9US9  Má     UR1                  5         g )NrÙ   ÚRangeÚIfMatch©rÑ   rÈ   rÉ   r<   rÊ   rÚ   rÛ   Ústart_indexrÔ   rÜ   rÓ   rÝ   rß   )rj   rk   r   r6   Úmultipart_chunksizer   rÅ   r1   r   Ú&_get_final_io_task_submission_callbackÚranger   rÆ   ÚupdaterÊ   Ú	incrementr   r9   ÚGetObjectTaskrÈ   rÉ   râ   rÜ   Ú	decrementÚfinalize)r   rÑ   rÂ   r   rÒ   r!   rÔ   r5   rÓ   rk   rã   r<   Ú	part_sizeÚ	num_partsrä   Úfinalize_download_invokerÚiÚrange_parameterrÊ   s                      r"   rÐ   Ú6DownloadSubmissionTask._submit_ranged_download_requestÔ  s•  € ð $×(Ñ(×2Ñ2ˆ	ô +¨?¸JÓGÐð *×CÑCØó
ˆð
 ×.Ñ.ˆ	Ü'¨×(<Ñ(<×(AÑ(AÀ9ÓMˆ	ð 1×FÑFÓHˆô %9Ø×7Ñ7Ø'óó%
Ð!ô
 �yÖ!ˆAä7Ø˜1˜ióˆOð ˜ðˆJð ×#Ñ#×(Ñ(Ñ4Ø(7×(<Ñ(<×(AÑ(A�
˜9Ñ%Ø×Ñ˜i×2Ñ2Ô3Ø%×/Ñ/Ô1à×&Ñ&×-Ñ-Ø ÜØ)-×)CÑ)Cà"(Ø"+×"2Ñ"2Ø(Ÿ}™}Ø#*Ø&0Ø%7Ø(.×(DÑ(DØ'(¨9¡}Ø3JØ(.×(;Ñ(;Ø->ñ!ð %>×$GÑ$GÐ#Hñð" #ð' .ó ñ "ðH 	"×*Ñ*Õ,r%   c                 ób   • UR                  5       n[        U R                  R                  X#5      $ r   )rG   r   r   r9   )r   Údownload_managerr!   rå   s       r"   rí   Ú=DownloadSubmissionTask._get_final_io_task_submission_callback  s0   € ð &×7Ñ7Ó9ˆ
Ü Ø×&Ñ&×-Ñ-¨{ó
ð 	
r%   c                 óB   • X!-  nX#S-
  :X  a  SnOXA-   S-
  nSU SU 3nU$ )Né   Ú zbytes=Ú-r/   )r   rô   Ú
part_indexrõ   Ústart_rangeÚ	end_rangeÚrange_params          r"   Ú_calculate_range_paramÚ-DownloadSubmissionTask._calculate_range_param&  s>   € à Ñ,ˆØ Q™Ó&Ø‰Ià#Ñ/°!Ñ3ˆIØ˜{˜m¨1¨Y¨KÐ8ˆØÐr%   c	                 ól  • UR                   R                  n	UR                  U5      n
[        US5      nUR	                  5       nUR
                  n[        U	R                  5      nSUS-
   3US'   UR                   R                  b  UR                   R                  US'   [        UUUU R                  UUUUU
UU5      n[        U R                  UU	R                  U	R                  U
UUUR                  SUUR                  US.U/S9nUR!                  U5        U R                  R#                  UUUS	9  g )
NrÙ   zbytes=0-rþ   rè   ré   r   rê   rÝ   rß   )rj   rk   r6   r   r1   rì   ÚdictrÊ   rÆ   Ú!GetObjectFirstChunkOnDoneCallbackr   rñ   rÈ   rÉ   râ   rÜ   Úset_taskr9   )r   rÑ   rÂ   r   rÒ   r!   rÔ   r5   rÓ   rk   r<   rã   rä   Ú
chunk_sizerÊ   Úon_done_callbackÚtasks                    r"   rÄ   Ú2DownloadSubmissionTask._submit_first_chunk_request0  sc  € ð $×(Ñ(×2Ñ2ˆ	ð *×CÑCØó
ˆô
 +¨?¸JÓGÐð 1×FÑFÓHˆð ×/Ñ/ˆ
Ü˜)×.Ñ.Ó/ˆ
Ø (¨°a©Ð(8Ð9ˆ
�7Ñà×Ñ×$Ñ$Ñ0Ø$3×$8Ñ$8×$=Ñ$=ˆJ�yÑ!ô =ØØ#ØØ×&Ñ&ØØØØØØØó
Ðô Ø!%×!;Ñ!;à Ø#×*Ñ*Ø —}‘}Ø"Ø(Ø/Ø &× <Ñ <Ø Ø+BØ &× 3Ñ 3Ø%6ñð -Ð-ñ
ˆð" 	×!Ñ! $Ô'à×"Ñ"×)Ñ)ØØØð 	*ò 	
r%   r/   r   )rT   rU   rV   rW   rX   r¹   rÖ   rÏ   rÐ   rí   r  rÄ   rZ   r/   r%   r"   r³   r³      s4   † Ù9ò
ðH ôaòF0
òdH-òT
òõH
r%   r³   c                   ó2   • \ rS rSrS rS rS rS rS rSr	g)	r	  i{  c                 ó–   • Xl         X l        X0l        X@l        XPl        X`l        Xpl        X€l        X�l        X l	        X°l
        S U l        g r   )Ú_transfer_futureÚ_download_output_managerr   r   Ú_clientÚ_configÚ_request_executorÚ_bandwidth_limiterr¨   Ú_progress_callbacksÚ_get_object_tagÚ_task)r   r5   rÔ   r!   r    rÑ   rÂ   rÒ   rÓ   r<   rã   rä   s               r"   r#   Ú*GetObjectFirstChunkOnDoneCallback.__init__|  sJ   € ð !0ÔØ(?Ô%Ø'ÔØ%9Ô"ØŒØŒØ!1ÔØ"3ÔØŒØ#5Ô Ø-ÔØˆ�
r%   c                 óž  • U R                   c  [        S5      eU R                   R                  5       nUcA  U R                  R	                  5       nU R
                  R                  U R                  U5        g U R
                  R                  5       (       aA  U R                  R	                  5       nU R
                  R                  U R                  U5        g U R                  U5      u  p4U R                  R                  R                  U5        U R                  R                  R                  U5        US:X  a'  U R                  R                  U R                  SS5        U R                   R"                  nX5:”  a  U R%                  X45        g U R                  R	                  5       nU R
                  R                  U R                  U5        g )Nz6set_task() must be called before the task is submittedr   r%   )r  rµ   Úget_responser  rG   r   r9   r   ÚdoneÚ_extract_metadatar  rj   rË   rÌ   r?   r¨   r  rì   Ú_schedule_remaining_chunks)r   rÕ   rå   rÅ   rÆ   r  s         r"   Ú__call__Ú*GetObjectFirstChunkOnDoneCallback.__call__—  sx  € Ø�:‰:ÑÜØHóð ð —:‘:×*Ñ*Ó,ˆØÑð ×6Ñ6×HÑHÓJˆJØ×&Ñ&×-Ñ-¨d×.?Ñ.?ÀÔLØð ×%Ñ%×*Ñ*×,Ñ,Ø×6Ñ6×HÑHÓJˆJØ×&Ñ&×-Ñ-¨d×.?Ñ.?ÀÔLØà×+Ñ+¨HÓ5‰
ˆØ×Ñ×"Ñ"×8Ñ8¸Ô>Ø×Ñ×"Ñ"×6Ñ6°tÔ<à�1‹9ð
 ×)Ñ)×<Ñ<Ø—‘˜s Aôð —\‘\×5Ñ5ˆ
ØÓØ×+Ñ+¨DÕ7à×6Ñ6×HÑHÓJˆJØ×&Ñ&×-Ñ-¨d×.?Ñ.?ÀÕLr%   c                 ó   • Xl         g r   )r  )r   r  s     r"   r
  Ú*GetObjectFirstChunkOnDoneCallback.set_taskÀ  s   € Ø�
r%   c                 ó    • UR                  S5      nU(       a  [        UR                  S5      S   5      nOUS   nUR                  S5      nX44$ )NÚContentRangeÚ/éÿÿÿÿrÀ   rÁ   )rÍ   ÚintÚsplit)r   rÕ   Úcontent_rangerÅ   rÆ   s        r"   r  Ú3GetObjectFirstChunkOnDoneCallback._extract_metadataÃ  sO   € Ø Ÿ™ ^Ó4ˆÞô �}×*Ñ*¨3Ó/°Ñ3Ó4‰Dà˜OÑ,ˆDØ�|‰|˜FÓ#ˆØˆzÐr%   c                 ó‚  • U R                   R                  R                  nU R                  R                  n[        X5      nU R                  R                  5       n[        [        U R                  R                  U R                  U5      5      n[        SU5       GH  n[        XHU5      n	SU	0n
Ub  X*S'   U
R                  UR                   5        UR#                  5         U R                  R                  U R$                  ['        U R                  U R(                  UR*                  UR,                  U R.                  U
U R0                  U R                  R2                  X„-  U R                  U R                  R4                  U R6                  S.UR8                  /S9U R:                  S9  GM     UR=                  5         g )Nrþ   rè   ré   rê   rÝ   rß   )r  rj   rk   r  rì   r   r  rG   r   r   r   r9   r   rî   r   rï   rÊ   rð   r  rñ   r  rÈ   rÉ   r¨   r  râ   rÜ   r  rò   r  ró   )r   rÅ   rÆ   rk   rô   rõ   rå   rö   r÷   rø   rÊ   s              r"   r  Ú<GetObjectFirstChunkOnDoneCallback._schedule_remaining_chunksÎ  s‘  € Ø×)Ñ)×.Ñ.×8Ñ8ˆ	Ø—L‘L×4Ñ4ˆ	Ü'¨Ó8ˆ	ð ×2Ñ2×DÑDÓFˆ
Ü$8ÜØ×*Ñ*×1Ñ1Ø×!Ñ!Øóó%
Ð!ô �q˜)×$ˆAÜ7Ø˜ióˆOð ˜ðˆJð ÑØ(,˜9Ñ%Ø×Ñ˜i×2Ñ2Ô3Ø%×/Ñ/Ô1à×&Ñ&×-Ñ-Ø×&Ñ&ÜØ)-×)CÑ)Cà"&§,¡,Ø"+×"2Ñ"2Ø(Ÿ}™}Ø#'§=¡=Ø&0Ø%)×%=Ñ%=Ø(,¯©×(JÑ(JØ'(¡}Ø37×3PÑ3PØ(,¯©×(AÑ(AØ-1×-DÑ-Dñ!ð %>×$GÑ$GÐ#Hñð" ×(Ñ(ð' .ô ñ %ðD 	"×*Ñ*Õ,r%   )r  r  r  r  r¨   r  r   r  r  r  r   r  N)
rT   rU   rV   rW   r#   r   r
  r  r  rZ   r/   r%   r"   r	  r	  {  s   † òò6'MòRò	õ3-r%   r	  c                   ó4   • \ rS rSr  SS jrS rS rS rSrg)	rñ   i  Nc           
      ó@  • Sn[        U5       HÛ  n U
nUR                  " SX#S.UD6nXðl        U R                  UR	                  S5      UR	                  S5      5        [        US   U5      nU(       a  UR                  UU R                  5      n[        UU	5      nU HG  nU R                  R                  5       (       d$  U R                  UUUU5        U[        U5      -  nMF      g     g   ['        U5      e! [         a`  nUR                  R	                  S0 5      R	                  S5      nUS:X  a  [        S	U S
U S35      eUS:X  a  SSSS.U l         SnA  ge SnAf[         a3  n[         R#                  SUUUSS9  Un[%        XjW-
  5         SnAGMŠ  SnAff = f)a^  Downloads an object and places content into io queue

:param client: The client to use when calling GetObject
:param bucket: The bucket to download from
:param key: The key to download from
:param fileobj: The file handle to write content to
:param exta_args: Any extra arguments to include in GetObject request
:param callbacks: List of progress callbacks to invoke on download
:param max_attempts: The number of retries to do when downloading
:param download_output_manager: The download output manager associated
    with the current download.
:param io_chunksize: The size of each io chunk to read from the
    download stream and queue in the io queue.
:param start_index: The location in the file to start writing the
    content of the key to.
:param bandwidth_limiter: The bandwidth limiter to use when throttling
    the downloading of data in streams.
Nr½   rè   r%  ÚBodyÚErrorÚCodeÚPreconditionFailedzContents of stored object "z" in bucket "z" did not match expected ETag.ÚInvalidRanger   )rÀ   r%  rÁ   zCRetrying exception caught (%s), retrying request, (attempt %s / %s)T)Úexc_infor/   )rî   Ú
get_objectÚ	_responseÚ_validate_content_rangerÍ   r   Úget_bandwith_limited_streamr   ÚDownloadChunkIteratorr  Ú
_handle_ioÚlenr   rÕ   r   r   rž   rŸ   r   r   )r   rÑ   rÈ   rÉ   r<   rÊ   rÚ   rÛ   rÔ   rÜ   rë   rÓ   Úlast_exceptionr÷   Úcurrent_indexrÕ   Ústreaming_bodyÚchunksÚchunkÚeÚ
error_codes                        r"   Ú_mainÚGetObjectTask._main  sç  € ð@ ˆÜ�|Ö$ˆAðFØ +�Ø!×,Ò,ð Ø!ñØ.8ñ�ð "*”à×,Ñ,Ø—N‘N 7Ó+Ø—L‘L Ó0ôô "6Ø˜VÑ$ ió"�ö %à)×EÑEØ*¨D×,FÑ,Fóð #ô /¨~¸|ÓL�Û#�Eð  ×5Ñ5×:Ñ:×<Ñ<ØŸ™Ø3Ø#Ø!Ø)ô	ð &¬¨U«Ñ3šâñ $ñ ñM %ôP # >Ó2Ð2øôC ó ØŸZ™ZŸ^™^¨G°RÓ8×<Ñ<¸VÓD�
ØÐ!5Ó5Ü/Ø5°c°Uð ;Ø"˜8Ð#AðCóð ð   >Ó1à)*Ø(,Ø $ñ&�D”Nõ
 àûÜ/ó Ü—‘ð:àØØ Ø!ð ñ ð "#�ô *Ø¨]Ñ:ôö ûð!ús1   ’CC8Ã'C8Ã8
FÄAEÅEÅFÅ*'FÆFc                 ó(   • UR                  X#U5        g r   )r?   )r   rÔ   r<   rA  Úindexs        r"   r;  ÚGetObjectTask._handle_iop  s   € Ø×2Ñ2°7À5ÕIr%   c                 ó   • [        U SS 5      $ )Nr7  )Úgetattrr0   s    r"   r  ÚGetObjectTask.get_responses  s   € Ü�t˜[¨$Ó/Ð/r%   c                 ó˜  • U(       a  U(       d  g UR                  S5      u  p4USS  nSU;  a  g UR                  SS5      u  pg[        U5      nU(       a  [        U5      O[        U5      S-
  nUSS  nUR                  SS5      u  pš[        U	5      n	[        U
5      n
X–:w  a  [        SU	 SU S35      eX§:”  a  [        SU
 S	U S35      eg )
Nr&  é   r   rþ   zResponse range start `z"` does not match requested start `Ú`zResponse range end `z` exceeds requested end `)r)  r(  r   )r   Úrequested_ranger*  Úresponse_rangeÚ
total_sizeÚreq_range_partÚ	req_startÚreq_endÚresp_range_partÚ
resp_startÚresp_ends              r"   r8  Ú%GetObjectTask._validate_content_rangev  sþ   € Þ¦mØð &3×%8Ñ%8¸Ó%=Ñ"ˆà(¨¨Ð,ˆØ�nÓ$ØØ+×1Ñ1°#°qÓ9Ñˆ	Ü˜	“Nˆ	æ")”#�g”,¬s°:«ÀÑ/Bˆð )¨¨Ð,ˆØ.×4Ñ4°S¸!Ó<Ñˆ
Ü˜“_ˆ
Ü�x“=ˆð Ó"Ü#Ø(¨¨ð 5$Ø$- ;¨að1óð ð ÓÜ#Ø& x jð 1"Ø") ¨!ð-óð ð r%   )r7  )r   N)	rT   rU   rV   rW   rD  r;  r  r8  rZ   r/   r%   r"   rñ   rñ     s!   † ð Øôi3òVJò0õ"r%   rñ   c                   ó   • \ rS rSrSrS rSrg)rá   i›  zðGetObjectTask that immediately writes to the provided file object

This is useful for downloads where it is known only one thread is
downloading the object so there is no reason to go through the
overhead of using an IO queue and executor.
c                 ó6   • UR                  X#U5      nU" 5         g r   )r:   )r   rÔ   r<   rA  rG  r  s         r"   r;  Ú*ImmediatelyWriteIOGetObjectTask._handle_io£  s   € Ø&×8Ñ8¸ÈÓOˆÙ�r%   r/   N)rT   rU   rV   rW   rX   r;  rZ   r/   r%   r"   rá   rá   ›  s   † ñõr%   rá   c                   ó   • \ rS rSrS rSrg)rD   i¨  c                 óH   • UR                  U5        UR                  U5        g)z¶Pulls off an io queue to write contents to a file

:param fileobj: The file handle to write content to
:param data: The data to write
:param offset: The offset to write the data to.
N)Úseekr“   r;   s       r"   rD  ÚIOWriteTask._main©  s   € ð 	�‰�VÔØ�‰�dÕr%   r/   N)rT   rU   rV   rW   rD  rZ   r/   r%   r"   rD   rD   ¨  s   † õr%   rD   c                   ó   • \ rS rSrSrS rSrg)r£   i´  z/Task for writing data to a non-seekable stream.c                 ó&   • UR                  U5        g)z³Write data to a fileobj.

Data will be written directly to the fileobj without
any prior seeking.

:param fileobj: The fileobj to write content to
:param data: The data to write

N)r“   )r   r<   r=   s      r"   rD  ÚIOStreamingWriteTask._main·  s   € ð 	�‰�dÕr%   r/   N©rT   rU   rV   rW   rX   rD  rZ   r/   r%   r"   r£   r£   ´  s
   † Ù9õ
r%   r£   c                   ó   • \ rS rSrSrS rSrg)rr   iÄ  züA task to rename a temporary file to its final filename

:param fileobj: The file handle that content was written to.
:param final_filename: The final name of the file to rename to
    upon completion of writing the contents.
:param osutil: OS utility
c                 ó\   • UR                  5         UR                  UR                  U5        g r   )rO   Úrename_fileÚname)r   r<   rp   r   s       r"   rD  ÚIORenameFileTask._mainÍ  s   € Ø�‰ŒØ×Ñ˜7Ÿ<™<¨Õ8r%   r/   Nrc  r/   r%   r"   rr   rr   Ä  s   † ñõ9r%   rr   c                   ó   • \ rS rSrSrS rSrg)r°   iÒ  zaA task to close out a file once the download is complete.

:param fileobj: The fileobj to close.
c                 ó$   • UR                  5         g r   )rO   )r   r<   s     r"   rD  ÚIOCloseTask._mainØ  s   € Ø�‰�r%   r/   Nrc  r/   r%   r"   r°   r°   Ò  s   † ñõ
r%   r°   c                   ó>   ^ • \ rS rSrSr    SU 4S jjrS rSrU =r$ )r„   iÜ  z£A NOOP task to serve as an indicator that the download is complete

Note that the default for is_final is set to True because this should
always be the last task.
c                 ó(   >• [         TU ]  UUUUUS9  g )N)r    rC   Úpending_main_kwargsrÞ   rq   )r_   r#   )r   r    rC   rn  rÞ   rq   rc   s         €r"   r#   Ú!CompleteDownloadNOOPTask.__init__ã  s&   ø€ ô 	‰ÑØ!5Ø#Ø 3Ø)Øð 	ò 	
r%   c                 ó   • g r   r/   r0   s    r"   rD  ÚCompleteDownloadNOOPTask._mainó  s   € Ør%   r/   )NNNT)	rT   rU   rV   rW   rX   r#   rD  rZ   rw   rx   s   @r"   r„   r„   Ü  s%   ø† ñð Ø ØØ÷
÷ ð r%   r„   c                   ó*   • \ rS rSrS rS rS r\rSrg)r:  i÷  c                 ó*   • Xl         X l        SU l        g)z†Iterator to chunk out a downloaded S3 stream

:param body: A readable file-like object
:param chunksize: The amount to read each time
r   N©Ú_bodyÚ
_chunksizeÚ
_num_reads)r   ÚbodyÚ	chunksizes      r"   r#   ÚDownloadChunkIterator.__init__ø  s   € ð Œ
Ø#ŒØˆ�r%   c                 ó   • U $ r   r/   r0   s    r"   Ú__iter__ÚDownloadChunkIterator.__iter__  s   € Øˆr%   c                 óÀ   • U R                   R                  U R                  5      nU =R                  S-  sl        U(       a  U$ U R                  S:X  a  U$ [	        5       e)Nrþ   )ru  Úreadrv  rw  ÚStopIteration)r   rA  s     r"   Ú__next__ÚDownloadChunkIterator.__next__  sI   € Ø—
‘
—‘ §¡Ó0ˆØ�Š˜1Ñ�ÞØˆLØ�_‰_ Ó!ð
 ˆLÜ‹oÐr%   rt  N)	rT   rU   rV   rW   r#   r|  r�  ÚnextrZ   r/   r%   r"   r:  r:  ÷  s   † òòòð ƒDr%   r:  c                   ó$   • \ rS rSrSrS rS rSrg)rŠ   i  a  IO queue that defers write requests until they are queued sequentially.

This class is used to track IO data for a *single* fileobj.

You can send data to this queue, and it will defer any IO write requests
until it has the next contiguous block available (starting at 0).

c                 ó.   • / U l         0 U l        SU l        g )Nr   )Ú_writesÚ_pending_offsetsÚ_next_offsetr0   s    r"   r#   ÚDeferQueue.__init__  s   € ØˆŒØ "ˆÔØˆÕr%   c                 ó$  • U[        U5      -   U R                  ::  a  / $ / nXR                  :  a  U R                  U-
  nX$S nU R                  nXR                  ;   a8  U R                  U   n[        U5      [        U5      ::  a  / $ X R                  U'   O/[        R                  " U R
                  U5        X R                  U'   U R
                  (       aº  U R
                  S   U R                  :X  a�  [        R                  " U R
                  5      nU R                  U   nUR                  XgS.5        U R                  U	 U =R                  [        U5      -  sl        U R
                  (       a  U R
                  S   U R                  :X  a  M�  U$ )a�  Request any available writes given new incoming data.

You call this method by providing new data along with the
offset associated with the data.  If that new data unlocks
any contiguous writes that can now be submitted, this
method will return all applicable writes.

This is done with 1 method call so you don't have to
make two method calls (put(), get()) which acquires a lock
each method call.

Nr   )r>   r=   )r<  rˆ  r‡  ÚheapqÚheappushr†  ÚheappopÚappend)r   r>   r=   r    Ú
seen_bytesÚqueued_dataÚnext_write_offsetÚ
next_writes           r"   r�   ÚDeferQueue.request_writes$  sW  € ð ”C˜“IÑ ×!2Ñ!2Ó2ð
 ˆIØˆØ×%Ñ%Ó%ð ×*Ñ*¨VÑ3ˆJØ˜Ð$ˆDØ×&Ñ&ˆFØ×*Ñ*Ó*Ø×/Ñ/°Ñ7ˆKÜ�4‹yœC Ó,Ó,ð
 �	ð 15×%Ñ% fÒ-ä�NŠN˜4Ÿ<™<¨Ô0Ø,0×!Ñ! &Ñ)Ø�l�l˜tŸ|™|¨A™°$×2CÑ2CÓCÜ %§¢¨d¯l©lÓ ;ÐØ×.Ñ.Ð/@ÑAˆJØ�M‰MÐ%6ÑKÔLØ×%Ñ%Ð&7Ð8Ø×Ò¤ Z£Ñ0Õð �l�l˜tŸ|™|¨A™°$×2CÑ2CÕCð ˆr%   )rˆ  r‡  r†  N)rT   rU   rV   rW   rX   r#   r�   rZ   r/   r%   r"   rŠ   rŠ     s   † ñòõ
:r%   rŠ   )-r‹  ÚloggingrŒ   Úbotocore.exceptionsr   Ús3transfer.compatr   Ús3transfer.exceptionsr   r   r   Ús3transfer.futuresr
   Ús3transfer.tasksr   r   Ús3transfer.utilsr   r   r   r   r   r   r   r   r   Ú	getLoggerrT   rž   r   r\   rz   r‡   r¦   r³   r	  rñ   rá   rD   r£   rr   r°   r„   r:  rŠ   r/   r%   r"   Ú<module>rœ     s  ðó Û Û å +å &÷ñ õ
 6ß 1÷
÷ 
õ 
ð 
×	Ò	˜8Ó	$€÷nñ nôb%Ð$9ô %ôP
Ð$9ô 
ô",
Ð'<ô ,
ô^
Ð+Kô 
ô:X
˜^ô X
÷v
F-ñ F-ôRT�Dô Tôn
 mô 
ô	�$ô 	ô˜4ô ô 9�tô 9ô�$ô ô˜tô ÷6ñ ÷<Iò Ir%   