o
    oĎi                     @   st   d dl Z d dlmZ d dlmZ d dlmZmZmZ ddl	m
Z
mZmZ er,ddlmZ ed	G d
d de
ZdS )    N)Path)TemporaryDirectory)AnyTYPE_CHECKINGOptional   )	CloudPathNoStatErrorregister_path_class   )GSClientgsc                   @   s   e Zd ZU dZdZeed< ded< edefddZdde	e
 fddZddede	e
 fddZdddZedefddZedefddZedd Zede	e fddZd
S )GSPathaG  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                 C   s   | j S N)bucketself r   R/home/jeff/fluffinator/venv/lib/python3.10/site-packages/cloudpathlib/gs/gspath.pydrive   s   zGSPath.driveFNmodec                 C   s   d S r   r   )r   parentsexist_okr   r   r   r   mkdir#   s   zGSPath.mkdirTr   c                 C   sb   |   r|std|  | j| |  d S t }t|jd }|  | j||  |	  d S )NzFile exists: empty)
existsFileExistsErrorr   
_move_filer   r   nametouch_upload_filecleanup)r   r   r   tfpr   r   r   r"   '   s   zGSPath.touchc                 C   st   | j | }|d u rtd|  dz|d  }W n ty%   d}Y nw td d | jd d d |ddd |d f
S )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mtimer   r   r   stat5   s.   

zGSPath.statc                 C   s   | j ddd S )N/r   r   )
_no_prefixsplitr   r   r   r   r   P      zGSPath.bucketc                 C   s    | j }|dr|dd  }|S )Nr3   r   )_no_prefix_no_drive
startswith)r   keyr   r   r   blobT   s   
zGSPath.blobc                 C   s   | j | dS )Netagr   r)   r.   r   r   r   r   r;   _   r6   zGSPath.etagc                 C   s    | j | }|s
d S |dd S )Nmd5_hashr<   )r   r0   r   r   r   md5c   s   z
GSPath.md5)FFN)TN)T)__name__
__module____qualname____doc__r   str__annotations__propertyr   r   r   r   boolr"   r2   r   r:   r;   r>   r   r   r   r   r      s"   
 


r   )r,   pathlibr   tempfiler   typingr   r   r   	cloudpathr   r	   r
   gsclientr   r   r   r   r   r   <module>   s    