
    i+                        U d dl Z d dlmZ d dlZd dlmZ d dlmZmZm	Z	m
Z
mZ d dlZd dlmZmZmZmZ d dlZd dlZd dlmZ d dlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z* d d	l+m,Z, e%rd d
l-m.Z.m/Z/m0Z0m1Z1m2Z2 ejf                  dk\  rd dlm4Z4 nd dl5m4Z4 ejf                  dk\  rd dlm6Z6 nd dl5m6Z6 ejf                  dk  rd dlm7Z7 d dlm8Z9 d dlm:Z: d2dZ8ngejf                  dd dk(  rd dlm:Z: d dlm;Z7 d dlm8Z8 nBejf                  dd dk(  rd dl<m:Z: d dl;Z7ddl=m8Z8 nejf                  dk\  rd dlm:Z: d dl;Z7ddl=m8Z8 d dl>m?Z? ddl@mAZA ddlBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQ e%rddlRmSZS ddlTmUZU  G d d      ZV eeV      ZWeeXeVf   eYd <    e&d!      ZZ e&d"d#$      Z[d%eXd&ee$e[   ge$e[   f   fd'Z\ G d( d)e j                        Z^ G d* d#e^+      Z_d,ed&eXfd-Z` G d. d/      Za G d0 d1      Zby)3    Ndefaultdict)contextmanager)BufferedRandomBufferedReaderBufferedWriterFileIOTextIOWrapper)Path	PosixPathPurePosixPathWindowsPath)
MethodType)BinaryIOLiteraloverloadAnyCallable	ContainerIterableIODict	GeneratorListOptionalTupleTypeTYPE_CHECKINGTypeVarUnioncast)urlparse)warn)OpenBinaryModeOpenBinaryModeReadingOpenBinaryModeUpdatingOpenBinaryModeWritingOpenTextMode)   
   )	TypeGuard)r)      )Selfr)      )_posix_flavour)_make_selector)_PathParentsc                 ,    t        t        |       |      S N)_make_selector_pathlibtuple)pattern_parts_flavourcase_sensitives      g/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/cloudpathlib/cloudpath.pyr1   r1   A   s    %eM&:HEE       )	posixpathr)         )r)      )FileCacheMode)anypath)ClientMismatchErrorCloudPathFileExistsErrorCloudPathFileNotFoundErrorCloudPathIsADirectoryErrorCloudPathNotADirectoryErrorCloudPathNotExistsErrorCloudPathNotImplementedErrorDirectoryNotEmptyErrorIncompleteImplementationErrorInvalidPrefixErrorMissingDependenciesErrorNoStatErrorOverwriteDirtyFileErrorOverwriteNewerCloudErrorOverwriteNewerLocalError)ClientCloudPathInfoc                       e Zd ZU eed<   dZeed<   ed   ed<   ed   ed<   dd
Ze	ded   fd       Z
e	ded   fd       Zy	)CloudImplementationnameTdependencies_loadedrS   _client_class	CloudPath_path_classreturnNc                     ddg}|D cg c]  }t        | d|       | }}|rt        d|       | j                  s0t        d| j                  j
                   d| j                   d      y c c}w )Nclient_class
path_class_z1Implementation is missing registered components: zMissing dependencies for z6. You can install them with 'pip install cloudpathlib[z]'.)getattrrL   rY   rN   rZ   __name__rX   )selfexpectedclsmissings       r:   validate_completenessz)CloudImplementation.validate_completenessu   s    "L1"*O3gdauI.F.N3OO/CG9M  ''*+D,>,>,G,G+H I226))CA  ( Ps
   A1A1c                 :    | j                          | j                  S r4   )rh   rZ   rd   s    r:   r_   z CloudImplementation.client_class   s    ""$!!!r;   c                 :    | j                          | j                  S r4   )rh   r\   rj   s    r:   r`   zCloudImplementation.path_class   s    ""$r;   r]   N)rc   
__module____qualname__str__annotations__rY   boolr   rh   propertyr_   r`    r;   r:   rW   rW   o   sk    
I $$>!k"" "d8n " "  D-    r;   rW   implementation_registryT
CloudPathTr[   )boundkeyr]   c                 H     dt         t           dt         t           f fd}|S )Nrf   r]   c                 v    t        | t              st        d      | t           _        t           | _        | S )Nz/Only subclasses of CloudPath can be registered.)
issubclassr[   	TypeErrorrt   r\   _cloud_meta)rf   rx   s    r:   	decoratorz&register_path_class.<locals>.decorator   s8    #y)MNN36$01#6
r;   )r   rv   )rx   r~   s   ` r:   register_path_classr      s(    tJ' D,<  r;   c                       e Zd Zedee   dedededef
d       Zedee   de	e
df   dededef
d       Zdee   de	e
ef   dedede	edef   f
d	Zd
e
deedf   dee
ef   ddfdZy)CloudPathMetarf   
cloud_pathargskwargsr]   c                      y r4   rs   rf   r   r   r   s       r:   __call__zCloudPathMeta.__call__   s     r;   r[   c                      y r4   rs   r   s       r:   r   zCloudPathMeta.__call__   s     r;   c                 N   t        | t              st        dt        j                   d      | t        u rt        j                         D ]T  }|j                  }||j                  |d      s&t        j                  |      } |j                  ||g|i | |c S  t        j                         D cg c]$  }|j                  |j                  j                  & }}t        d| d| d      t        j                  |       } | j                  ||g|i | |S c c}w )NzOnly subclasses of z) can be instantiated from its meta class.Fraise_on_errorPath z$ does not begin with a known prefix .)r{   r[   r|   rc   rt   valuesr\   is_valid_cloudpathobject__new____init__cloud_prefixrM   )	rf   r   r   r   implementationr`   new_objimplvalid_prefixess	            r:   r   zCloudPathMeta.__call__   sC    #y)%i&8&8%99bc 
 )"9"@"@"B #+77
)j.K.Ku /L / %nnZ8G'J''MdMfM"N# 4::<##/   --N 
 %
|#GGWWXY  ..%Wj:4:6:s   7)D"rX   bases.dicNc                    t        |       D ]  }|j                  d      rt        t        |      s&t	        t	        t        |      dd       sBt	        t        |      j
                  dz   }t        t	        | |      t              r|t	        | |      j                  _        n|t	        | |      _        t        t	        | |      t              s|t	        | |      j                  _         y )Nra   __doc__z' _(Docstring copied from pathlib.Path)_)dir
