
    MiO                         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JrJr  \
(       a  SSKJr  \R"                  " S	5      r\" S
5       " S S\5      5       rg)    N)Path)TemporaryDirectory)AnyOptionalTYPE_CHECKING   )	CloudPathNoStatErrorregister_path_class   )S3ClientzK^s3://(?P<arn>arn:aws:s3::\d{12}:accesspoint/[^/]+\.mrap)(?:/(?P<key>.*))?$s3c                       \ rS rSr% SrSr\\S'   S\S'   \\S'   \\S'   \	S	\4S
 j5       r
SS\\   4S jjrSS\S\\   4S jjrSS jr\	S	\4S j5       r\	S	\4S j5       r\	S 5       r\	S	\4S j5       rSrg)S3Path   a  Class for representing and operating on AWS S3 URIs, in the style of the Python standard
library's [`pathlib` module](https://docs.python.org/3/library/pathlib.html). Instances
represent a path in S3 with filesystem path semantics, and convenient methods allow for basic
operations like joining, reading, writing, iterating over contents, etc. This class almost
entirely mimics the [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
interface, so most familiar properties and methods should be available and behave in the
expected way.

The [`S3Client`](../s3client/) class handles authentication with AWS. If a client instance is
not explicitly specified on `S3Path` instantiation, a default client is used. See `S3Client`'s
documentation for more details.
zs3://cloud_prefixr   client_bucket_local_pathreturnc                     U R                   $ N)bucketselfs    p/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/cloudpathlib/s3/s3path.pydriveS3Path.drive&   s    {{    Nmodec                     g r    )r   parentsexist_okr    s       r   mkdirS3Path.mkdir*   s    r   r$   c                 J   U R                  5       (       a1  U(       d  [        SU  35      eU R                  R                  X 5        g [	        5       n[        UR                  5      S-  nUR                  5         U R                  R                  X@5        UR                  5         g )NzFile exists: empty)
existsFileExistsErrorr   
_move_filer   r   nametouch_upload_filecleanup)r   r$   r    tfps        r   r-   S3Path.touch.   sr    ;;==%dV&<==KK""4.#%BRWW'AGGIKK$$Q-JJLr   c                 l    U R                   R                  U 5      n[
        R                  " S S U R                  S S S UR                  SS5      S UR                  SS5      R                  5       S 4
5      $ ! U R                   R                   R                  R                   a    [	        SU  S35      ef = f)NzNo stats available for z%; it may be a directory or not exist.sizer   last_modified)
r   _get_metadata
exceptions	NoSuchKeyr
   osstat_resultr   get	timestamp)r   follow_symlinksmetas      r   statS3Path.stat<   s    	;;,,T2D ~~!!#!,668
 	
 {{!!,,66 	)$/TU 	s   A5 5>B3c                 *   [        U S5      (       a  U R                  $ [        R                  [	        U 5      5      =n(       a"  UR                  S5      U l        U R                  $ U R                  R                  SS5      S   U l        U R                  $ )zKThe bucket name, or the full MRAP ARN for MRAP paths.

:type: :class:`str`
r   arn/r   r   )hasattrr   _MRAP_PATTERNmatchstrgroup
_no_prefixsplit)r   rF   s     r   r   S3Path.bucketS   sz     4##<<!''D	2252 ;;u-DL ||  ??00a8;DL||r   c                 T    U R                   nUR                  S5      (       a  USS  nU$ )NrC   r   )_no_prefix_no_drive
startswith)r   keys     r   rO   
S3Path.keya   s.    && >>#ab'C
r   c                 V    U R                   R                  U 5      R                  S5      $ )Netag)r   r6   r;   r   s    r   rR   S3Path.etagl   s"    {{((.226::r   c                     [        U S5      (       a  U R                  $ U R                  n[        R                  S:X  a  UR                  SS5      nU R                  R                  U-  U l        U R                  $ )Nr   win32:z%3A)rD   r   rI   sysplatformreplacer   _local_cache_dir)r   	no_prefixs     r   _localS3Path._localp   se    4''###OO	<<7"!))#u5I;;77)Cr   )r   r   )FFN)TN)T)__name__
__module____qualname____firstlineno____doc__r   rG   __annotations__r   propertyr   r   r   r%   boolr-   r?   r   rO   rR   r\   __static_attributes__r"   r   r   r   r      s      L#Ls  # d # 
.    S   ; ;      r   r   )r9   rerW   pathlibr   tempfiler   typingr   r   r   	cloudpathr	   r
   r   s3clientr   compilerE   r   r"   r   r   <module>rn      sZ    	 	 
  ' / / C C"

R
 Tf Y f  f r   