ó
    ëBjŸC  ã                   ó@  • S SK r S SK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  SSKJrJr  SSKJr  SSKJr  SSKJr  S	S
KJr   S SKJr  S SKJrJr  S SKJr  S SKJ r   S SK!r"\" S5       " S S\5      5       r%\%RL                  \%l        g! \# a    S\S   l$         N:f = f)é    N)ÚPathÚPurePosixPath)ÚAnyÚCallableÚDictÚIterableÚOptionalÚTupleÚUnioné   )ÚClientÚregister_client_class)Úimplementation_registry)ÚFileCacheMode)ÚCloudPathExceptioné   )ÚS3Path)ÚSession)ÚTransferConfigÚ
S3Transfer)ÚConfig)ÚClientErrorFÚs3c                   óR  ^ • \ rS rSrSrSSSSSSSSSSS\R                  S4S\\   S\\   S\\   S\\	   S	\S
   S\\   S\S   S\\
\\4      S\\
\\R                  4      S\\   S\S   S\\   S\\   4U 4S jjjrS\S\\\4   4S jrS\S\
\\R                  4   S\4S jrS\S\\   4S jrS\S\	4S jrS\4S jrS*S\S\\\\	4      4S jjrS+S\S \S!\	S\4S" jjrS+S\S#\	SS4S$ jjrS\
\\R                  4   S\S\4S% jrS\S\4S& jr S,S\S'\!S\4S( jjr"S)r#U =r$$ )-ÚS3Clienté   zâClient class for AWS S3 which handles authentication with AWS for [`S3Path`](../s3path/)
instances. See documentation for the [`__init__` method][cloudpathlib.s3.s3client.S3Client.__init__]
for detailed authentication options.NFÚaws_access_key_idÚaws_secret_access_keyÚaws_session_tokenÚno_sign_requestÚbotocore_sessionzbotocore.session.SessionÚprofile_nameÚboto3_sessionr   Úfile_cache_modeÚlocal_cache_dirÚendpoint_urlÚboto3_transfer_configr   Úcontent_type_methodÚ
extra_argsc                 óÞ  >• U
=(       d    [         R                  " S5      n
Ub  Xpl        O[        UUUUUS9U l        U(       a  U R                  R	                  SU
[        [        R                  R                  S9S9U l	        U R                  R                  SU
[        [        R                  R                  S9S9U l
        O>U R                  R	                  SU
S9U l	        U R                  R                  SU
S9U l
        X°l        Uc  0 nXÐl        UR                  5        VVs0 s H  u  pïU[        R                  ;   d  M  Xï_M     snnU l        UR                  5        VVs0 s H  u  pïU[        R"                  ;   d  M  Xï_M     snnU l        S Vs0 s H#  nXàR                  ;   d  M  XàR                  U   _M%     snU l        X l        [*        TU ]Y  U	UUS	9  gs  snnf s  snnf s  snf )
aè  Class constructor. Sets up a boto3 [`Session`](
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html).
Directly supports the same authentication interface, as well as the same environment
variables supported by boto3. See [boto3 Session documentation](
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/session.html).

If no authentication arguments or environment variables are provided, then the client will
be instantiated as anonymous, which will only have access to public buckets.

Args:
    aws_access_key_id (Optional[str]): AWS access key ID.
    aws_secret_access_key (Optional[str]): AWS secret access key.
    aws_session_token (Optional[str]): Session key for your AWS account. This is only
        needed when you are using temporarycredentials.
    no_sign_request (Optional[bool]): If `True`, credentials are not looked for and we use unsigned
        requests to fetch resources. This will only allow access to public resources. This is equivalent
        to `--no-sign-request` in the [AWS CLI](https://docs.aws.amazon.com/cli/latest/reference/).
    botocore_session (Optional[botocore.session.Session]): An already instantiated botocore
        Session.
    profile_name (Optional[str]): Profile name of a profile in a shared credentials file.
    boto3_session (Optional[Session]): An already instantiated boto3 Session.
    file_cache_mode (Optional[Union[str, FileCacheMode]]): How often to clear the file cache; see
        [the caching docs](https://cloudpathlib.drivendata.org/stable/caching/) for more information
        about the options in cloudpathlib.eums.FileCacheMode.
    local_cache_dir (Optional[Union[str, os.PathLike]]): Path to directory to use as cache
        for downloaded files. If None, will use a temporary directory. Default can be set with
        the `CLOUDPATHLIB_LOCAL_CACHE_DIR` environment variable.
    endpoint_url (Optional[str]): S3 server endpoint URL to use for the constructed boto3 S3 resource and client.
        Parameterize it to access a customly deployed S3-compatible object store such as MinIO, Ceph or any other.
    boto3_transfer_config (Optional[dict]): Instantiated TransferConfig for managing
        [s3 transfers](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/s3.html#boto3.s3.transfer.TransferConfig)
    content_type_method (Optional[Callable]): Function to call to guess media type (mimetype) when
        writing a file to the cloud. Defaults to `mimetypes.guess_type`. Must return a tuple (content type, content encoding).
    extra_args (Optional[dict]): A dictionary of extra args passed to download, upload, and list functions as relevant. You
        can include any keys supported by upload or download, and we will pass on only the relevant args. To see the extra
        args that are supported look at the upload and download lists in the
        [boto3 docs](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/s3.html#boto3.s3.transfer.S3Transfer).
ÚAWS_ENDPOINT_URLN)r   r   r   r!   r"   r   ©Úsignature_version©r&   Úconfig)r&   )ÚRequestPayerÚExpectedBucketOwner)r%   r(   r$   )ÚosÚgetenvÚsessr   Úresourcer   ÚbotocoreÚsessionÚUNSIGNEDr   Úclientr'   Ú_extra_argsÚitemsr   ÚALLOWED_DOWNLOAD_ARGSÚboto3_dl_extra_argsÚALLOWED_UPLOAD_ARGSÚboto3_ul_extra_argsÚboto3_list_extra_argsÚ_endpoint_urlÚsuperÚ__init__)Úselfr   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   ÚkÚvÚ	__class__s                   €ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/cloudpathlib/s3/s3client.pyrC   ÚS3Client.__init__   sä  ø€ ðl $×D¤r§y¢yÐ1CÓ'DˆØÑ$Ø%�IäØ"3Ø&;Ø"3Ø!1Ø)ñˆDŒIö Ø—i‘i×(Ñ(ØØ)Ü´×0@Ñ0@×0IÑ0IÑJð )ð ˆDŒGð
 Ÿ)™)×*Ñ*ØØ)Ü´×0@Ñ0@×0IÑ0IÑJð +ð ˆD�Kð —i‘i×(Ñ(¨¸LÐ(ÐIˆDŒGØŸ)™)×*Ñ*¨4¸lÐ*ÐKˆDŒKà%:Ô"àÑØˆJà%Ôà'×-Ñ-Ô/ô$
Ú/‘T�Q°1¼
×8XÑ8XÑ3X‹DˆAŠDÑ/ò$
ˆÔ ð (×-Ñ-Ô/ô$
Ú/‘T�Q°1¼
×8VÑ8VÑ3V‹DˆAŠDÑ/ò$
ˆÔ ñ =ó&
â<�Ø×$Ñ$Ñ$ó #ˆA×Ñ Ñ"Ò"Ù<ñ&
ˆÔ"ð
 *Ôä‰ÑØ+Ø 3Ø+ð 	ò 	
ùó!$
ùó$
ùò&
s$   Ä%GÅGÅ%G$ÆG$ÆG*Æ-G*Ú
cloud_pathÚreturnc                 óÞ   • U R                   R                  UR                  UR                  5      R                  " S0 U R
                  D6nUS   US   US   UR	                  SS 5      US   S.$ )NÚLastModifiedÚContentLengthÚETagÚContentTypeÚMetadata)Úlast_modifiedÚsizeÚetagÚcontent_typeÚextra© )r   ÚObjectSummaryÚbucketÚkeyÚgetr=   )rD   rJ   Údatas      rH   Ú_get_metadataÚS3Client._get_metadata‰   st   € à�w‰w×$Ñ$ Z×%6Ñ%6¸
¿¹ÓG×KÒKñ 
Ø×&Ñ&ñ
ˆð
 " .Ñ1Ø˜Ñ)Ø˜‘LØ ŸH™H ]°DÓ9Ø˜*Ñ%ñ
ð 	
ó    Ú
local_pathc                 óØ   • [        U5      nU R                  R                  UR                  UR                  5      nUR                  [        U5      U R                  U R                  S9  U$ )N©r   Ú	ExtraArgs)	r   r   ÚObjectrY   rZ   Údownload_fileÚstrr'   r=   )rD   rJ   r`   Úobjs       rH   Ú_download_fileÚS3Client._download_file—   s\   € Ü˜*Ó%ˆ
Ø�g‰g�n‰n˜Z×.Ñ.°
·±Ó?ˆà×ÑÜ�
‹O D×$>Ñ$>È$×JbÑJbð 	ñ 	
ð Ðr_   c                 óH   • UR                   (       d  gU R                  U5      $ )NÚdir)rZ   Ú_s3_file_query)rD   rJ   s     rH   Ú_is_file_or_dirÚS3Client._is_file_or_dir    s   € à�~�~Øð ×"Ñ" :Ó.Ð.r_   c                 ó(  • UR                   (       dZ  S Vs0 s H#  o"U R                  ;   d  M  X R                  U   _M%     nn U R                  R                  " SSUR                  0UD6  gU R                  U5      S L$ s  snf ! [
         a     gf = f)N)r1   ÚBucketTFrW   )rZ   r:   r9   Úhead_bucketrY   r   rl   )rD   rJ   rE   rV   s       rH   Ú_existsÚS3Client._exists¨   sœ   € à�~�~á0GóÚ0G¨1ÐPT×P`ÑP`ÑK`Ó&�×#Ñ# AÑ&Ò&Ñ0Gð ð ðØ—‘×'Ò'ÑJ¨z×/@Ñ/@ÐJÀEÒJØð ×"Ñ" :Ó.°dÐ:Ð:ùòøô ó Ùðús   –A?­A?Á(B Â
BÂBc           	      ó  •  U R                   R                  " SUR                  UR                  R	                  S5      S.U R
                  D6  g! [        U R                   R                  R                  4 aŒ    UR                  R	                  S5      S-   n[        S U R                  R                  UR                  5      R                  R                  " SSU0U R                  D6R                  S5       5       S5      s $ f = f)	zFBoto3 query used for quick checks of existence and if path is file/dirÚ/©rp   ÚKeyÚfilec              3   ó&   #   • U  H  nS v •  M	     g7f)rk   NrW   )Ú.0rg   s     rH   Ú	<genexpr>Ú*S3Client._s3_file_query.<locals>.<genexpr>È   s   é € ð ò"ð õ ò"ùs   ‚ÚPrefixr   NrW   )r9   Úhead_objectrY   rZ   Úrstripr=   r   Ú
exceptionsÚ	NoSuchKeyÚnextr   rp   ÚobjectsÚfilterr@   Úlimit)rD   rJ   rZ   s      rH   rl   ÚS3Client._s3_file_query·   sû   € ð	à�K‰K×#Ò#ð Ø!×(Ñ(Ø—N‘N×)Ñ)¨#Ó.ñð ×*Ñ*òð
 øô ˜TŸ[™[×3Ñ3×=Ñ=Ð>ó 	Ø—.‘.×'Ñ'¨Ó,¨sÑ2ˆCäñð Ÿ™Ÿ™ z×'8Ñ'8Ó9ß ™§¡ð(ñ RØ/2ðRØ6:×6PÑ6PñRç™˜q›ð"óð ó
ò 
ð	ús   ‚AA ÁB3DÄDc           
   #   óT  ^ ^#   • TR                   (       dP  U(       a  [        S5      eUU 4S jT R                  R                  5       R	                  S/ 5       5        S h  v•N   g TR
                  nU(       a  UR                  S5      (       d  US-  n[        5       nT R                  R                  S5      nUR                  " STR                   UU(       a  SOSS.T R                  D6 GH3  nUR	                  S/ 5       Hk  nUR	                  S	5      R                  S5      nX„;  d  M*  T R                  TR                   TR                    SU 35      S
4v •  UR                  U5        Mm     UR	                  S/ 5       GH—  n	U	R	                  S5      [        U5      S  n
[!        U
5      R"                   Hy  nU[%        U5      R                  S5      -   nXÄ;  d  M'  [%        U5      S:w  d  M8  T R                  TR                   TR                    SU 35      S
4v •  UR                  U5        M{     U	R	                  S5      R                  S5      nX„;   a  MÚ  U	R	                  S5      R                  S5      (       aY  U	R	                  S5      S:X  aD  T R                  TR                   TR                    SU 35      S
4v •  UR                  U5        GMX  T R                  TR                   TR                    SU	R	                  S5       35      S4v •  GMš     GM6     g  GNÅ7f)NztCannot recursively list all buckets and contents; you can get all the buckets then recursively list each separately.c              3   ól   >#   • U  H)  nTR                  TR                   US     35      S4v •  M+     g7f)ÚNameTN)Ú	CloudPathÚcloud_prefix)rz   ÚbrJ   rD   s     €€rH   r{   Ú%S3Client._list_dir.<locals>.<genexpr>Û   s:   øé € ð âF�Að —‘ :×#:Ñ#:Ð";¸A¸f¹I¸;Ð GÓHÈ$ÕOÚFùs   ƒ14ÚBucketsru   Úlist_objects_v2Ú )rp   r}   Ú	DelimiterÚCommonPrefixesr}   TÚContentsrw   Ú.ÚSizer   FrW   )rY   ÚNotImplementedErrorr9   Úlist_bucketsr[   rZ   ÚendswithÚsetÚget_paginatorÚpaginater@   r   rŠ   r‹   ÚaddÚlenr   Úparentsrf   )rD   rJ   Ú	recursiveÚprefixÚyielded_dirsÚ	paginatorÚresultÚresult_prefixÚ	canonicalÚ
result_keyÚo_relative_pathÚparentÚparent_canonicals   ``           rH   Ú	_list_dirÚS3Client._list_dirÓ   s  ùé € à× × ÞÜ)ð Kóð õàŸ™×1Ñ1Ó3×7Ñ7¸	À2ÔFó÷ ð ð à—‘ˆÞ˜&Ÿ/™/¨#×.Ñ.Ø�c‰MˆFä“uˆà—K‘K×-Ñ-Ð.?Ó@ˆ	à×(Ò(ð 
Ø×$Ñ$ØÞ&‘r¨Cñ
ð ×(Ñ(õ	
ˆFð "(§¡Ð,<¸bÖ!A�Ø)×-Ñ-¨hÓ7×>Ñ>¸sÓC�	ØÕ0àŸ™Ø)×6Ñ6Ð7¸
×8IÑ8IÐ7JÈ!ÈIÈ;ÐWóð ð	ò ð !×$Ñ$ YÖ/ñ "Bð %Ÿj™j¨°R×8�
à",§.¡.°Ó"7¼¸F»¸Ð"F�Ü+¨OÓ<×DÔD�FØ'-´°F³×0BÑ0BÀ3Ó0GÑ'GÐ$Ø'Õ;ÄÀFÃÈsÕ@Rà ŸN™NØ#-×#:Ñ#:Ð";¸J×<MÑ<MÐ;NÈaÐP`ÐOaÐ bóð !ð	ò ð %×(Ñ(Ð)9Ö:ñ Eð 'ŸN™N¨5Ó1×8Ñ8¸Ó=�	ØÓ,Ùð —>‘> %Ó(×1Ñ1°#×6Ñ6¸:¿>¹>È&Ó;QÐUVÓ;VàŸ™Ø)×6Ñ6Ð7¸
×8IÑ8IÐ7JÈ!ÈIÈ;ÐWóð ð	ò ð !×$Ñ$ Y×/ð
 Ÿ™Ø)×6Ñ6Ð7¸
×8IÑ8IÐ7JÈ!ÈJÏNÉNÐ[`ÓLaÐKbÐcóð ð	õ ô? 9ò'
òùs'   „AL(Á L%Á!CL(Ä,B0L(Ç L(Ç1D5L(ÚsrcÚdstÚ
remove_srcc                 ó(  • X:X  aˆ  U R                   R                  UR                  UR                  5      nUR                  " SUR                  UR                  S.U R                  U5      R                  S0 5      SS.U R                  D6  U$ U R                   R                  UR                  UR                  5      nUR                  UR                  UR                  S.U R                  U R                  S9  U(       a  U R                  U5        U$ )Nrv   rV   ÚREPLACE)Ú
CopySourcerQ   ÚMetadataDirective)rc   r   rW   )r   rd   rY   rZ   Ú	copy_fromr]   r[   r?   Úcopyr=   r'   Ú_remove)rD   r¬   r­   r®   ÚoÚtargets         rH   Ú
_move_fileÚS3Client._move_file"  sà   € à‹:Ø—‘—‘˜sŸz™z¨3¯7©7Ó3ˆAØ�KŠKð Ø&)§j¡j¸¿¹ÑAØ×+Ñ+¨CÓ0×4Ñ4°W¸bÓAØ"+ñð ×*Ñ*ò	ð" ˆ
ð —W‘W—^‘^ C§J¡J°·±Ó8ˆFØ�K‰KØŸ:™:¨c¯g©gÑ6Ø×2Ñ2Ø×1Ñ1ð ñ ö Ø—‘˜SÔ!Øˆ
r_   Ú
missing_okc                 ó  • U R                  US9nUS:X  a€  U R                  R                  UR                  UR                  5      R
                  " S0 U R                  D6nUR                  S5      R                  S5      S;  a  [        SU SU 35      eg US:X  aÎ  U R                  R                  UR                  5      nUR                  nU(       a  UR                  S	5      (       d  US	-  nUR                  R                  " SS
U0U R                  D6R
                  " S0 U R                  D6nUS   R                  S5      R                  S5      S;  a  [        SU SU 35      eg U(       d  [        SU S35      eg )N)rJ   rx   ÚResponseMetadataÚHTTPStatusCode)éÌ   éÈ   zDelete operation failed for z with response: rk   ru   r}   r   z(Cannot delete file that does not exist: z# (consider passing missing_ok=True)rW   )rm   r   rd   rY   rZ   Údeleter@   r[   r   rp   r˜   rƒ   r„   ÚFileNotFoundError)rD   rJ   rº   Úfile_or_dirÚresprY   r    s          rH   rµ   ÚS3Client._remove9  s„  € Ø×*Ñ*°jÐ*ÐAˆØ˜&Ó Ø—7‘7—>‘> *×"3Ñ"3°Z·^±^ÓD×KÒKñ Ø×,Ñ,ñˆDð �x‰xÐ*Ó+×/Ñ/Ð0@ÓAÈÓSÜ(Ø2°:°,Ð>NÈtÈfÐUóð ð Tð
 ˜EÓ!à—W‘W—^‘^ J×$5Ñ$5Ó6ˆFà—^‘^ˆFÞ˜fŸo™o¨c×2Ñ2Ø˜#‘�à—>‘>×(Ò(ÑU°ÐU¸$×:TÑ:TÑU×\Ò\ñ Ø×,Ñ,ñˆDð �A‰w�{‰{Ð-Ó.×2Ñ2Ð3CÓDÈJÓVÜ(Ø2°:°,Ð>NÈtÈfÐUóð ð Wö Ü'Ø>¸z¸lÐJmÐnóð ð r_   c                 óP  • U R                   R                  UR                  UR                  5      nU R                  R                  5       nU R                  b*  U R                  [        U5      5      u  pVUb  XTS'   Ub  XdS'   UR                  [        U5      U R                  US9  U$ )NrP   ÚContentEncodingrb   )
r   rd   rY   rZ   r?   r´   r(   rf   Úupload_filer'   )rD   r`   rJ   rg   r)   rU   Úcontent_encodings          rH   Ú_upload_fileÚS3Client._upload_fileZ  s—   € Ø�g‰g�n‰n˜Z×.Ñ.°
·±Ó?ˆà×-Ñ-×2Ñ2Ó4ˆ
à×#Ñ#Ñ/Ø-1×-EÑ-EÄcÈ*ÃoÓ-VÑ*ˆLØÑ'Ø,8˜=Ñ)ØÑ+Ø0@Ð,Ñ-à�‰œ˜J›°×0JÑ0JÐV`ˆÑaØÐr_   c                 óÎ   • [        [        R                  S9nU R                  R	                  SU R
                  US9nUR                  SUR                  UR                  S.SS9nU$ )zÚApparently the best way to get the public URL is to generate a presigned URL
with the unsigned config set. This creates a temporary unsigned client to generate
the correct URL
See: https://stackoverflow.com/a/48197877
r,   r   r.   Ú
get_objectrv   r   ©ÚParamsÚ	ExpiresIn)	r   r6   r8   r4   r9   rA   Úgenerate_presigned_urlrY   rZ   )rD   rJ   Úunsigned_configÚunsigned_clientÚurls        rH   Ú_get_public_urlÚS3Client._get_public_urli  sp   € ô !´8×3DÑ3DÑEˆØŸ)™)×*Ñ*Ø˜t×1Ñ1¸/ð +ð 
ˆð #×9Ñ9ØØ(×/Ñ/¸
¿¹ÑGØð :ð 
ˆð
 ˆ