startswithhasattrr   rb   r   
isinstancer   __func__rr   fget)rf   rX   r   r   attr	docstrings         r:   r   zCloudPathMeta.__init__   s    H 	@DOOC(D$'GD$/DA#D$/77:cc	gc40:?:CGC&//71:GC&.gc40(; 7@GC&++3!	@r;   )rc   rm   rn   r   r   ru   rv   r   r   r    ro   r   typer   r   rs   r;   r:   r   r      s	   !W",58DG	  !W"'[(8"9BEQT	
 !W"'Z"8ADPS	q+z)	*B@C @dCi(8 @tCH~ @RV @r;   r   c                      e Zd ZU dZeed<   eed<   dddeeed f   dede	d	   d
dfdZ
ed        ZddZd
eeef   fdZdeeef   d
dfdZed
efd       Zed
efd       Zee	 ddd ded
ee   fd              Zeeddeded
efd              Ze	 ddeed f   ded
eeee   f   fd       Zd
efdZd
efdZd
efdZded
efdZd
efdZded
efdZded
efd Z ded
efd!Z!ded
efd"Z"ee#jH                  d
efd#              Z%e#jH                  	 dd$ed%ed&e	e   d
dfd'       Z&e#jH                  dd%ed&e	e   d
dfd(       Z'dd)ed*ed
efd+Z(ded
dfd,Z)ed
efd-       Z*d
efd.Z+dd
efd/Z,dd
efd0Z-dd
efd1Z.ed
efd2       Z/ed3ed
efd4       Z0d5eee1jd                  f   d
efd6Z3d7 Z4d8ed
e5eddf   fd9Z6	 	 dd5eee1jd                  f   d:e	e   d;ed
e5eddf   fd<Z7	 	 dd5eee1jd                  f   d:e	e   d;ed
e5eddf   fd=Z8d
e5eddf   fd>Z9e:dd?       Z;	 	 	 dd@edAe	e<   dBed
e5e=ee>e   e>e   f   ddf   fdCZ?e	 	 	 	 	 	 	 dd&dDdEedFe	e   dGe	e   dHe	e   dIe	e   dJe	e   d
dKfdL       Z@e	 	 	 	 	 dd&dMdEeAdN   dFddGddHddIe	e   dJe	e   d
dOfdP       Z@e	 	 	 	 	 	 dd&dQdEeAdR   dFddGddHddIe	e   dJe	e   d
dSfdT       Z@e	 	 	 	 	 	 dd&dUdEeAdR   dFddGddHddIe	e   dJe	e   d
dVfdW       Z@e	 	 	 	 	 	 dd&dXdEeAdR   dFddGddHddIe	e   dJe	e   d
dYfdZ       Z@e	 	 	 	 	 	 dd&dMdEedFddGddHddIe	e   dJe	e   d
d[fd\       Z@e	 	 	 	 	 	 dd&edEedFe	e   dGe	e   dHe	e   dIe	e   dJe	e   d
d]fd^       Z@	 	 	 	 	 	 	 dd&edEedFe	e   dGe	e   dHe	e   dIe	e   dJe	e   d
d]fd_Z@d`ed
efdaZBd`ed
efdbZCddcZDddeee1jd                  f   d
efdeZEddfed
dfdgZFdheGd
efdiZH	 	 	 ddhedFe	e   dGe	e   dHe	e   d
ef
djZId
eGfdkZJ	 	 	 ddFe	e   dGe	e   dHe	e   d
efdlZKdm ZLdned
efdoZMdeeeNf   d
efdpZOdqeee1jd                  f   d
efdrZPd
efdsZQd
efdtZRddued
efdvZSddedwed
eNfdxZTded
efdyZUed
efdz       ZVdd5ed:e	e   d
efd{ZWdd|ed:e	e   d
efd}ZXed
efd~       ZYed
efd       ZZed
e=edf   fd       Z[ed
e=edf   fd       Z\ed
efd       Z]ed
efd       Z^ed
e>e   fd       Z_ded
efdZ`ded
efdZad
efdZbded
efdZcdned
efdZdddBed
e1j                  fdZfddZgdeee1jd                  f   d
ehfdZiddZj	 ddeee1jd                  f   dJe	e   d
efdZk	 	 	 	 dd`eee1jd                  d f   dBededJe	e   ded
eehef   fdZle	 	 	 dd`edJe	e   d
efd       Zme	 	 	 dd`ehdJe	e   d
ehfd       Zme	 	 	 dd`edJe	e   d
eehd f   fd       Zm	 	 	 dd`eee1jd                  ef   dBededJe	e   d
eehef   f
dZme	 	 	 ddedBededJe	e   d
ef
d       Zne	 	 	 ddehdBededJe	e   d
ehf
d       Zne	 	 	 ddedBededJe	e   d
eehd f   f
d       Zn	 	 	 ddeee1jd                  ef   dBededJe	e   d
eehef   f
dZne	 	 ddedJe	e   de	e<eeoe   gepe   f      d
efd       Zqe	 	 ddehdJe	e   de	e<eeoe   gepe   f      d
ehfd       Zqe	 	 ddeee1jd                  ef   dJe	e   de	e<eeoe   gepe   f      d
eehd f   fd       ZqddZqe	 	 	 dd`edBededJe	e   d
ef
d       Zre	 	 	 dd`ehdBededJe	e   d
ehf
d       Zre	 	 	 dd`edBededJe	e   d
eehd f   f
d       Zr	 	 	 dd`eee1jd                  ef   dBededJe	e   d
eehef   f
dZre	 	 	 ddedBededJe	e   d
ef
d       Zse	 	 	 ddehdBededJe	e   d
ehf
d       Zse	 	 	 ddedBededJe	e   d
eehd f   f
d       Zs	 	 	 ddeee1jd                  ef   dBededJe	e   d
eehef   f
dZsd Zted
ehfd       Zudeee1jd                  f   ded
efdZvddIe	e   d
dfdZw	 ddJe	e   d
efdZx	 ddehdJe	e   d
efdZyedefd       Zzeded
efd       Z{ed
e5e<egef   ddf   fd       Z|eded
efd       Z}y)r[   a  Base class for cloud storage file 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 cloud storage with filesystem path semantics, and convenient methods allow for basic
    operations like joining, reading, writing, iterating over contents, etc. `CloudPath` 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.

    Analogous to the way `pathlib.Path` works, instantiating `CloudPath` will instead create an
    instance of an appropriate subclass that implements a particular cloud storage service, such as
    [`S3Path`](../s3path). This dispatching behavior is based on the URI scheme part of a cloud
    storage URI (e.g., `"s3://"`).
    r}   r   N)clientr   partsr   rS   r]   c          	         d | _         d | _        |rLt        |      j                  d      st        |      dz   }t        |      dj	                  d |D              z   }| j                  |d       | j                  j                          t        |      | _        t        | j                        | _
        t        d| j                         | _        |"t        |t              r|j                   | _        n|| _        |]t        || j                  j"                        s=t%        d|j&                   d| j&                   d| j                  j"                   d      d	| _        y )
