
    h+                     (   % S SK r S SKJr  S SKrS SKJr  S SKJrJrJ	r	J
r
Jr  S SKrS SKJrJrJrJr  S SKrS SKrS SKJr  S SKJrJrJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(  S SK)J*r*  S S	K+J,r,  \%(       a  S S
K-J.r.J/r/J0r0J1r1J2r2  \Rf                  S:  a  S SKJ4r4  OS SK5J4r4  \Rf                  S:  a  S SKJ6r6  OS SK5J6r6  \Rf                  S:  a  S SKJ7r7  S SKJ8r9  S SKJ:r:  S2S jr8Oj\Rf                  SS S:X  a  S SKJ:r:  S SKJ;r7  S SKJ8r8  OD\Rf                  SS S:X  a  S SK<J:r:  S SK;r7SSK=J8r8  O \Rf                  S:  a  S SKJ:r:  S SK;r7SSK=J8r8  S SK>J?r?  SSK@JArA  SSKBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQ  \%(       a  SSKRJSrS  SSKTJUrU   " S S5      rV\" \V5      rW\\X\V4   \YS '   \&" S!5      rZ\&" S"S#S$9r[S%\XS&\\$\[   /\$\[   4   4S' jr\ " S( S)\ R                  5      r^ " S* S#\^S+9r_S,\S&\X4S- jr` " S. S/5      ra " S0 S15      rbg)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                 ,    [        [        U 5      U5      $ N)_make_selector_pathlibtuple)pattern_parts_flavourcase_sensitives      P/home/james-whalen/.local/lib/python3.13/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                       \ rS rSr% \\S'   Sr\\S'   \S   \S'   \S   \S'   SS jr	\
S	\S   4S j5       r\
S	\S   4S j5       rSrg
)CloudImplementationo   nameTdependencies_loadedrS   _client_class	CloudPath_path_classreturnNc                 
   SS/nU Vs/ s H  n[        U SU 35      b  M  UPM     nnU(       a  [        SU 35      eU R                  (       d0  [        SU R                  R
                   SU R                   S35      eg s  snf )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   rZ   rN   r[   __name__rY   )selfexpectedclsmissings       r:   validate_completeness)CloudImplementation.validate_completenessu   s    "L1"*O(3gdauI.F3(O/CG9M  ''*+D,>,>,G,G+H I226))CA  ( Ps
   B B c                 :    U R                  5         U R                  $ r4   )ri   r[   re   s    r:   r`    CloudImplementation.client_class   s    ""$!!!r;   c                 :    U R                  5         U R                  $ r4   )ri   r]   rl   s    r:   ra   CloudImplementation.path_class   s    ""$r;    r^   N)rd   
__module____qualname____firstlineno__str__annotations__rZ   boolr   ri   propertyr`   ra   __static_attributes__rp   r;   r:   rW   rW   o   sk    
I $$>!k"" "d8n " "  D-    r;   rW   implementation_registryT
CloudPathTr\   )boundkeyr^   c                 L   ^  S[         [           S[         [           4U 4S jjnU$ )Nrg   r^   c                    > [        U [        5      (       d  [        S5      eU [        T   l        [        T   U l        U $ )Nz/Only subclasses of CloudPath can be registered.)
issubclassr\   	TypeErrorrz   r]   _cloud_meta)rg   r~   s    r:   	decorator&register_path_class.<locals>.decorator   s;    #y))MNN36$01#6
r;   )r   r|   )r~   r   s   ` r:   register_path_classr      s(    tJ' D,<  r;   c                       \ rS rSr\S\\   S\S\S\S\4
S j5       r	\S\\   S\
\S4   S\S\S\4
S	 j5       r	S\\   S\
\\4   S\S\S\
\S\4   4
S
 jr	S\S\\S4   S\\\4   SS4S jrSrg)CloudPathMeta   rg   
cloud_pathargskwargsr^   c                     g r4   rp   rg   r   r   r   s       r:   __call__CloudPathMeta.__call__   s     r;   r\   c                     g r4   rp   r   s       r:   r   r      s     r;   c                 n   [        U [        5      (       d  [        S[        R                   S35      eU [        L a  [        R                  5        HX  nUR                  nUc  M  UR                  USS9(       d  M+  [        R                  U5      nUR                  " Xa/UQ70 UD6  Us  $    [        R                  5        Vs/ s H(  nUR                  c  M  UR                  R                  PM*     nn[        SU SU S35      e[        R                  U 5      nU R                  " Xa/UQ70 UD6  U$ s  snf )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   rd   rz   valuesr]   is_valid_cloudpathobject__new____init__cloud_prefixrM   )	rg   r   r   r   implementationra   new_objimplvalid_prefixess	            r:   r   r      sA    #y))%i&8&8%99bc 
 )"9"@"@"B+77
)j.K.Ku /L / / %nnZ8G''MdMfM"N #C 4::<<D## .  --<  
 %
|#GGWWXY  ..%W:4:6:s   D2D2rY   bases.dicNc                 
   [        U 5       H  nUR                  S5      (       a  M  [        [        U5      (       d  M2  [	        [	        [        U5      SS 5      (       d  MT  [	        [        U5      R
                  S-   n[        [	        X5      [        5      (       a  U[	        X5      R                  l        OU[	        X5      l        [        [	        X5      [        5      (       d  M  U[	        X5      R                  l        M     g )Nrb   __doc__z' _(Docstring copied from pathlib.Path)_)dir
startswithhasattrr   rc   r   
isinstancer   __func__rx   fget)rg   rY   r   r   attr	docstrings         r:   r   CloudPathMeta.__init__   s    HDOOC((D$''GD$/DAA#D$/77:cc	gc0:??:CGC&//71:GC&.gc0(;; 7@GC&++3! r;   rp   )rd   rr   rs   rt   r   r   r{   r|   r   r   r    ru   r   typer   r   ry   rp   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                   n   \ rS rSr% Sr\\S'   \\S'   SS.S\\\	S 4   S\S	\
S
   SS4S jjr\S 5       rSS jrS\\\4   4S jrS\\\4   SS4S jr\S\4S j5       r\S\4S j5       r\\ SSS S\S\\	   4S jj5       5       r\\SS\S\S\4S jj5       5       r\ SS\\S 4   S\S\\\\	   4   4S jj5       rS\4S jrS\4S jrS\4S jrS\S\4S jrS\4S jrS\S\4S  jr S\S\4S! jr!S\S\4S" jr"S\S\4S# jr#\\$RJ                  S\4S$ j5       5       r&\$RJ                   SS%\S&\S'\
\   SS4S( jj5       r'\$RJ                  SS&\S'\
\   SS4S) jj5       r(SS*\S+\S\4S, jjr)S\SS4S- jr*\S\4S. j5       r+S\4S/ jr,SS\4S0 jjr-SS\4S1 jjr.SS\4S2 jjr/\S\4S3 j5       r0\S4\S\	4S5 j5       r1S6\\\2Rf                  4   S\4S7 jr4S8 r5S9\S\6\	SS4   4S: jr7  SS6\\\2Rf                  4   S;\
\   S<\S\6\	SS4   4S= jjr8  SS6\\\2Rf                  4   S;\
\   S<\S\6\	SS4   4S> jjr9S\6\	SS4   4S? jr:\;SS@ j5       r<   SSA\SB\
\=   SC\S\6\>\	\?\   \?\   4   SS4   4SD jjr@\       SS'SESF\SG\
\   SH\
\   SI\
\   SJ\
\   SK\
\   SSL4SM jj5       rA\     SS'SNSF\BSO   SGSSHSSISSJ\
\   SK\
\   SSP4SQ jj5       rA\      SS'SRSF\BSS   SGSSHSSISSJ\
\   SK\
\   SST4SU jj5       rA\      SS'SVSF\BSS   SGSSHSSISSJ\
\   SK\
\   SSW4SX jj5       rA\      SS'SYSF\BSS   SGSSHSSISSJ\
\   SK\
\   SSZ4S[ jj5       rA\      SS'SNSF\SGSSHSSISSJ\
\   SK\
\   SS\4S] jj5       rA\      SS'\SF\SG\
\   SH\
\   SI\
\   SJ\
\   SK\
\   SS^4S_ jj5       rA       SS'\SF\SG\
\   SH\
\   SI\
\   SJ\
\   SK\
\   SS^4S` jjrASa\	S\	4Sb jrCSa\	S\	4Sc jrDSSd jrESe\\\2Rf                  4   S\4Sf jrFSSg\SS4Sh jjrGSi\HS\4Sj jrI   SSi\SG\
\   SH\
\   SI\
\   S\4
Sk jjrJS\H4Sl jrK   SSG\
\   SH\
\   SI\
\   S\4Sm jjrLSn rMSo\S\4Sp jrNS\\\O4   S\	4Sq jrPSr\\\2Rf                  4   S\	4Ss jrQS\	4St jrRS\4Su jrSSSv\S\	4Sw jjrTSS\	Sx\S\O4Sy jjrUS\	S\4Sz jrV\S\4S{ j5       rWSS6\S;\
\   S\4S| jjrXSS}\S;\
\   S\4S~ jjrY\S\	4S j5       rZ\S\	4S j5       r[\S\>\	S4   4S j5       r\\S\>\S4   4S j5       r]\S\4S j5       r^\S\4S j5       r_\S\?\   4S j5       r`S\S\	4S jraS\S\	4S jrbS\	4S jrcS\S\	4S jrdSo\S\4S jreSSC\S\2R                  4S jjrgSS jrhS\\\2Rf                  4   S\i4S jrjSS jrk SS\\\2Rf                  4   SK\
\   S\	4S jjrl    SSa\\\2Rf                  S 4   SC\S\SK\
\   S\S\\i\	4   4S jjrm\   SSa\	SK\
\   S\	4S jj5       rn\   SSa\iSK\
\   S\i4S jj5       rn\   SSa\SK\
\   S\\iS 4   4S jj5       rn   SSa\\\2Rf                  \	4   SC\S\SK\
\   S\\i\	4   4
S jjrn\   SS\	SC\S\SK\
\   S\	4
S jj5       ro\   SS\iSC\S\SK\
\   S\i4
S jj5       ro\   SS\SC\S\SK\
\   S\\iS 4   4
S jj5       ro   SS\\\2Rf                  \	4   SC\S\SK\
\   S\\i\	4   4
S jjro\  SS\	SK\
\   S\
\=\\p\   /\q\   4      S\	4S jj5       rr\  SS\iSK\
\   S\
\=\\p\   /\q\   4      S\i4S jj5       rr\  SS\\\2Rf                  \	4   SK\
\   S\
\=\\p\   /\q\   4      S\\iS 4   4S jj5       rrSS jrr\   SSa\	SC\S\SK\
\   S\	4
S jj5       rs\   SSa\iSC\S\SK\
\   S\i4
S jj5       rs\   SSa\SC\S\SK\
\   S\\iS 4   4
S jj5       rs   SSa\\\2Rf                  \	4   SC\S\SK\
\   S\\i\	4   4
S jjrs\   SS\	SC\S\SK\
\   S\	4
S jj5       rt\   SS\iSC\S\SK\
\   S\i4
S jj5       rt\   SS\SC\S\SK\
\   S\\iS 4   4
S jj5       rt   SS\\\2Rf                  \	4   SC\S\SK\
\   S\\i\	4   4
S jjrtS ru\S\i4S j5       rvS\\\2Rf                  4   S\S\	4S jrwSSJ\
\   SS4S jjrx SSK\
\   S\	4S jjry SS\iSK\
\   S\	4S jjrz\S\4S j5       r{\S\S\	4S j5       r|\S\6\=\/\	4   SS4   4S j5       r}\S\S\	4S j5       r~Srg)r\      aj  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          	         S U l         S U l        U(       aQ  [        U5      R                  S5      (       d  [        U5      S-   n[        U5      SR	                  S U 5       5      -   nU R                  USS9  U R                  R                  5         [        U5      U l        [        U R                  5      U l
        [        SU R                   35      U l        Uc'  [        U[        5      (       a  UR                   U l        OX l        Uba  [        X R                  R"                  5      (       d=  [%        SUR&                   SU R&                   SU R                  R"                   S35      eS	U l        g )
N/c              3   B   #    U  H  oR                  S 5      v   M     g7f)r   N)strip.0ps     r:   	<genexpr>%CloudPath.__init__.<locals>.<genexpr>  s     3P%QGGCLL%s   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_clientru   endswithjoinr   r   ri   _strr"   _urlr   
_no_prefix_pathr   r\   r   r`   rD   	__class___dirty)re   r   r   r   s       r:   r   CloudPath.__init__   sF    &*+/z?++C00 _s2
Z3883P%3P+PPJ
4@..0 
O	TYY'	"Qt&7#89
 >*i00)00!Lj9I9I9V9V&W&W%"6#3#3"4 5NN##;D<L<L<Y<Y;Z [HI  r;   c                     [        U SS 5      c)  U R                  R                  R                  5       U l        U R                  $ Nr   )rc   r   r`   get_default_clientr   rl   s    r:   r   CloudPath.client  s7    4D)1++88KKMDL||r;   c                 
   U R                   b9  U R                  R                  5       (       a  U R                   R                  5         [	        U SS 5      n[	        USS 5      [
        R                  :X  a  U R                  5         g g )Nr   file_cache_mode)r   _localexistscloserc   rB   cloudpath_objectclear_cache)re   r   s     r:   __del__CloudPath.__del__%  sh    <<#(:(:(<(<LL  y$/6,d3}7U7UU Vr;   c                 L    U R                   R                  5       nSU;   a  US	 U$ r   )__dict__copyre   states     r:   __getstate__CloudPath.__getstate__/  s+    ""$ i r;   r   c                 :    U R                   R                  U5        g r4   )r   updater   s     r:   __setstate__CloudPath.__setstate__8  s    U#r;   c                 F    U R                   [        U R                  5      S  $ r4   )r   lenanchorrl   s    r:   r   CloudPath._no_prefix;  s    yyT[[)+,,r;   c                 r    U R                   [        U R                  5      [        U R                  5      -   S  $ r4   )r   r   r   driverl   s    r:   _no_prefix_no_driveCloudPath._no_prefix_no_drive?  s*    yyT[[)C

O;=>>r;   .pathr   c                     g r4   rp   rg   r   r   s      r:   r   CloudPath.is_valid_cloudpathC  s     r;   c                     g r4   rp   r   s      r:   r   r   I  s    PSr;   c                     [        U5      R                  5       R                  U R                  R                  5       5      nU(       a#  U(       d  [	        SU SU R                   S35      eU$ )N'z4' is not a valid path since it does not start with ')ru   lowerr   r   rM   )rg   r   r   valids       r:   r   r   M  sb     D	!,,S-=-=-C-C-EF%$D6McN^N^M__`a  r;   c                 :    U R                   R                   SU  S3$ )Nz('z'))r   rd   rl   s    r:   __repr__CloudPath.__repr__Z  s     ..))*"TF"55r;   c                     U R                   $ r4   )r   rl   s    r:   __str__CloudPath.__str__]  s    yyr;   c                 T    [        [        U 5      R                  [        U 5      45      $ r4   )hashr   rd   ru   rl   s    r:   __hash__CloudPath.__hash__`  s     T$Z((#d)455r;   otherc                 h    [        U[        U 5      5      =(       a    [        U 5      [        U5      :H  $ r4   )r   r   ru   re   r   s     r:   __eq__CloudPath.__eq__c  s%    %d,HTc%j1HHr;   c                 v    U R                  5       (       a  U R                  5         [        U R                  5      $ r4   )is_file_refresh_cacheru   r   rl   s    r:   
__fspath__CloudPath.__fspath__f  s(    <<>>!4;;r;   c                 t    [        U[        U 5      5      (       d  [        $ U R                  UR                  :  $ r4   r   r   NotImplementedr   r   s     r:   __lt__CloudPath.__lt__k  ,    %d,,!!zzEKK''r;   c                 t    [        U[        U 5      5      (       d  [        $ U R                  UR                  :*  $ r4   r  r   s     r:   __le__CloudPath.__le__p  ,    %d,,!!zzU[[((r;   c                 t    [        U[        U 5      5      (       d  [        $ U R                  UR                  :  $ r4   r  r   s     r:   __gt__CloudPath.__gt__u  r	  r;   c                 t    [        U[        U 5      5      (       d  [        $ U R                  UR                  :  $ r4   r  r   s     r:   __ge__CloudPath.__ge__z  r  r;   c                     g)zVFor example "bucket" on S3 or "container" on Azure; needs to be defined for each classNrp   rl   s    r:   r   CloudPath.drive  s     	r;   parentsexist_okmodec                     g)zPShould be implemented using the client API without requiring a dir is downloadedNrp   )re   r  r  r  s       r:   mkdirCloudPath.mkdir  s    
 	r;   c                     g)zMShould be implemented using the client API to create and update modified timeNrp   )re   r  r  s      r:   touchCloudPath.touch  s     	r;   presignexpire_secondsc                     U(       a  U R                   R                  XS9nU$ U R                   R                  U 5      nU$ )N)r   )r   _generate_presigned_url_get_public_url)re   r  r   urls       r:   as_urlCloudPath.as_url  s>    ++55d5ZC 
 ++--d3C
r;   c                     [        S5      e)NzZCannot change a cloud path's root since all paths are absolute; create a new path instead.)
ValueErrorr   s     r:   __rtruediv__CloudPath.__rtruediv__  s    h
 	
r;   c                     U R                   $ r4   )r   rl   s    r:   r   CloudPath.anchor  s       r;   c                     [        U 5      $ r4   )ru   rl   s    r:   as_uriCloudPath.as_uri  s    4yr;   c                 8    U R                   R                  U 5      $ r4   )r   _existsre   follow_symlinkss     r:   r   CloudPath.exists  s    {{""4((r;   c                 >    U R                   R                  U 5      S:H  $ )Nr   r   _is_file_or_dirr2  s     r:   is_dirCloudPath.is_dir  s    {{**40E99r;   c                 >    U R                   R                  U 5      S:H  $ )Nfiler6  r2  s     r:   r   CloudPath.is_file  s    {{**40F::r;   c                 "    U R                  5       $ r4   )r  rl   s    r:   fspathCloudPath.fspath  s      r;   uric                     U " U5      $ r4   rp   )rg   r@  s     r:   from_uriCloudPath.from_uri  s    3xr;   patternc                    [        U[        R                  5      (       aG  [        U[        5      (       a  [	        UR                  U 5      5      nO"[        R                  " U5      nO[	        U5      nSU;   a  [        S5      eUR                  U R                  5      (       d  UR                  S5      (       a  [        S5      eU R                  S:X  a  [        S5      eU$ )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\   ru   relative_tor>  rJ   r   r   r   )re   rD  str_patterns      r:   _glob_checksCloudPath._glob_checks  s    gr{{++'9--!'"5"5d";< ii0g,K;.J  !!$"3"3448N8Ns8S8S./VWW::. Z  r;   c                 H  ^^ U4S jmUU4S jmT" 5       nU R                   R                  XS9 He  u  p4[        UR                  U 5      5      R	                  S5      n[        U5      S:X  a  US   S:X  a  MH  S U 5       nT" U[        US 5      Xd5        Mg     [        U5      $ )	Nc                     > [        T 5      $ r4   r   )Trees   r:   <lambda>*CloudPath._build_subtree.<locals>.<lambda>  s
    T!2r;   c                 b   > [        US5      nUc  U(       a  T" 5       OSX'   gT" X   XBU5        g)z]Utility to build a tree from nested defaultdicts with a generator
of nodes (parts) of a path.N)next)trunkbranchnodesr8  next_branchrP  _build_trees        r:   rY  -CloudPath._build_subtree.<locals>._build_tree  s4     ud+K"*0d EM;vFr;   	recursiver   r@   r   r   c              3   $   #    U  H  ov   M     g 7fr4   rp   r   s     r:   r   +CloudPath._build_subtree.<locals>.<genexpr>  s     &1Qs   )r   	_list_dirru   rJ  splitr   rT  dict)	re   r\  	file_treefr8  r   rW  rP  rY  s	          @@r:   _build_subtreeCloudPath._build_subtree  s    2		G F	..t.IIAd+,2237E 5zQ58s?&&E	4t#4eD J Ir;   r\  c              #      #    U R                  U5      n[        U R                  / U5      nUR                  U5       H,  nU [	        U5      [        U R                  5      S-   S  -  v   M.     g 7f)Nr@   )rd  _CloudPathSelectablerY   select_fromru   r   )re   selectorr\  rb  rootr   s         r:   _globCloudPath._glob  sg     ''	2	#II
 %%d+A#a&TYY!!3!5667 ,s   A+A-r9   recurse_symlinksc              #      #    U R                  U5      n[        U5      R                  n[        [	        U5      [
        US9nU R                  USU;   =(       d    SU;   5       S h  vN   g  N7f)Nr9   r   **rL  r   r   r1   r6   r0   rk  re   rD  r9   rm  r7   ri  s         r:   globCloudPath.glob  so      ##G,%g.44!- .
 ::7N 
 	
 	
s   A#A-%A+&A-c              #      #    U R                  U5      n[        U5      R                  n[        S[	        U5      -   [
        US9nU R                  US5       S h  vN   g  N7f)N)rp  ro  Trq  rr  s         r:   rglobCloudPath.rglob'  sX      ##G,%g.44!eM**N>
 ::h---s   AA!AA!c              #   h   #    U R                   R                  U SS9 H  u  pX:w  d  M  Uv   M     g 7f)NFr[  )r   r_  )re   rc  rb   s      r:   iterdirCloudPath.iterdir6  s0     KK))$%)@DAy As   #2	2c              #   "  #    / n/ nUR                  5        H,  u  pVUc  UR                  U5        M  UR                  U5        M.     U(       a  XU4v   U H$  n[        R                  X-  X   US9 Sh  vN   M&     U(       d  XU4v   gg N7f)zmUtility 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)rj  treer}  dirsfilesitemrV  r   s           r:   r  !CloudPath._walk_results_from_tree;  s     
  JJLLD"(.ELLdkk$6G ) e##C 88TYYa8bbb  e##  cs   A3B5B6Br}  on_errorr3  c              #      #     U R                  SS9nU R                  XUS9 S h  vN   g  N! [         a  nUb  U" U5         S nAg e S nAff = f7f)NTr[  r|  )rd  r  	Exception)re   r}  r  r3  rb  es         r:   walkCloudPath.walkN  sW     	++d+;I33Dh3WWW 	#		s<   A". ,. A. 
AA	AA		AAr(   	bufferingencodingerrorsnewlineforce_overwrite_from_cloudforce_overwrite_to_cloudr
   c                     g r4   rp   re   r  r  r  r  r  r  r  s           r:   openCloudPath.open^  s     r;   r$   r   r	   c                     g r4   rp   r  s           r:   r  r  j  s     r;   r&   )r@   r   c                     g r4   rp   r  s           r:   r  r  v       r;   r'   r   c                     g r4   rp   r  s           r:   r  r    r  r;   r%   r   c                     g r4   rp   r  s           r:   r  r    r  r;   r   c                     g r4   rp   r  s           r:   r  r    s     r;   zIO[Any]c                     g r4   rp   r  s           r:   r  r    s     r;   c                 r  ^ ^^^^^ T R                  5       nU(       a$  T R                  5       (       d  [        ST  S35      eU(       d(  [        U4S jS 5       5      (       a  [	        ST  35      eTS:X  a$  T R                  5       (       a  [        ST  S35      eT R                  US	9  T R                  R                  5       (       d'  T R                  R                  R                  S
S
S9  SmO$T R                  R                  5       R                  mT R                  R                  TUUUUS9n	[        U4S jS 5       5      (       a+  U	R                  mSUUU U4S jjn
Xl        U	T l        S
T l        T R                   R"                  [$        R&                  :X  a  U	R                  mU U4S jnXl        U	$ )Nz2Cannot open directory, only files. Tried to open ()c              3   ,   >#    U  H	  oT;   v   M     g 7fr4   rp   r   mr  s     r:   r   !CloudPath.open.<locals>.<genexpr>  s     &E*QDy*   )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  r  r  r  r  c              3   ,   >#    U  H	  oT;   v   M     g 7fr4   rp   r  s     r:   r   r    s     7"6QDy"6r  )w+r  r  c                     > T" U 0 UD6  TR                   (       d  g TR                  R                  5       R                  T:  a%  TS-   n[        R
                  " TR                  X"4S9  TR                  TS9  STl         g )Nr@   timesr  F)r   r   statst_mtimerH  utime_upload_local_to_cloud)r   r   	new_mtimer  original_mtimere   wrapped_closes      r:   _patched_close_upload-CloudPath.open.<locals>._patched_close_upload  sq    t.v. {{
 ;;##%..? . 2IHHT[[0FG++E]+^#r;   c                  6   > T" U 0 UD6  TR                  5         g r4   )r   )r   r   re   wrapped_close_for_caches     r:   _patched_close_empty_cache2CloudPath.open.<locals>._patched_close_empty_cache  s    '88   "r;   rq   )r   r   rG   anyrF   rE   r  r   parentr  r  r  r  r   r   r   r   r   rB   
close_file)re   r  r  r  r  r  r  r  exists_on_cloudbufferr  r  r  r  r  s   ``     `    @@@r:   r  r    s    ++-4<<>>,DTF!L  3&E*&E#E#E,RSWRXY  3;4;;==*-Ho+^__ 	7QR {{!!##KK$$TD$A N![[--/88N!! " 
 7"6777"LLM$ $$ 1L "DL DK ;;&&-*B*BB '-ll## 6Lr;   targetc                 8   [        U 5      [        U5      La  [        S[        U 5       35      eU R                  5       (       a  [        SU  S35      eX:X  a  U $ UR	                  5       (       a  UR                  5         U R                  R                  X5        U$ )NzBThe target based to rename must be an instantiated class of type: r   z6 is a directory; rename/replace the files recursively.)r   r   r8  rG   r   unlinkr   
_move_filere   r  s     r:   replaceCloudPath.replace  s    :T&\)TUYZ^U_T`a  ;;==,vST  >K==??MMOt,r;   c                 $    U R                  U5      $ r4   )r  r  s     r:   renameCloudPath.rename%  s     ||F##r;   c                     U R                  5       (       a  [        SU  S35      e [        U R                  5       5        [	        SU  S35      e! [
         a     Of = fU R                  R                  U 5        g )Nr   z) is a file; call unlink instead of rmdir.zDirectory not empty: 'z$'. Use rmtree to delete recursively.)r   rH   rT  ry  rK   StopIterationr   _removerl   s    r:   rmdirCloudPath.rmdir*  sz    <<>>-vFG 	 ((.RS   		D!s   (A 
AA
other_pathc                 
    X:H  $ r4   rp   )re   r  s     r:   samefileCloudPath.samefile8  s    !!r;   
missing_okc                     U R                  5       (       a  [        SU  S35      eU R                  R                  X5        g )Nr   z. is a directory; call rmdir instead of unlink.)r8  rG   r   r  )re   r  s     r:   r  CloudPath.unlink<  s;    ;;==,vKL  	D-r;   datac                     [        U5      nU R                  SS9 nUR                  U5      sSSS5        $ ! , (       d  f       g= f)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)re   r  viewrc  s       r:   write_bytesCloudPath.write_bytesD  s5     $YYDY!Q774= "!!s	   6
Ac                     [        U[        5      (       d"  [        SUR                  R                  -  5      eU R                  SX#US9 nUR                  U5      sSSS5        $ ! , (       d  f       g= f)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 %sr  r  r  r  r  N)r   ru   r   r   rd   r  r  )re   r  r  r  r  rc  s         r:   
write_textCloudPath.write_textO  sY     $$$69P9PPQQYYC(7YSWX774= TSSs   	A$$
A2c                 v    U R                  SS9 nUR                  5       sS S S 5        $ ! , (       d  f       g = f)Nrbr  r  read)re   rc  s     r:   
read_bytesCloudPath.read_bytesa  s'    YYDY!Q668 "!!s   *
8c                 z    U R                  SXUS9 nUR                  5       sS S S 5        $ ! , (       d  f       g = f)Nr  r  r  )re   r  r  r  rc  s        r:   	read_textCloudPath.read_texte  s/     YYC(7YSWX668 TSSs   ,
:c                     gNFrp   rl   s    r:   is_junctionCloudPath.is_junctionn      r;   funcc                   ^  T R                   R                  U5      n[        U5      (       a  U" U0 UD6n[        U[        5      (       a  [        U5      nT R                  U5      $ [        U[        R                  R                  5      (       a_  [        U5      S:  aP  [        US   [        5      (       a8  [        U[        5      (       d  [        U5      O[        nU" U 4S jU 5       5      $ U$ )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      >#    U  H:  n[        U5      UR                  :w  d  M  TR                  [        U5      5      v   M<     g 7fr4   )_resolverj  _new_cloudpath)r   r   re   s     r:   r   .CloudPath._dispatch_to_path.<locals>.<genexpr>  s<      ":FQ(ST+YZY_Y_J_0##HQK00,s
   A!A)r   __getattribute__callabler   r   r  r  collectionsabcSequencer   r2   r   r6   )re   r  r   r   path_versionsequence_classs   `     r:   _dispatch_to_pathCloudPath._dispatch_to_pathu  s    
 zz2248 L!!'88L lM22#L1L&&|44 |[__%=%=>>L!A%<?M:: +5\<*P*P\"V[  " ":F"    r;   c                 h    [        U[        [        45      (       d  [        $ U R	                  SU5      $ )N__truediv__)r   ru   r   r  r   r   s     r:   r  CloudPath.__truediv__  s-    %#}!566!!%%mU;;r;   pathsegmentsc                 (    U R                   " S/UQ76 $ )Njoinpathr   re   r  s     r:   r  CloudPath.joinpath  s    %%j@<@@r;   c                     U $ r4   rp   rl   s    r:   absoluteCloudPath.absolute      r;   c                     gNTrp   rl   s    r:   is_absoluteCloudPath.is_absolute  s    r;   strictc                     U $ r4   rp   )re   r  s     r:   resolveCloudPath.resolve  r  r;   walk_upc           
         [        U[        5      (       d  [        U  SU S35      eU R                  UR                  :w  a+  [        U  SU R                   SU SUR                   S35      e[	        US9n[
        R                  S:  a  UR                  S5        U R                  R                  " UR                  40 UD6$ )	Nz is a cloud path, but z is notz is a z path, but z path)r  r.   r  )
r   r\   r(  r   ra  sysversion_infopopr   rJ  )re   r   r  r   s       r:   rJ  CloudPath.relative_to  s     %++v%;E7'JKK;;%,,&&t{{m;ugVELL>QVW  g&g%JJy!zz%%ekk<V<<r;   c                 H     U R                  U5        g! [         a     gf = fNTF)rJ  r(  r   s     r:   is_relative_toCloudPath.is_relative_to  s*    	U# 		s    
!!c                 $    U R                  S5      $ )NrY   r  rl   s    r:   rY   CloudPath.name      %%f--r;   c                    [         R                  S:  a  [        S5      eUR                  U R                  U R
                  -   5      (       a&  U[        U R                  U R
                  -   5      S  nO;UR                  U R                  5      (       a  U[        U R                  5      S-
  S  n[        U R                  5      R                  XS9$ )Nr>   z)full_match requires Python 3.13 or higherr@   ro  )
r  r  NotImplementedErrorr   r   r   r   r   r   
full_match)re   rD  r9   s      r:   r&  CloudPath.full_match  s    g%%&QRR dkkDJJ677c$++

":;=>G,,c$++.245G T556AA B 
 	
r;   path_patternc                 6   UR                  U R                  U R                  -   S-   5      (       a(  U[        U R                  U R                  -   S-   5      S  n[	        US9n[
        R                  S:  a  UR                  S5        U R                  " SU40 UD6$ )Nr   ro  r.   r9   match)	r   r   r   r   ra  r  r  r  r   )re   r(  r9   r   s       r:   r*  CloudPath.match  s    ""4;;#;c#ABB'DKK$**,Ds,J(K(MNL^4g%JJ'(%%g|FvFFr;   c                 b    [         R                  S:  a  [        S5      eU R                  S5      $ )Nr>   z%parser requires Python 3.13 or higherparser)r  r  r%  r   rl   s    r:   r-  CloudPath.parser  s-    g%%&MNN%%h//r;   c                 $    U R                  S5      $ )Nr  r  rl   s    r:   r  CloudPath.parent      %%h//r;   c                 $    U R                  S5      $ )Nr  r  rl   s    r:   r  CloudPath.parents  s    %%i00r;   c                 `    U R                  S5      nUS   S:X  a  USS  nU R                  /UQ7$ )Nr   r   r   r@   )r   r   )re   r   s     r:   r   CloudPath.parts  s:    &&w/8s?!"IE$e$$r;   c                 $    U R                  S5      $ )Nstemr  rl   s    r:   r7  CloudPath.stem  r#  r;   c                 $    U R                  S5      $ )Nsuffixr  rl   s    r:   r:  CloudPath.suffix  r1  r;   c                 $    U R                  S5      $ )Nsuffixesr  rl   s    r:   r=  CloudPath.suffixes  s    %%j11r;   r7  c                      U R                  SU5      $ ! [         a     U R                  XR                  -   5      s $ f = f)N	with_stem)r   AttributeError	with_namer:  )re   r7  s     r:   r@  CloudPath.with_stem  s?    	6))+t<< 	6>>$"455	6s    '>>rY   c                 &    U R                  SU5      $ )NrB  r  )re   rY   s     r:   rB  CloudPath.with_name  s    %%k488r;   c                 B    U R                  SR                  U5      5      $ )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_segmentsCloudPath.with_segments  s     ""388L#9::r;   r:  c                 &    U R                  SU5      $ )Nwith_suffixr  )re   r:  s     r:   rJ  CloudPath.with_suffix  s    %%mV<<r;   c                    U R                  5         U R                  R                  U5      n[        U5      (       a  U" U0 UD6n[	        U[
        [        45      (       a!  UR                  5       nU R                  U5      $ U$ r4   )	r  r   r  r  r   r   r   r  r  )re   r  r   r   r  s        r:   _dispatch_to_local_cache_path'CloudPath._dispatch_to_local_cache_path  sy    {{33D9 L!!'88L lY$<=='//1L&&|44  r;   c                 T    [        SU R                   S35        U R                  SUS9$ )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 filesizer  )r3  )r#   r   rM  r2  s     r:   r  CloudPath.stat-  s=    
 	3DNN3C DO P	
 11&/1ZZr;   c                     [        U 5      $ )z,Return a CloudPathInfo object for this path.rT   rl   s    r:   infoCloudPath.info8  s    T""r;   destinationc                    [        U5      nU R                  5       (       d  [        SU  35      eU R                  5       (       a>  UR	                  5       (       a  XR
                  -  nU R                  R                  X5      $ UR                  SS9  U R                  5        HS  n[        U 5      nUR                  S5      (       d  US-   n[        U5      [        U5      S  nUR                  X-  5        MU     U$ )Nz-Cannot download because path does not exist: T)r  r   )r   r   rI   r   r8  rY   r   _download_filer  ry  ru   r   r   download_to)re   rT  rc  relrel_dests        r:   rW  CloudPath.download_to=  s    ;'{{}}),YZ^Y_*`aa<<>>!!##)II5;;--d@@t,\\^$i||C(()Cq6#c(*-k45 $ r;   c                     U R                  5       (       a  [        SU  S35      eU R                  R                  U 5        g)z Delete an entire directory tree.r   z* is a file; call unlink instead of rmtree.N)r   rH   r   r  rl   s    r:   rmtreeCloudPath.rmtreeS  s;    <<>>-vGH  	D!r;   sourcec                 B   [        U5      nUR                  5       (       a4  UR                  5        H  nXR                  -  R	                  X2S9  M      U $ U R                  5       (       a$  U R                  5       (       a  XR                  -  nOU nUR                  XS9  U$ )z-Upload a file or directory to the cloud path.r  )r   r8  ry  rY   upload_fromr   _upload_file_to_cloud)re   r^  r  r   dsts        r:   r`  CloudPath.upload_from[  s     f==??^^%++A+a & K {{}}[[(%%f%`Jr;   preserve_metadata
remove_srcc           	         U R                  5       (       d  [        SU  S35      e[        R                  " U5      nU R	                  5       (       a-  U R                  UUS9n[        [        [        [        4   U5      $ [        U[        5      (       d  U R                  U5      $ U R                  UR                  L a  UR                  5       (       a#  UR	                  5       (       a  X`R                  -  nUc1  [        R                   R#                  SS5      R%                  5       S;   nU(       d]  UR                  5       (       aH  UR'                  5       R(                  U R'                  5       R(                  :  a  [+        SU SU  S	35      e[        [        U R                  R-                  XUS
95      $ UR                  5       (       a  UR/                  5       (       a5  [        [        [        [        4   UR1                  U R2                  US95      $ [        [        [        [        4   X`R                  -  R1                  U R2                  US95      $ )Nr   z must exist to copy.r  %CLOUDPATHLIB_FORCE_OVERWRITE_TO_CLOUDFalse1truezFile (z) is newer than (z5). To overwrite pass `force_overwrite_to_cloud=True`.)re  )r   r(  rC   
to_anypathr8  copytreer!   r    r   r-   r   r\   rW  r   rY   rH  environgetr   r  r  rQ   r  r   r`  r>  )re   r  r3  rd  r  re  rT  results           r:   _copyCloudPath._copys  s    {{}}uTF*>?@@((0;;==]])A # F dDj)622+y11##K00 ;;+,,,!!##(:(:(<(<)II5'/+-::>>;W,%'],+(
 -&&(($$&//499;3G3GG.[M):4& A< =  dkk44TS]4^__ %%'';+>+>+@+@$*%++>V ,   $*% 99,99>V :  r;   c                     g r4   rp   re   r  r3  rd  r  s        r:   r   CloudPath.copy       r;   c                     g r4   rp   rt  s        r:   r   ru    rv  r;   c                     g r4   rp   rt  s        r:   r   ru         $'r;   c                 (    U R                  UUUUSS9$ )z6Copy self to target folder or file, if self is a file.Fr3  rd  r  re  rq  rt  s        r:   r   ru    s)     zz+/%=  
 	
r;   
target_dirc                     g r4   rp   re   r}  r3  rd  r  s        r:   	copy_intoCloudPath.copy_into  rv  r;   c                     g r4   rp   r  s        r:   r  r    rv  r;   c                     g r4   rp   r  s        r:   r  r    ry  r;   c                     [         R                  " U5      U R                  -  nU R                  UUUUSS9n[	        [
        [        [        4   U5      $ )z9Copy self into target directory, preserving the filename.Fr{  rC   rl  rY   rq  r!   r    r   r-   re   r}  r3  rd  r  target_pathrp  s          r:   r  r    sW     ((4tyy@+/%=  
 E$*%v..r;   ignorec                     g r4   rp   re   rT  r  r  s       r:   rm  CloudPath.copytree
       r;   c                     g r4   rp   r  s       r:   rm  r    r  r;   c                     g r4   rp   r  s       r:   rm  r    s     $'r;   c                    U R                  5       (       d  [        SU  S35      e[        R                  " U5      nUR	                  5       (       a$  UR                  5       (       a  [        SU S35      e[        U R                  5       5      nUb.  U" U R                  U Vs/ s H  oUR                  PM     sn5      nO
[        5       nUR                  SSS9  U H  nUR                  U;   a  M  UR                  5       (       a  UR                  XR                  -  US9  MH  UR                  5       (       d  M_  UR                  XR                  UR                  R                  S5      (       a  S	OS-   -  UUS
9  M     U$ s  snf )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.Tr  r  r   rG  )r  r  )r8  rH   rC   rl  r   r   rE   listry  r   rY   setr  r   rm  r   )re   rT  r  r  contentsr  ignored_namessubpaths           r:   rm  r  "  se   {{}}-tf$de  ((5K$7$7$9$9*#K=0QR  '"4#;#;h=Whffh=WXMEM$6G||},  ,,.Ia   !!  <<9N9Ns9S9S2Y\#]^-E! !    ) >Xs   !F
c                     g r4   rp   rt  s        r:   moveCloudPath.moveI  rv  r;   c                     g r4   rp   rt  s        r:   r  r  R  rv  r;   c                     g r4   rp   rt  s        r:   r  r  [  ry  r;   c                 (    U R                  UUUUSS9$ )z2Move self to target location, removing the source.Tr{  r|  rt  s        r:   r  r  d  s)     zz+/%=  
 	
r;   c                     g r4   rp   r  s        r:   	move_intoCloudPath.move_intot  rv  r;   c                     g r4   rp   r  s        r:   r  r  }  rv  r;   c                     g r4   rp   r  s        r:   r  r    ry  r;   c                     [         R                  " U5      U R                  -  nU R                  UUUUSS9n[	        [
        [        [        4   U5      $ )zQMove self into target directory, preserving the filename and removing the source.Tr{  r  r  s          r:   r  r    sW     ((4tyy@+/%=  
 E$*%v..r;   c                     U R                   R                  5       (       a[  U R                   R                  5       (       a  U R                   R                  5         g[        R
                  " U R                   5        gg)zRemoves cache if it existsN)r   r   r   r  shutilr\  rl   s    r:   r   CloudPath.clear_cache  sM    ;;{{""$$""$dkk*	  r;   c                 H    U R                   R                  U R                  -  $ )z!Cached local version of the file.)r   _local_cache_dirr   rl   s    r:   r   CloudPath._local  s     {{++doo==r;   c                     [        U5      nUR                  S5      (       a  USS nUR                  U R                  5      (       d  U R                   U 3nU R                  R                  " U/UQ76 $ )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)ru   r   r   r   r\   )re   r   r   s      r:   r  CloudPath._new_cloudpath  sj     4y ??38D t{{++kk]4&)D{{$$T2E22r;   c                 <    U R                  5       nUc1  [        R                  R	                  SS5      R                  5       S;   nU(       dQ  U R                  R                  5       (       a2  U R                  R                  5       R                  UR                  :  at  U R                  R                  R                  SSS9  U R                  U R                  5        [        R                  " U R                  UR                  UR                  4S9  U R                  (       a  [        SU R                   SU  S	35      eU R                  R                  5       R                  UR                  :  a  [        SU R                   SU  S
35      eg ! [         a     g f = f)N'CLOUDPATHLIB_FORCE_OVERWRITE_FROM_CLOUDrh  ri  Tr  r  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.)r  rO   rH  rn  ro  r   r   r   r  r  r  rW  r  r   rP   rR   )re   r  statss      r:   r  CloudPath._refresh_cache  se   	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   U R                   R                  5       (       a  [        S5      eU R                  U R                   US9nU R	                  5       n[
        R                  " U R                   UR                  UR                  4S9  SU l        SU l	        U$ )z.Uploads cache file at self._local to the cloudz2Only individual files can be uploaded to the cloudr  r  FN)
r   r8  r(  ra  r  rH  r  r  r   r   )re   r  uploadedr  s       r:   r   CloudPath._upload_local_to_cloud  s     ;;QRR--KK2J . 

 		
U^^U^^$DE r;   
local_pathc                    Uc1  [         R                  R                  SS5      R                  5       S;   nU(       a  U R                  R                  UU 5        U $  U R                  5       nU(       a(  UR                  5       R                  UR                  :  a  U R                  R                  UU 5        U $ [        SU R                   SU  S35      e! [         a    Sn Nwf = f)zVUploads file at `local_path` to the cloud if there is not a newer file
already there.
Nrg  rh  ri  r  r  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.)rH  rn  ro  r   r   _upload_filer  rO   r  rQ   r   )re   r  r  r  s       r:   ra  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                      SSK Jn  UR                  U R                  UR	                  5       5      $ ! [
         a     gf = f)zNPydantic special method. See
https://docs.pydantic.dev/2.0/usage/types/custom/r   )core_schemaN)pydantic_corer   no_info_after_validator_functionvalidate
any_schemaImportError)rg   r  _handlerr  s       r:   __get_pydantic_core_schema__&CloudPath.__get_pydantic_core_schema__2  sD    	1??&&(   		s   /2 
??vc                     U " U5      $ )zSUsed as a Pydantic validator. See
https://docs.pydantic.dev/2.0/usage/types/custom/rp   )rg   r  s     r:   r  CloudPath.validate@  s     1vr;   c              #   (   #    U R                   v   g7f)z_Pydantic special method. See
https://pydantic-docs.helpmanual.io/usage/types/#custom-data-typesN)	_validate)rg   s    r:   __get_validators__CloudPath.__get_validators__F  s      mms   valuec                     U " U5      $ )zdUsed as a Pydantic validator. See
https://pydantic-docs.helpmanual.io/usage/types/#custom-data-typesrp   )rg   r  s     r:   r  CloudPath._validateL  s     5zr;   )r   r   r   r   r   r   rq   ).F)FFN)TN)Fi  Tr  )TNF)r  r  NNNNN)NNNNN)r  NNNNN)NNNr4   )r^   rU   )TFNF)TFN)NN)rd   rr   rs   rt   r   rW   rv   ru   r    r-   r   r   rx   r   r   r   r   r   r   r   r   r   classmethodrw   r+   r   r   r   intr   r   r  r  r  r  r  r  abstractmethodr   r  r  r%  r)  r   r.  r   r8  r   r>  rB  rH  rI  rL  rd  r   rk  rs  rv  ry  staticmethodr  r   r   r   r  r  r   r  r  r  r  r  bytesr  r  r  r  r  r   r   r  r  r  r  r  rJ  r  rY   r&  r*  r-  r  r  r   r7  r:  r=  r@  rB  rG  rJ  rM  stat_resultr  rR  r   rW  r\  r`  rq  r   r  r   r   rm  r  r  r   r   r  r  r  ra  r  r  r  r  ry   rp   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                     SnSn[        U 5      R                  U5       H6  nU(       a  US:X  a  M  US:X  a  UR                  U5      u  n  nM/  X!-   U-   nM8     U=(       d    U$ )Nr   rG  r   rF  )ru   r`  
rpartition)r   sepnewpathrY   rb   s        r:   r  r  Z  si    
C GD	$ts{4<#..s3MGQ-$& % >cr;   c                   &    \ rS rSrS\SS4S jrSrg)_CloudPathSelectableAccessoriu  scandir_funcr^   Nc                     Xl         g r4   scandir)re   r  s     r:   r   %_CloudPathSelectableAccessor.__init__v  s    #r;   r  )rd   rr   rs   rt   r   r   ry   rp   r;   r:   r  r  u  s    $X $$ $r;   r  c                       \ rS rSr SS\S\\   S\S\SS4
S jjrS\4S	 jr	SS
\S\4S jjr
S\4S jrS\4S jr\S\4S j5       rS r\\SS S\\S   SS4   4S j5       5       r\rS rSrg)rg  iz  rY   r  childrenr   r^   Nc                 h    Xl         X0l        X l        X@l        [	        U R
                  5      U l        g r4   )_name_all_children_parentsr1  r  r  	_accessor)re   rY   r  r  r   s        r:   r   _CloudPathSelectable.__init__{  s)     
%5dllCr;   c                 T    SR                  U R                  U R                  /-   5      $ )Nr   )r   r  rY   rl   s    r:   r   _CloudPathSelectable.__repr__  s     xx344r;   r3  c                     U R                   S L$ r4   )r  r2  s     r:   r8  _CloudPathSelectable.is_dir  s    !!--r;   c                     U R                   $ r4   )r1  rl   s    r:   r   _CloudPathSelectable.exists  s    ||r;   c                     gr  rp   rl   s    r:   
is_symlink_CloudPathSelectable.is_symlink  r  r;   c                     U R                   $ r4   )r  rl   s    r:   rY   _CloudPathSelectable.name  s    zzr;   c                     [        UU R                  U R                  /-   U R                  R	                  US 5      XR                  ;   S9$ )N)r   )rg  r  rY   r  ro  )re   parts     r:   _make_child_relpath(_CloudPathSelectable._make_child_relpath  sF    #MMTYYK'""4.---	
 	
r;   rj  )rg  NNc              #   Z   ^ #    U 4S jT R                   R                  5        5       v   g 7f)Nc              3   r   >#    U  H,  u  p[        UTR                  TR                  /-   U5      v   M.     g 7fr4   )rg  r  r  )r   childgrand_childrenrj  s      r:   r   /_CloudPathSelectable.scandir.<locals>.<genexpr>  s6      
)C% !(DnUU)Cs   47)r  r~  )rj  s   `r:   r  _CloudPathSelectable.scandir  s'     

)-););)A)A)C
 	
s   (+c              #     #    [        [        5      nU R                  U 5       nU H$  nXR                  5          R	                  U5        M&     XS    Vs/ s H  oDR
                  PM     snUS    Vs/ s H  oDR
                  PM     sn4v   US    H  nUR                  5        S h  vN   M     S S S 5        g s  snf s  snf  N! , (       d  f       g = f7fr  )r   r  r  r8  r  rY   r  )re   
dirs_filesr~  r  rc  	child_dirs         r:   r  _CloudPathSelectable.walk  s      &
\\$5<<>*11%8  D)9:)9A)9:ZX]M^<_M^VVM^<___'-	$>>+++ .  
 ;<_ ,  sF   !C2CB;*	C3C 
!C)C*C2	C;C
CC)r  r  r1  r  r  r  r  )rd   rr   rs   rt   ru   r   r   rw   r   r   r8  r   r  rx   rY   r  r  r   r   r  _scandirr  ry   rp   r;   r:   rg  rg  z  s     DD cD 	D
 D 
D5# 5.d .t . D  c  
 
$
	9?@$L	M
  
 H,r;   rg  r  )cr  r  r   collections.abc
contextlibr   ior   r   r   r	   r
   rH  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   rG  rC   
exceptionsrD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   r   rS   cloudpath_inforU   rW   rz   ru   rv   r{   r|   r   ABCMetar   r\   r  r  rg  rp   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;   