
    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TYPE_CHECKINGOptional   )	CloudPathNoStatErrorregister_path_class   )GSClientgsc                       \ 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\
\   4S j5       rSrg	)GSPath   a  Class for representing and operating on Google Cloud Storage 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 GS 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 [`GSClient`](../gsclient/) class handles authentication with GCP. If a client instance is
not explicitly specified on `GSPath` instantiation, a default client is used. See `GSClient`'s
documentation for more details.
zgs://cloud_prefixr   clientreturnc                     U R                   $ N)bucketselfs    P/home/james-whalen/.local/lib/python3.13/site-packages/cloudpathlib/gs/gspath.pydriveGSPath.drive   s    {{    Nmodec                     g r    )r   parentsexist_okr   s       r   mkdirGSPath.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+   GSPath.touch'   sr    ;;==%dV&<==KK""4.#%BRWW'AGGIKK$$Q-JJLr   c                    U R                   R                  U 5      nUc  [        SU  S35      e US   R                  5       n[
        R                  " S S U R                  S S S UR                  SS5      S US 4
5      $ ! [         a    Sn NHf = f)NzNo stats available for z%; it may be a directory or not exist.updatedr   size)	r   _get_metadatar
   	timestampKeyErrorosstat_resultr   get)r   follow_symlinksmetamtimes       r   statGSPath.stat5   s    {{((.<)$/TU 	O--/E ~~!!#
 	
  	E	s   A< <B
Bc                 @    U R                   R                  SS5      S   $ )N/r   r   )
_no_prefixsplitr   s    r   r   GSPath.bucketP   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   blobGSPath.blobT   s.    && >>#ab'C
r   c                 V    U R                   R                  U 5      R                  S5      $ )Netagr   r4   r9   r   s    r   rK   GSPath.etag_   s"    {{((.226::r   c                 l    U R                   R                  U 5      nU(       d  g UR                  SS 5      $ )Nmd5_hashrL   )r   r;   s     r   md5
GSPath.md5c   s-    {{((.xx
D))r   r    )FFN)TN)T)__name__
__module____qualname____firstlineno____doc__r   str__annotations__propertyr   r   r   r#   boolr+   r=   r   rH   rK   rP   __static_attributes__r    r   r   r   r      s      L#s  # d # 
6 0 0 0 c   ; ; *Xc] * *r   r   )r7   pathlibr   tempfiler   typingr   r   r   	cloudpathr	   r
   r   gsclientr   r   r    r   r   <module>ra      sE    	  ' / / C C " TZ*Y Z* Z*r   