N/c              3   >   K   | ]  }|j                  d         yw)r   N)strip.0ps     r:   	<genexpr>z%CloudPath.__init__.<locals>.<genexpr>  s     3PQAGGCL3Ps   Tr   zClient of type [z'] is not valid for cloud path of type [z]; must be instance of [z;], or None to use default client for this cloud path class.F)_handle_clientro   endswithjoinr   r}   rh   _strr"   _urlr   
_no_prefix_pathr   r[   r   r_   rD   	__class___dirty)rd   r   r   r   s       r:   r   zCloudPath.__init__   s@    &*+/z?++C0 _s2
Z3883P%3P+PPJ
4@..0 
O	TYY'	"Qt&7#89
 >*i0)00!DLj9I9I9V9V&W%"6#3#3"4 5NN##;D<L<L<Y<Y;Z [HI  r;   c                     t        | dd       )| j                  j                  j                         | _        | j                  S Nr   )rb   r}   r_   get_default_clientr   rj   s    r:   r   zCloudPath.client  s7    4D)1++88KKMDL||r;   c                     | j                   4| j                  j                         r| j                   j                          t	        | dd       }t	        |dd       t
        j                  k(  r| j                          y y )Nr   file_cache_mode)r   _localexistscloserb   rB   cloudpath_objectclear_cache)rd   r   s     r:   __del__zCloudPath.__del__%  se    <<#(:(:(<LL  y$/6,d3}7U7UU Vr;   c                 H    | j                   j                         }d|v r|d= |S r   )__dict__copyrd   states     r:   __getstate__zCloudPath.__getstate__/  s+    ""$ i r;   r   c                 :    | j                   j                  |       y r4   )r   updater   s     r:   __setstate__zCloudPath.__setstate__8  s    U#r;   c                 F    | j                   t        | j                        d  S r4   )r   lenanchorrj   s    r:   r   zCloudPath._no_prefix;  s    yyT[[)+,,r;   c                 r    | j                   t        | j                        t        | j                        z   d  S r4   )r   r   r   driverj   s    r:   _no_prefix_no_drivezCloudPath._no_prefix_no_drive?  s*    yyT[[)C

O;=>>r;   .pathr   c                      y r4   rs   rf   r   r   s      r:   r   zCloudPath.is_valid_cloudpathC  s     r;   c                      y r4   rs   r   s      r:   r   zCloudPath.is_valid_cloudpathI  s    PSr;   c                     t        |      j                         j                  | j                  j                               }|r|st	        d| d| j                   d      |S )N'z4' is not a valid path since it does not start with ')ro   lowerr   r   rM   )rf   r   r   valids       r:   r   zCloudPath.is_valid_cloudpathM  sb     D	!,,S-=-=-C-C-EF%$D6McN^N^M__`a  r;   c                 :    | j                   j                   d|  dS )Nz('z'))r   rc   rj   s    r:   __repr__zCloudPath.__repr__Z  s     ..))*"TF"55r;   c                     | j                   S r4   )r   rj   s    r:   __str__zCloudPath.__str__]  s    yyr;   c                 T    t        t        |       j                  t        |       f      S r4   )hashr   rc   ro   rj   s    r:   __hash__zCloudPath.__hash__`  s     T$Z((#d)455r;   otherc                 ^    t        |t        |             xr t        |       t        |      k(  S r4   )r   r   ro   rd   r   s     r:   __eq__zCloudPath.__eq__c  s%    %d,HTc%j1HHr;   c                 l    | j                         r| j                          t        | j                        S r4   )is_file_refresh_cachero   r   rj   s    r:   
__fspath__zCloudPath.__fspath__f  s&    <<>!4;;r;   c                 j    t        |t        |             st        S | j                  |j                  k  S r4   r   r   NotImplementedr   r   s     r:   __lt__zCloudPath.__lt__k  )    %d,!!zzEKK''r;   c                 j    t        |t        |             st        S | j                  |j                  k  S r4   r   r   s     r:   __le__zCloudPath.__le__p  )    %d,!!zzU[[((r;   c                 j    t        |t        |             st        S | j                  |j                  kD  S r4   r   r   s     r:   __gt__zCloudPath.__gt__u  r   r;   c                 j    t        |t        |             st        S | j                  |j                  k\  S r4   r   r   s     r:   __ge__zCloudPath.__ge__z  r   r;   c                      y)zVFor example "bucket" on S3 or "container" on Azure; needs to be defined for each classNrs   rj   s    r:   r   zCloudPath.drive  s     	r;   parentsexist_okmodec                      y)zPShould be implemented using the client API without requiring a dir is downloadedNrs   )rd   r   r   r   s       r:   mkdirzCloudPath.mkdir  s    
 	r;   c                      y)zMShould be implemented using the client API to create and update modified timeNrs   )rd   r   r   s      r:   touchzCloudPath.touch  s     	r;   presignexpire_secondsc                 ~    |r| j                   j                  | |      }|S | j                   j                  |       }|S )N)r   )r   _generate_presigned_url_get_public_url)rd   r   r   urls       r:   as_urlzCloudPath.as_url  s@    ++55d>5ZC 
 ++--d3C
r;   c                     t        d      )NzZCannot change a cloud path's root since all paths are absolute; create a new path instead.)
ValueErrorr   s     r:   __rtruediv__zCloudPath.__rtruediv__  s    h
 	
r;   c                     | j                   S r4   )r   rj   s    r:   r   zCloudPath.anchor  s       r;   c                     t        |       S r4   )ro   rj   s    r:   as_urizCloudPath.as_uri  s    4yr;   c                 8    | j                   j                  |       S r4   )r   _existsrd   follow_symlinkss     r:   r   zCloudPath.exists  s    {{""4((r;   c                 >    | j                   j                  |       dk(  S )Nr   r   _is_file_or_dirr  s     r:   is_dirzCloudPath.is_dir  s    {{**40E99r;   c                 >    | j                   j                  |       dk(  S )Nfiler  r  s     r:   r   zCloudPath.is_file  s    {{**40F::r;   c                 "    | j                         S r4   )r   rj   s    r:   fspathzCloudPath.fspath  s      r;   uric                      | |      S r4   rs   )rf   r  s     r:   from_urizCloudPath.from_uri  s    3xr;   patternc                    t        |t        j                        rAt        |t              rt	        |j                  |             }n!t        j                  |      }nt	        |      }d|v rt        d      |j                  | j                        s|j                  d      rt        d      | j                  dk(  rt        d      |S )N..z8Relative paths with '..' not supported in glob patterns.r   z%Non-relative patterns are unsupported z.glob is only supported within a bucket or container; you can use `.iterdir` to list buckets; for example, CloudPath('s3://').iterdir())r   osPathLiker[   ro   relative_tor  rJ   r   r   r   )rd   r  str_patterns      r:   _glob_checkszCloudPath._glob_checks  s    gr{{+'9-!'"5"5d";< ii0g,K;.J  !!$"3"348N8Ns8S./VWW::. Z  r;   c                 F   fdfd        }| j                   j                  | |      D ]c  \  }}t        |j                  |             j	                  d      }t        |      dk(  r	|d   dk(  rFd |D        } |t        |d       ||       e t        |      S )	Nc                      t               S r4   r   )Trees   r:   <lambda>z*CloudPath._build_subtree.<locals>.<lambda>  s    T!2 r;   c                 d    t        |d      }||r        | |<   yd| |<   y | |   |||       y)ziUtility to build a tree from nested defaultdicts with a generator
            of nodes (parts) of a path.N)next)trunkbranchnodesr  next_branchr&  _build_trees        r:   r.  z-CloudPath._build_subtree.<locals>._build_tree  s@     ud+K"*0fdf E&M;vFr;   	recursiver   r@   r   r   c              3       K   | ]  }|  y wr4   rs   r   s     r:   r   z+CloudPath._build_subtree.<locals>.<genexpr>  s     &1Q&s   )r   	_list_dirro   r!  splitr   r)  dict)	rd   r0  	file_treefr  r   r,  r&  r.  s	          @@r:   _build_subtreezCloudPath._build_subtree  s    2		G F	..ty.I 	EIAvd+,2237E 5zQ58s?&&E	4t#4eVD	E Ir;   r0  c              #      K   | j                  |      }t        | j                  g |      }|j                  |      D ]+  }| t	        |      t        | j                        dz   d  z   - y w)Nr@   )r7  _CloudPathSelectablerX   select_fromro   r   )rd   selectorr0  r5  rootr   s         r:   _globzCloudPath._glob  sm     ''	2	#II
 %%d+ 	8A#a&TYY!!3!5667	8s   A)A+r9   recurse_symlinksc              #      K   | j                  |      }t        |      j                  }t        t	        |      t
        |      }| j                  |d|v xs d|v       E d {    y 7 w)Nr9   r   **r#  r   r   r1   r6   r0   r=  rd   r  r9   r>  r7   r;  s         r:   globzCloudPath.glob  sp      ##G,%g.44!- .
 ::7N 
 	
 	