r_   Úexpire_secondsc                 ój   • U R                   R                  SUR                  UR                  S.US9nU$ )NrÌ   rv   rÍ   )r9   rÐ   rY   rZ   )rD   rJ   rÖ   rÓ   s       rH   Ú_generate_presigned_urlÚ S3Client._generate_presigned_urlz  s:   € Ø—;‘;×5Ñ5ØØ(×/Ñ/¸
¿¹ÑGØ$ð 6ð 
ˆð
 ˆ
r_   )	rA   r:   r=   r@   r'   r?   r9   r   r4   )F)T)i  )%Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	mimetypesÚ
guess_typer	   rf   Úboolr   r   r2   ÚPathLiker   ÚdictrC   r   r   r   r]   r   rh   rm   rr   rl   r   r
   rª   r¸   rµ   rÉ   rÔ   ÚintrØ   Ú__static_attributes__Ú__classcell__)rG   s   @rH   r   r      s]  ø† ñ,ð ,0Ø/3Ø+/Ø*/ØAEØ&*Ø-1Ø?CØ=AØ&*Ø<@Ø2;×2FÑ2FØ%)ñk
à# C™=ðk
ð  (¨™}ðk
ð $ C™=ð	k
ð
 " $™ðk
ð #Ð#=Ñ>ðk
ð ˜s‘mðk
ð   	Ñ*ðk
ð " %¨¨]Ð(:Ñ";Ñ<ðk
ð " %¨¨R¯[©[Ð(8Ñ"9Ñ:ðk
ð ˜s‘mðk
ð  (Ð(8Ñ9ðk
ð & hÑ/ðk
ð ˜T‘N÷k
ð k
ðZ
¨ð 
°4¸¸S¸±>ô 
ð¨ð ¸UÀ3ÈÏÉÐCSÑ=Tð ÐY]ô ð/¨&ð /°X¸c±]ô /ð; &ð ;¨Tô ;ð¨ô ñ8M Fð MÀÈÈvÐW[È|ÑI\Ñ@]õ Mñ^˜fð ¨6ð ¸tð Èvõ ñ. &ð °dð Àdõ ðB u¨S°"·+±+Ð-=Ñ'>ð ÈFð ÐW]ô ð¨&ð °Sô ñ"°&ð È#ð Ð\_÷ ó r_   r   )'rß   r2   Úpathlibr   r   Útypingr   r   r   r   r	   r
   r   r9   r   r   Ú	cloudpathr   Úenumsr   r€   r   Ús3pathr   Úboto3.sessionr   Úboto3.s3.transferr   r   Úbotocore.configr   Úbotocore.exceptionsr   Úbotocore.sessionr6   ÚModuleNotFoundErrorÚdependencies_loadedr   rŠ   rW   r_   rH   Ú<module>ró      s�   ðÛ Û 	ß 'ß H× HÑ Hç 2Ý /Ý !Ý +Ý ð>Ý%ß<Ý&Ý/Ûñ
 �tÓôiˆvó ió ðiðX ×$Ñ$€…øðc ó >Ø8=Ð˜DÑ!Ö5ð>ús   ÁB
 Â
BÂB