
    iw                         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
 	 d dlmZ ddlmZmZmZ erd	d
lmZ  ed       G d de             Zy# e$ r Y 0w xY w)    N)Path)TemporaryDirectory)AnyOptionalTYPE_CHECKING)CloudPathIsADirectoryError)ResourceNotFoundError   )	CloudPathNoStatErrorregister_path_class   )AzureBlobClientazurec                        e Zd ZU dZdZeed<   ded<   edefd       Zdde	e
   fd	Zdd
ede	e
   fdZddZd fdZedefd       Zedefd       Zed        Zedefd       Z xZS )AzureBlobPathaj  Class for representing and operating on Azure Blob 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 Blob Storage 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 [`AzureBlobClient`](../azblobclient/) class handles authentication with Azure. If a
    client instance is not explicitly specified on `AzureBlobPath` instantiation, a default client
    is used. See `AzureBlobClient`'s documentation for more details.
    zaz://cloud_prefixr   clientreturnc                     | j                   S N)	containerselfs    n/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/cloudpathlib/azure/azblobpath.pydrivezAzureBlobPath.drive&   s    ~~    modec                 @    | j                   j                  | ||       y )N)parentsexist_ok)r   _mkdir)r   r    r!   r   s       r   mkdirzAzureBlobPath.mkdir*   s    48Dr   r!   c                 :   | j                         r-|st        d|        | j                  j                  | |        y t	               }t        |j                        dz  }|j                          | j                  j                  ||        |j                          y )NzFile exists: empty)
existsFileExistsErrorr   
_move_filer   r   nametouch_upload_filecleanup)r   r!   r   tfps        r   r*   zAzureBlobPath.touch-   st    ;;=%dV&<==KK""4.#%BRWW'AGGIKK$$Q-JJLr   c                     	 | j                   j                  |       }t	        j
                  d d | j                  d d d |j                  dd      d |j                  dd      j                         d f
      S # t        $ r t        d|  d      w xY w)NzNo stats available for z%; it may be a directory or not exist.sizer   last_modified)	r   _get_metadatar	   r   osstat_resultr   get	timestamp)r   follow_symlinksmetas      r   statzAzureBlobPath.stat;   s    	;;,,T2D ~~!!#!,668
 	
 % 	)$/TU 	s   A4 4Bc                     	 t         |   |      S # t        $ r; | j                  j	                  |       r| j                  j                  | |      cY S  w xY wr   )superreplacer   r   
_check_hnsr(   )r   target	__class__s     r   r<   zAzureBlobPath.replaceR   sT    	7?6** * 	{{%%d+{{--dF;;		s    A AAc                 @    | j                   j                  dd      d   S )N/r   r   )
_no_prefixsplitr   s    r   r   zAzureBlobPath.container]   s    $$S!,Q//r   c                 J    | j                   }|j                  d      r|dd  }|S )NrA   r   )_no_prefix_no_drive
startswith)r   keys     r   blobzAzureBlobPath.bloba   s+    && >>#ab'C
r   c                 X    | j                   j                  |       j                  dd       S )Netagr   r2   r5   r   s    r   rJ   zAzureBlobPath.etagk   s$    {{((.2264@@r   c                 x    | j                   j                  |       j                  di       j                  dd       S )Ncontent_settingscontent_md5rK   r   s    r   md5zAzureBlobPath.md5o   s3    {{((.223ErJNN}^bccr   )FFN)TN)T)r>   r   r   r   )__name__
__module____qualname____doc__r   str__annotations__propertyr   r   r   r#   boolr*   r9   r<   r   rH   rJ   rO   __classcell__)r?   s   @r   r   r      s      L#s  E# Ed # 
.	 03 0 0 c   A A dS d dr   r   )r3   pathlibr   tempfiler   typingr   r   r   cloudpathlib.exceptionsr   azure.core.exceptionsr	   ImportError	cloudpathr   r   r   azblobclientr   r    r   r   <module>rb      sj    	  ' / / >	; D C - W\dI \d \d  		s   A AA