s   AA)!A'"A)c              #      K   | j                  |      }t        |      j                  }t        dt	        |      z   t
        |      }| j                  |d      E d {    y 7 w)N)rA  r@  TrB  rC  s         r:   rglobzCloudPath.rglob'  sY      ##G,%g.44!eM**N>
 ::h---s   AA$A"A$c              #   j   K   | j                   j                  | d      D ]  \  }}|| k7  s|  y w)NFr/  )r   r2  )rd   r6  ra   s      r:   iterdirzCloudPath.iterdir6  s9     KK))$%)@ 	DAqDy	s   )33c              #     K   g }g }|j                         D ])  \  }}||j                  |      n|j                  |       + |r| ||f |D ](  }t        j                  | |z  ||   |      E d{    * |s| ||f yy7 w)z}Utility to yield tuples in the form expected by `.walk` from the file
        tree constructed by `_build_substree`.
        Ntop_down)itemsappendr[   _walk_results_from_tree)r<  treerK  dirsfilesitemr+  r   s           r:   rN  z!CloudPath._walk_results_from_tree;  s     
  JJL 	HLD&"(.ELLdkk$6G	H e## 	cC 88T#YYa8bbb	c e##  cs   A0B2B3BrK  on_errorr  c              #      K   	 | j                  d      }| j                  | ||      E d {    y 7 # t        $ r}|	 ||       n Y d }~y d }~ww xY ww)NTr/  rJ  )r7  rN  	Exception)rd   rK  rS  r  r5  es         r:   walkzCloudPath.walkN  s]     	++d+;I33D)h3WWW 	# 	s6   A)5 35 A5 	AA
AAAr(   	bufferingencodingerrorsnewlineforce_overwrite_from_cloudforce_overwrite_to_cloudr
   c                      y r4   rs   rd   r   rX  rY  rZ  r[  r\  r]  s           r:   openzCloudPath.open^  s     r;   r$   r   r	   c                      y r4   rs   r_  s           r:   r`  zCloudPath.openj  s     r;   r&   )r@   r   c                      y r4   rs   r_  s           r:   r`  zCloudPath.openv       r;   r'   r   c                      y r4   rs   r_  s           r:   r`  zCloudPath.open  rd  r;   r%   r   c                      y r4   rs   r_  s           r:   r`  zCloudPath.open  rd  r;   r   c                      y r4   rs   r_  s           r:   r`  zCloudPath.open  s     r;   zIO[Any]c                      y r4   rs   r_  s           r:   r`  zCloudPath.open  s     r;   c                 4     j                         }|r j                         st        d  d      |s"t        fddD              rt	        d        dk(  r j                         rt        d  d       j                  |	        j                  j                         s* j                  j                  j                  d
d
       dn$ j                  j                         j                   j                  j                  ||||      }	t        fddD              r*|	j                  d fd}
