
    h                         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  \" S	5       " S
 S\
5      5       rg)    N)Path)TemporaryDirectory)AnyOptionalTYPE_CHECKING   )	CloudPathNoStatErrorregister_path_class   )S3Clients3c                       \ rS rSr% SrSr\\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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returnc                     U R                   $ N)bucketselfs    P/home/james-whalen/.local/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.stat5   s    	;;,,T2D ~~!!#!,668
 	
 {{!!,,66 	)$/TU 	s   A5 5>B3c                 @    U R                   R                  SS5      S   $ )N/r   r   )
_no_prefixsplitr   s    r   r   S3Path.bucketL   s    $$S!,Q//r   c                 T    U R                   nUR                  S5      (       a  USS  nU$ )Nr@   r   )_no_prefix_no_drive
startswith)r   keys     r   rG   
S3Path.keyP   s.    && >>#ab'C
r   c                 V    U R                   R                  U 5      R                  S5      $ )Netag)r   r4   r9   r   s    r   rJ   S3Path.etag[   s"    {{((.226::r   r    )FFN)TN)T)__name__
__module____qualname____firstlineno____doc__r   str__annotations__propertyr   r   r   r#   boolr+   r=   r   rG   rJ   __static_attributes__r    r   r   r   r      s      L#s  # d # 
. 0 0 0 S   ; ;r   r   )r7   pathlibr   tempfiler   typingr   r   r   	cloudpathr	   r
   r   s3clientr   r   r    r   r   <module>r[      sE    	  ' / / C C " TO;Y O; O;r   