|
|	_        |	 _        d
 _         j                   j"                  t$        j&                  k(  r|	j                   fd}||	_        |	S )Nz2Cannot open directory, only files. Tried to open ()c              3   &   K   | ]  }|v  
 y wr4   rs   r   mr   s     r:   r   z!CloudPath.open.<locals>.<genexpr>  s     &EQqDy&E   )raz@File opened for read or append, but it does not exist on cloud: xzCannot open existing file (z) for creation.)r\  Tr   r   g        )r   rX  rY  rZ  r[  c              3   &   K   | ]  }|v  
 y wr4   rs   rl  s     r:   r   z!CloudPath.open.<locals>.<genexpr>  s     7QqDy7rn  )w+rq  rp  c                       | i | j                   sy j                  j                         j                  k  r(dz   }t	        j
                  j                  ||f       j                         d_         y )Nr@   timesr]  F)r   r   statst_mtimer  utime_upload_local_to_cloud)r   r   	new_mtimer]  original_mtimerd   wrapped_closes      r:   _patched_close_uploadz-CloudPath.open.<locals>._patched_close_upload  ss    t.v. {{
 ;;##%..? . 2IHHT[[I0FG++E]+^#r;   c                  6     | i | j                          y r4   )r   )r   r   rd   wrapped_close_for_caches     r:   _patched_close_empty_cachez2CloudPath.open.<locals>._patched_close_empty_cache  s    '88   "r;   rl   )r   r   rG   anyrF   rE   r   r   parentr   rz  r{  r`  r   r   r   r   r   rB   
close_file)rd   r   rX  rY  rZ  r[  r\  r]  exists_on_cloudbufferr  r  r  r  r  s   ``     `    @@@r:   r`  zCloudPath.open  s    ++-4<<>,DTF!L  3&E*&E#E,RSWRXY  3;4;;=*-Ho+^__ 	7QR {{!!#KK$$TD$A N![[--/88N!! " 
 7"677"LLM$ $$ 1FL "DL DK ;;&&-*B*BB '-ll## 6FLr;   targetc                 $   t        |       t        |      urt        dt        |              | j                         rt        d|  d      || k(  r| S |j	                         r|j                          | j                  j                  | |       |S )NzBThe target based to rename must be an instantiated class of type: r   z6 is a directory; rename/replace the files recursively.)r   r|   r  rG   r   unlinkr   
_move_filerd   r  s     r:   replacezCloudPath.replace  s    :T&\)TUYZ^U_T`a  ;;=,vST  T>K==?MMOtV,r;   c                 $    | j                  |      S r4   )r  r  s     r:   renamezCloudPath.rename%  s     ||F##r;   c                     | j                         rt        d|  d      	 t        | j                                t	        d|  d      # t
        $ r Y nw xY w| j                  j                  |        y )Nr   z) is a file; call unlink instead of rmdir.zDirectory not empty: 'z$'. Use rmtree to delete recursively.)r   rH   r)  rH  rK   StopIterationr   _removerj   s    r:   rmdirzCloudPath.rmdir*  sx    <<>-vFG 	 ((.RS   		D!s   (A	 		AA
other_pathc                     | |k(  S r4   rs   )rd   r  s     r:   samefilezCloudPath.samefile8  s    z!!r;   
missing_okc                 z    | j                         rt        d|  d      | j                  j                  | |       y )Nr   z. is a directory; call rmdir instead of unlink.)r  rG   r   r  )rd   r  s     r:   r  zCloudPath.unlink<  s;    ;;=,vKL  	D*-r;   datac                     t        |      }| j                  d      5 }|j                  |      cddd       S # 1 sw Y   yxY w)zOpen the file in bytes mode, write to it, and close the file.

        NOTE: vendored from pathlib since we override open
        https://github.com/python/cpython/blob/3.8/Lib/pathlib.py#L1235-L1242
        wbr   N)
memoryviewr`  write)rd   r  viewr6  s       r:   write_byteszCloudPath.write_bytesD  s>     $YYDY! 	!Q774=	! 	! 	!s	   9Ac                     t        |t              s"t        d|j                  j                  z        | j                  d|||      5 }|j                  |      cddd       S # 1 sw Y   yxY w)zOpen the file in text mode, write to it, and close the file.

        NOTE: vendored from pathlib since we override open
        https://github.com/python/cpython/blob/3.10/Lib/pathlib.py#L1146-L1155
        zdata must be str, not %srt  r   rY  rZ  r[  N)r   ro   r|   r   rc   r`  r  )rd   r  rY  rZ  r[  r6  s         r:   
write_textzCloudPath.write_textO  s`     $$69P9PPQQYYC(67YS 	!WX774=	! 	! 	!s   A##A,c                 r    | j                  d      5 }|j                         cd d d        S # 1 sw Y   y xY w)Nrbr  r`  read)rd   r6  s     r:   
read_byteszCloudPath.read_bytesa  s0    YYDY! 	Q668	 	 	s   -6c                 x    | j                  d|||      5 }|j                         cd d d        S # 1 sw Y   y xY w)Nro  r  r  )rd   rY  rZ  r[  r6  s        r:   	read_textzCloudPath.read_texte  s9     YYC(67YS 	WX668	 	 	s   09c                      yNFrs   rj   s    r:   is_junctionzCloudPath.is_junctionn      r;   funcc                      j                   j                  |      }t        |      r ||i |}t        |t              rt        |      } j                  |      S t        |t        j                  j                        rSt        |      dkD  rEt        |d   t              r2t        |t              st        |      nt        } | fd|D              S |S )zSome functions we can just dispatch to the pathlib version
        We want to do this explicitly so we don't have to support all
        of pathlib and subclasses can override individually if necessary.
        r   c              3      K   | ]7  }t        |      |j                  k7  sj                  t        |             9 y wr4   )_resolver<  _new_cloudpath)r   r   rd   s     r:   r   z.CloudPath._dispatch_to_path.<locals>.<genexpr>  s8      "56(ST+YZY_Y_J_##HQK0"s
   A A )r   __getattribute__callabler   r   r  r  collectionsabcSequencer   r2   r   r6   )rd   r  r   r   path_versionsequence_classs   `     r:   _dispatch_to_pathzCloudPath._dispatch_to_pathu  s    
 zz2248 L!'88L lM2#L1L&&|44 |[__%=%=>L!A%<?M: +5\<*P\"V[  " ":F"    r;   c                 ^    t        |t        t        f      st        S | j	                  d|      S )N__truediv__)r   ro   r   r   r  r   s     r:   r  zCloudPath.__truediv__  s*    %#}!56!!%%mU;;r;   pathsegmentsc                 (     | j                   dg| S )Njoinpathr  rd   r  s     r:   r  zCloudPath.joinpath  s    %t%%j@<@@r;   c                     | S r4   rs   rj   s    r:   absolutezCloudPath.absolute      r;   c                      yNTrs   rj   s    r:   is_absolutezCloudPath.is_absolute  s    r;   strictc                     | S r4   rs   )rd   r  s     r:   resolvezCloudPath.resolve  r  r;   walk_upc           
      z   t        |t              st        |  d| d      | j                  |j                  k7  r+t        |  d| j                   d| d|j                   d      t	        |      }t
        j                  dk  r|j                  d        | j                  j                  |j                  fi |S )	Nz is a cloud path, but z is notz is a z path, but z path)r  r.   r  )
r   r[   r  r   r4  sysversion_infopopr   r!  )rd   r   r  r   s       r:   r!  zCloudPath.relative_to  s     %+v%;E7'JKK;;%,,&&t{{m;ugVELL>QVW  g&g%JJy!%tzz%%ekk<V<<r;   c                 F    	 | j                  |       y# t        $ r Y yw xY wNTF)r!  r  r   s     r:   is_relative_tozCloudPath.is_relative_to  s*    	U# 		s    	  c                 $    | j                  d      S )NrX   r  rj   s    r:   rX   zCloudPath.name      %%f--r;   c                    t         j                  dk  rt        d      |j                  | j                  | j
                  z         r&|t        | j                  | j
                  z         d  }n6|j                  | j                        r|t        | j                        dz
  d  }t        | j                        j                  ||      S )Nr>   z)full_match requires Python 3.13 or higherr@   r@  )
r  r  NotImplementedErrorr   r   r   r   r   r   
full_match)rd   r  r9   s      r:   r  zCloudPath.full_match  s    g%%&QRR dkkDJJ67c$++

":;=>G,c$++.245G T556AAN B 
 	
r;   path_patternc                 0   |j                  | j                  | j                  z   dz         r(|t        | j                  | j                  z   dz         d  }t	        |      }t
        j                  dk  r|j                  d        | j                  d|fi |S )Nr   r@  r.   r9   match)	r   r   r   r   r4  r  r  r  r  )rd   r  r9   r   s       r:   r  zCloudPath.match  s    ""4;;#;c#AB'DKK$**,Ds,J(K(MNL^4g%JJ'(%t%%g|FvFFr;   c                 `    t         j                  dk  rt        d      | j                  d      S )Nr>   z%parser requires Python 3.13 or higherparser)r  r  r  r  rj   s    r:   r  zCloudPath.parser  s-    g%%&MNN%%h//r;   c                 $    | j                  d      S )Nr  r  rj   s    r:   r  zCloudPath.parent      %%h//r;   c                 $    | j                  d      S )Nr   r  rj   s    r:   r   zCloudPath.parents  s    %%i00r;   c                 ^    | j                  d      }|d   dk(  r|dd  }| j                  g|S )Nr   r   r   r@   )r  r   )rd   r   s     r:   r   zCloudPath.parts  s:    &&w/8s?!"IE$e$$r;   c                 $    | j                  d      S )Nstemr  rj   s    r:   r  zCloudPath.stem  r  r;   c                 $    | j                  d      S )Nsuffixr  rj   s    r:   r  zCloudPath.suffix  r  r;   c                 $    | j                  d      S )Nsuffixesr  rj   s    r:   r  zCloudPath.suffixes  s    %%j11r;   r  c                     	 | j                  d|      S # t        $ r! | j                  || j                  z         cY S w xY w)N	with_stem)r  AttributeError	with_namer  )rd   r  s     r:   r  zCloudPath.with_stem  sA    	6))+t<< 	6>>$"455	6s    '>>rX   c                 &    | j                  d|      S )Nr  r  )rd   rX   s     r:   r  zCloudPath.with_name  s    %%k488r;   c                 B    | j                  dj                  |            S )zCreate a new CloudPath with the same client out of the given segments.
        The first segment will be interpreted as the bucket/container name.
        r   )r  r   r  s     r:   with_segmentszCloudPath.with_segments  s     ""388L#9::r;   r  c                 &    | j                  d|      S )Nwith_suffixr  )rd   r  s     r:   r  zCloudPath.with_suffix  s    %%mV<<r;   c                     | j                          | j                  j                  |      }t        |      r ||i |}t	        |t
        t        f      r!|j                         }| j                  |      S |S r4   )	r   r   r  r  r   r   r   r  r  )rd   r  r   r   r  s        r:   _dispatch_to_local_cache_pathz'CloudPath._dispatch_to_local_cache_path  ss    {{33D9 L!'88L lY$<='//1L&&|44  r;   c                 Z    t        d| j                   d       | j                  d|      S )zNote: for many clients, we may want to override so we don't incur
        network costs since many of these properties are available as
        API calls.
        z%stat not implemented as API call for z_ so file must be downloaded to calculate stats; this may take a long time depending on filesizerz  )r  )r#   r   r  r  s     r:   rz  zCloudPath.stat-  s=    
 	3DNN3C DO P	
 11&/1ZZr;   c                     t        |       S )z,Return a CloudPathInfo object for this path.rT   rj   s    r:   infozCloudPath.info8  s    T""r;   destinationc                    t        |      }| j                         st        d|        | j                         r;|j	                         r|| j
                  z  }| j                  j                  | |      S |j                  d       | j                         D ]N  }t        |       }|j                  d      s|dz   }t        |      t        |      d  }|j                  ||z         P |S )Nz-Cannot download because path does not exist: T)r   r   )r   r   rI   r   r  rX   r   _download_filer   rH  ro   r   r   download_to)rd   r  r6  relrel_dests        r:   r  zCloudPath.download_to=  s    ;'{{}),YZ^Y_*`aa<<>!!#)DII5;;--dK@@t,\\^ 6$i||C()Cq6#c(*-kH456 r;   c                 x    | j                         rt        d|  d      | j                  j                  |        y)z Delete an entire directory tree.r   z* is a file; call unlink instead of rmtree.N)r   rH   r   r  rj   s    r:   rmtreezCloudPath.rmtreeS  s9    <<>-vGH  	D!r;   sourcec                 4   t        |      }|j                         r7|j                         D ]"  }| |j                  z  j	                  ||       $ | S | j                         r | j                         r| |j                  z  }n| }|j                  ||       |S )z-Upload a file or directory to the cloud path.ry  )r   r  rH  rX   upload_fromr   _upload_file_to_cloud)rd   r   r]  r   dsts        r:   r  zCloudPath.upload_from[  s     f==?^^% b++AH`+ab K {{}V[[(%%fG_%`Jr;   preserve_metadata
remove_srcc                 b   | j                         st        d|  d      t        j                  |      }| j	                         r0| j                  ||      }t        t        t        t        f   |      S t        |t              s| j                  |      S | j                  |j                  u r|j                         r|j	                         r|| j                  z  }|0t        j                   j#                  dd      j%                         dv }|sW|j                         rG|j'                         j(                  | j'                         j(                  k\  rt+        d| d|  d	      t        t        | j                  j-                  | ||
            S |j                         r|j/                         r8t        t        t        t        f   |j1                  | j2                  |            S t        t        t        t        f   || j                  z  j1                  | j2                  |            S )Nr   z must exist to copy.ry  %CLOUDPATHLIB_FORCE_OVERWRITE_TO_CLOUDFalse1truezFile (z) is newer than (z5). To overwrite pass `force_overwrite_to_cloud=True`.)r  )r   r  rC   
to_anypathr  copytreer!   r    r   r-   r   r[   r  r   rX   r  environgetr   rz  r{  rQ   r  r   r  r  )rd   r  r  r  r]  r  r  results           r:   _copyzCloudPath._copys  s    {{}uTF*>?@@((0;;=]])A # F dDj)622+y1##K00 ;;+,,,!!#(:(:(<)DII5'/+-::>>;W,%'],+(
 -&&($$&//499;3G3GG.[M):4& A< =  dkk44T;S]4^__ %%';+>+>+@$*%++>V ,   $*% 499,99>V :  r;   c                      y r4   rs   rd   r  r  r  r]  s        r:   r   zCloudPath.copy       r;   c                      y r4   rs   r  s        r:   r   zCloudPath.copy  r  r;   c                      y r4   rs   r  s        r:   r   zCloudPath.copy       $'r;   c                 .    | j                  ||||d      S )z6Copy self to target folder or file, if self is a file.Fr  r  r]  r  r  r  s        r:   r   zCloudPath.copy  s)     zz+/%=  
 	
r;   
target_dirc                      y r4   rs   rd   r  r  r  r]  s        r:   	copy_intozCloudPath.copy_into  r  r;   c                      y r4   rs   r  s        r:   r  zCloudPath.copy_into  r  r;   c                      y r4   rs   r  s        r:   r  zCloudPath.copy_into  r  r;   c                     t        j                  |      | j                  z  }| j                  ||||d      }t	        t
        t        t        f   |      S )z9Copy self into target directory, preserving the filename.Fr  rC   r  rX   r  r!   r    r   r-   rd   r  r  r  r]  target_pathr  s          r:   r  zCloudPath.copy_into  sW     ((4tyy@+/%=  
 E$*%v..r;   ignorec                      y r4   rs   rd   r  r]  r&  s       r:   r  zCloudPath.copytree
       r;   c                      y r4   rs   r(  s       r:   r  zCloudPath.copytree  r)  r;   c                      y r4   rs   r(  s       r:   r  zCloudPath.copytree  s     $'r;   c                    | j                         st        d|  d      t        j                  |      }|j	                         r|j                         rt        d| d      t        | j                               }|, || j                  |D cg c]  }|j                   c}      }n
t               }|j                  dd       |D ]  }|j                  |v r|j                         r!|j                  ||j                  z  |       C|j                         sT|j                  ||j                  |j                  j                  d      rd	ndz   z  ||
        |S c c}w )z1Copy self to a directory, if self is a directory.zOrigin path z@ must be a directory. To copy a single file use the method copy.zDestination path z! of copytree must be a directory.Trr  ry  r   r  )r]  r&  )r  rH   rC   r  r   r   rE   listrH  r   rX   setr   r   r  r   )rd   r  r]  r&  contentsrq  ignored_namessubpaths           r:   r  zCloudPath.copytree"  s[   {{}-tf$de  ((5K$7$7$9*#K=0QR  '"4#;#;h=Waff=WXMEM$6 	G||}, ',,.Ia   !  7<<9N9Ns9S2Y\#]^-E! ! 	 ) >Xs   E#
c                      y r4   rs   r  s        r:   movezCloudPath.moveI  r  r;   c                      y r4   rs   r  s        r:   r3  zCloudPath.moveR  r  r;   c                      y r4   rs   r  s        r:   r3  zCloudPath.move[  r  r;   c                 .    | j                  ||||d      S )z2Move self to target location, removing the source.Tr  r  r  s        r:   r3  zCloudPath.moved  s)     zz+/%=  
 	
r;   c                      y r4   rs   r  s        r:   	move_intozCloudPath.move_intot  r  r;   c                      y r4   rs   r  s        r:   r8  zCloudPath.move_into}  r  r;   c                      y r4   rs   r  s        r:   r8  zCloudPath.move_into  r  r;   c                     t        j                  |      | j                  z  }| j                  ||||d      }t	        t
        t        t        f   |      S )zQMove self into target directory, preserving the filename and removing the source.Tr  r#  r$  s          r:   r8  zCloudPath.move_into  sW     ((4tyy@+/%=  
 E$*%v..r;   c                     | j                   j                         rU| j                   j                         r| j                   j                          yt	        j
                  | j                          yy)zRemoves cache if it existsN)r   r   r   r  shutilr  rj   s    r:   r   zCloudPath.clear_cache  sG    ;;{{""$""$dkk*	  r;   c                 H    | j                   j                  | j                  z  S )z!Cached local version of the file.)r   _local_cache_dirr   rj   s    r:   r   zCloudPath._local  s     {{++doo==r;   c                     t        |      }|j                  d      r|dd }|j                  | j                        s| j                   | } | j                  j                  |g| S )zUse the scheme, client, cache dir of this cloudpath to instantiate
        a new cloudpath of the same type with the path passed.

        Used to make results of iterdir and joins have a unified client + cache.
        r   r@   N)ro   r   r   r   r[   )rd   r   r   s      r:   r  zCloudPath._new_cloudpath  sf     4y ??38D t{{+kk]4&)D$t{{$$T2E22r;   c                    	 | j                         }|0t        j                  j	                  dd      j                         dv }|sK| j                  j                         r1| j                  j                         j                  |j                  k  ry| j                  j                  j                  dd       | j                  | j                         t        j                  | j                  |j                  |j                  f       | j                  rt        d| j                   d|  d	      | j                  j                         j                  |j                  kD  rt        d| j                   d|  d
      y # t        $ r Y y w xY w)N'CLOUDPATHLIB_FORCE_OVERWRITE_FROM_CLOUDr	  r
  Trr  rw  Local file () for cloud path (a  ) has been changed by your code, but is being requested for download from cloud. Either (1) push your changes to the cloud, (2) remove the local file, or (3) pass `force_overwrite_from_cloud=True` to overwrite; or set env var CLOUDPATHLIB_FORCE_OVERWRITE_FROM_CLOUD=1.z) is newer on disk, but is being requested for download from cloud. Either (1) push your changes to the cloud, (2) remove the local file, or (3) pass `force_overwrite_from_cloud=True` to overwrite; or set env var CLOUDPATHLIB_FORCE_OVERWRITE_FROM_CLOUD=1.)rz  rO   r  r  r  r   r   r   r{  r  r   r  r|  r   rP   rR   )rd   r\  statss      r:   r   zCloudPath._refresh_cache  sb   	IIKE &-)+97*eg*'& ';;%%'  "++enn< KK$$TD$AT[[) HHT[[(HI;;)t{{m+=dV DW X  ;;&&7*t{{m+=dV DW X  8C  	 	s   F   	FFc                 4   | j                   j                         rt        d      | j                  | j                   |      }| j	                         }t        j                  | j                   |j                  |j                  f       d| _        d| _	        |S )z.Uploads cache file at self._local to the cloudz2Only individual files can be uploaded to the cloudry  rw  FN)
r   r  r  r  rz  r  r|  r{  r   r   )rd   r]  uploadedrE  s       r:   r}  z CloudPath._upload_local_to_cloud  s     ;;QRR--KK2J . 

 		
U^^U^^$DE r;   
local_pathc                    |0t         j                  j                  dd      j                         dv }|r| j                  j                  ||        | S 	 | j                         }|r'|j                         j                  |j                  kD  r| j                  j                  ||        | S t        d| j                   d|  d      # t        $ r d}Y pw xY w)zfUploads file at `local_path` to the cloud if there is not a newer file
        already there.
        Nr  r	  r
  rC  rD  z) is newer in the cloud disk, but is being requested to be uploaded to the cloud. Either (1) redownload changes from the cloud or (2) pass `force_overwrite_to_cloud=True` to overwrite; or set env var CLOUDPATHLIB_FORCE_OVERWRITE_TO_CLOUD=1.)r  r  r  r   r   _upload_filerz  rO   r{  rQ   r   )rd   rH  r]  rE  s       r:   r  zCloudPath._upload_file_to_cloud  s     $+')zz~~7(eg('$ $KK$$ K	IIKE
 *33ennDKK$$
 K '4;;-'9$ @Q R
 	
  	E	s   C CC_source_typec                     	 ddl m} |j                  | j                  |j	                               S # t
        $ r Y yw xY w)zVPydantic special method. See
        https://docs.pydantic.dev/2.0/usage/types/custom/r   )core_schemaN)pydantic_corerM   no_info_after_validator_functionvalidate
any_schemaImportError)rf   rK  _handlerrM  s       r:   __get_pydantic_core_schema__z&CloudPath.__get_pydantic_core_schema__2  sD    	1??&&(   		s   /2 	>>vc                      | |      S )z[Used as a Pydantic validator. See
        https://docs.pydantic.dev/2.0/usage/types/custom/rs   )rf   rU  s     r:   rP  zCloudPath.validate@  s     1vr;   c              #   (   K   | j                    yw)zgPydantic special method. See
        https://pydantic-docs.helpmanual.io/usage/types/#custom-data-typesN)	_validate)rf   s    r:   __get_validators__zCloudPath.__get_validators__F  s      mms   valuec                      | |      S )zlUsed as a Pydantic validator. See
        https://pydantic-docs.helpmanual.io/usage/types/#custom-data-typesrs   )rf   rZ  s     r:   rX  zCloudPath._validateL  s     5zr;   rl   ).F)FFN)TN)Fi  Tr  )TNF)ro  rb  NNNNN)NNNNN)rb  NNNNN)NNNr4   )r]   rU   )TFNF)TFN)NN)~rc   rm   rn   r   rW   rp   ro   r    r-   r   r   rr   r   r   r   r   r   r   r   r   r   classmethodrq   r+   r   r   r   intr   r   r   r   r   r   r   r  abstractmethodr   r   r   r  r  r   r  r   r  r   r  r  r  r   r#  r7  r   r=  rD  rF  rH  staticmethodrN  r   r   r   rW  r`  r   r  r  r  r  r  bytesr  r  r  r  r  r  r   r  r  r  r  r  r!  r  rX   r  r  r  r  r   r   r  r  r  r  r  r  r  r  stat_resultrz  r  r   r  r  r  r  r   r  r   r   r  r3  r8  r   r   r  r   r}  r  rT  rP  rY  rX  rs   r;   r:   r[   r[      s    %$ &*	)#t[01) ) "	)
 
)V  d38n $$sCx. $T $ -C - - ?S ? ? 7:04	4   ScS4S$S  SCH
k)*
<@
	tYt_$	%
 
6# 6 6# 6IC ID I C  
(C (D (
)C )D )
(C (D (
)C )D )> s    	SW/3CKC=	  	d # $  d C c 
# 
$ 

 ! ! ! )d ):d :;t ; ! ! ! 3 4  E#r{{*:$;  0:8 8)D$<L2M 8  *.!%	
sBKK'(
 !
 	

 
4t#	$
. *.!%	.sBKK'(. !. 	.
 
4t#	$.4t#34 
 $ $( '+ %	 8$ 	
 
5tCy$s)34dD@	A    #"& $!%5937		 	 3-		
 	 #	 %-TN	 #+4.	 
	 	 
 5937		 1:	 		
 	 	 %-TN	 #+4.	 
	 	  %'5937	&	 5>	 		
 	 	 %-TN	 #+4.	 
	 	  %'5937	%	 5>	 		
 	 	 %-TN	 #+4.	 
	 	  %'5937	%	 5>	 		
 	 	 %-TN	 #+4.	 
	 	  5937		 	 		
 	 	 %-TN	 #+4.	 
	 	  "& $!%5937		 	 3-		
 	 #	 %-TN	 #+4.	 
	 	 "& $!%5937\\ \ 3-	\
 \ #\ %-TN\ #+4.\ 
\|d t *$T $d $
""5bkk)9#: "t ". . .	! 	!# 	! #' $!%!! 3-! 	!
 #! 
!$E  #' $!%	3-  #	
 
! c ! s ! F<sM'9!: <t <AeC,<&= A$ A$ T d t = = = ="D T  .c . .
# 
x~ 
QU 
 
G# 
Gx~ 
GQU 
G 0 0 0 0 0 0 1tSy) 1 1 %uS#X % % .c . . 0 0 0 2$s) 2 26c 6d 69c 9d 9;d ;=# =$ =
 #  3  &	[D 	[BNN 	[#
uS"++-='> 4 ," 48c2;;&' #+4. 
	6 !%"'37 <c2;;34< <  	<
 #+4.< < 
tTz	<|  37
 #+4. 
   37
 #+4. 
   37''
 #+4.' 
t[ 	!' ' !%"'37
c2;;,-
 
  	

 #+4.
 
tTz	
   !%"'37   	
 #+4. 
   !%"'37   	
 #+4. 
   !%"'37'' '  	'
 #+4.' 
t[ 	!' ' !%"'37/#r{{D01/ /  	/
 #+4./ 
tTz	/&  48KO	 #+4. 3"6	#"FGH	
 
   48KO	 #+4. 3"6	#"FGH	
 
   48KO	'3T12' #+4.' 3"6	#"FGH	'
 
t[ 	!' '%N  !%"'37   	
 #+4. 
   !%"'37   	
 #+4. 
   !%"'37'' '  	'
 #+4.' 
t[ 	!' ' !%"'37
c2;;,-
 
  	

 #+4.
 
tTz	
   !%"'37   	
 #+4. 
   !%"'37   	
 #+4. 
   !%"'37'' '  	'
 #+4.' 
t[ 	!' ' !%"'37/#r{{D01/ /  	/
 #+4./ 
tTz	/&+ > > >35bkk)9#: 3C 3D 3$*$ *SW *\ 48"*4. 
6 48)
)
 #+4.)
 
	)
X       
 9XseTk-BD$-N#O  
 c d  r;   )	metaclassr   c                     d}d}t        |       j                  |      D ]-  }|r|dk(  r|dk(  r|j                  |      \  }}}&||z   |z   }/ |xs |S )Nr   r  r   r  )ro   r3  
rpartition)r   sepnewpathrX   ra   s        r:   r  r  Z  sp    
C GD	$ 'ts{4<#..s3MGQC-$&' >cr;   c                       e Zd ZdeddfdZy)_CloudPathSelectableAccessorscandir_funcr]   Nc                     || _         y r4   )scandir)rd   rk  s     r:   r   z%_CloudPathSelectableAccessor.__init__v  s	    #r;   )rc   rm   rn   r   r   rs   r;   r:   rj  rj  u  s    $X $$ $r;   rj  c                       e Zd Z	 ddedee   dededdf
dZdefdZdd	edefd
Z	defdZ
defdZedefd       Zd Zeedd deed   ddf   fd              ZeZd Zy)r9  rX   r   childrenr   r]   Nc                 p    || _         || _        || _        || _        t	        | j
                        | _        y r4   )_name_all_children_parentsr  rj  rm  	_accessor)rd   rX   r   ro  r   s        r:   r   z_CloudPathSelectable.__init__{  s1     
%5dllCr;   c                 T    dj                  | j                  | j                  gz         S )Nr   )r   rs  rX   rj   s    r:   r   z_CloudPathSelectable.__repr__  s     xx344r;   r  c                     | j                   d uS r4   )rr  r  s     r:   r  z_CloudPathSelectable.is_dir  s    !!--r;   c                     | j                   S r4   )r  rj   s    r:   r   z_CloudPathSelectable.exists  s    ||r;   c                      yr  rs   rj   s    r:   
is_symlinkz_CloudPathSelectable.is_symlink  r  r;   c                     | j                   S r4   )rq  rj   s    r:   rX   z_CloudPathSelectable.name  s    zzr;   c                     t        || j                  | j                  gz   | j                  j	                  |d       || j                  v       S )N)r   )r9  rs  rX   rr  r  )rd   parts     r:   _make_child_relpathz(_CloudPathSelectable._make_child_relpath  sH    #MMTYYK'""4.4---	
 	
r;   r<  )r9  NNc              #   X    K    fd j                   j                         D         y w)Nc              3   n   K   | ],  \  }}t        |j                  j                  gz   |       . y wr4   )r9  rs  rq  )r   childgrand_childrenr<  s      r:   r   z/_CloudPathSelectable.scandir.<locals>.<genexpr>  s5      
%~ !(DnU
s   25)rr  rL  )r<  s   `r:   rm  z_CloudPathSelectable.scandir  s(     

)-););)A)A)C
 	
s   '*c              #     K   t        t              }| j                  |       5 }|D ]$  }||j                            j	                  |       & | |d   D cg c]  }|j
                   c}|d   D cg c]  }|j
                   c}f |d   D ]  }|j                         E d {     	 d d d        y c c}w c c}w 7 # 1 sw Y   y xY wwr  )r   r-  rm  r  rM  rX   rW  )rd   
dirs_filesrL  r  r6  	child_dirs         r:   rW  z_CloudPathSelectable.walk  s      &
\\$ 	,5 95<<>*11%89 D)9:A:ZX]M^<_QVV<___'- ,	$>>+++,	, 	,
 ;<_ ,	, 	,sF   !C2CB6(	C1B;
!C%C &C-	C6CCCr]  r\  )rc   rm   rn   ro   r   r   rq   r   r   r  r   ry  rr   rX   r}  ra  r   r   rm  _scandirrW  rs   r;   r:   r9  r9  z  s     DD cD 	D
 D 
D5# 5.d .t . D  c  
 
$
	9?@$L	M
  
 H,r;   r9  r]  )cr  r  r   collections.abc
contextlibr   ior   r   r   r	   r
   r  pathlibr   r   r   r   r=  r  typesr   typingr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   urllib.parser"   warningsr#   	_typeshedr$   r%   r&   r'   r(   r  r+   typing_extensionsr-   r0   r1   r5   r2   r=   pathlib._locallegacy.globcloudpathlib.enumsrB   r  rC   
exceptionsrD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   r   rS   cloudpath_inforU   rW   rt   ro   rp   ru   rv   r   ABCMetar   r[   r  rj  r9  rs   r;   r:   <module>r     s   
 #  % T T 	   
     ( "   w +w& g&@$F 	bqW$$3&bqW$+&+ $&+ -     &  )   < ;FFY:Z c#667 Z CL\5
S XtJ/?.@$zBR.R%S >@CKK >@Do- or+= S 6$ $
?, ?,r;   