
    h,                        S SK r S SKrS SKrS SKrS SKJr  SSKJr  S rS r	S r
\4S jr " S	 S
5      rS9S jrS rS:S jrSS.S jrSS.S jrS;S jrSS.S jrS rSSS.S jrS rSSS.S jrSS.S jrS:S jrSSS.S jrSS.S jrS<S jrS  rS! rS" rS# r S$ r!S% r"S& r#S' r$S( r%S) r&S* r'S+ r( " S, S-5      r)S. r*S/ r+SSSSS0.S1 jr,SSSSS0.S2 jr- " S3 S45      r.S5 r/ " S6 S75      r0S8 r1g)=    N)InvalidGlobArgumentsError   )	CloudPathc                  (    [        U S   [        5      $ Nr   
isinstancer   argskwargss     N/home/james-whalen/.local/lib/python3.13/site-packages/cloudpathlib/patches.py_check_first_argr      s    d1gy))    c                  .    [        U S   S   [        5      $ r   r   r
   s     r   _check_first_arg_first_indexr      s    d1gaj),,r   c                  v    [        U S   [        5      =(       d     [        UR                  SS 5      [        5      $ )Nr   root_dir)r	   r   getr
   s     r   _check_first_arg_or_root_dirr      s+    d1gy)`Z

:t8TV_-``r   c                 $   ^^^ U mUUU4S jnUn U$ )Nc                  >   > T" U 0 UD6(       a  T" U 0 UD6$ T" U 0 UD6$ N )r   r   	_original	cpl_checkcpl_versions     r   _patched_version(_patch_factory.<locals>._patched_version   s0    d%f%///d-f--r   r   )original_versionr   r   r   r   s    `` @r   _patch_factoryr       s     I. (r   c                   *    \ rS rSrSS jrS rS rSrg)
_OpenPatch$   Nc                     Uc  [         R                  nXl        [        R                  U l        [        U[        R                  5      U l        U R                  [         l        S [        l        g )Nc                     U $ r   r   )xs    r   <lambda>%_OpenPatch.__init__.<locals>.<lambda>2   s    r   )builtinsopen
_orig_openr   
__fspath___orig_fspathr    patched)selforiginal_opens     r   __init___OpenPatch.__init__%   sO     $MMM'%00%NN
 *	r   c                 "    [         R                  $ r   )r)   r*   r/   s    r   	__enter___OpenPatch.__enter__4   s    }}r   c                 X    U R                   [        l        U R                  [        l        g r   )r+   r)   r*   r-   r   r,   r/   exc_type	exc_value	tracebacks       r   __exit___OpenPatch.__exit__7   s    #00	r   )r-   r+   r.   r   __name__
__module____qualname____firstlineno__r1   r5   r<   __static_attributes__r   r   r   r"   r"   $   s    +1r   r"   c                     [        U 5      $ r   )r"   )r0   s    r   
patch_openrE   <   s    m$$r   c                     U $ r   r   paths    r   _cloudpath_fspathrI   @   s    Kr   c                 4    [        U R                  5       5      $ r   )listiterdirrG   s    r   _cloudpath_os_listdirrM   D   s    r   )dir_fdc                "    U R                  5       $ r   statrH   rN   s     r   _cloudpath_lstatrS   H       99;r   c                "    U R                  5       $ r   )mkdirrR   s     r   _cloudpath_mkdirrW   L       ::<r   Fc                 .    [         R                  " U SUS9$ )NT)parentsexist_ok)r   rV   )namemoder[   s      r   _cloudpath_os_makedirsr^   P   s    ??4AAr   c                     U R                  SS9$ )NF)
missing_okunlinkrR   s     r   _cloudpath_os_removerc   T   s    ;;%;((r   c                 J    U R                    H  nUR                  5         M     g r   )rZ   rmdir)r\   ds     r   _cloudpath_os_removedirsrg   X   s    \\		 r   )
src_dir_fd
dst_dir_fdc                $    U R                  U5      $ r   renamesrcdstrh   ri   s       r   _cloudpath_os_renamerp   ]       ::c?r   c                 <    U R                  U5        [        U 5        g r   )rl   rg   )oldnews     r   _cloudpath_os_renamesru   a   s    JJsOS!r   c                $    U R                  U5      $ r   rk   rm   s       r   _cloudpath_os_replacerw   f   rq   r   c                "    U R                  5       $ r   )re   rR   s     r   _cloudpath_os_rmdirry   j   rX   r   c                 "    U R                  5       $ r   )rL   rG   s    r   _cloudpath_os_scandirr{   n   s    <<>r   T)rN   follow_symlinksc                "    U R                  5       $ r   rP   )rH   rN   r|   s      r   _cloudpath_os_statr~   r   rT   r   c                "    U R                  5       $ r   ra   rR   s     r   _cloudpath_os_unlinkr   v   s    ;;=r   c              #   @   #    U R                  XUS9 S h  vN   g  N7f)N)top_downon_errorr|   )walk)toptopdownonerrorfollowlinkss       r   _cloudpath_os_walkr   z   s     
 xxKxXXXs   c                     U R                   $ r   )r\   rG   s    r   _cloudpath_os_path_basenamer      s    99r   c                    ^ ^ Sm [        UU 4S jT SS   5       5      (       a%  TS-  m[        UU 4S jT SS   5       5      (       a  M%  T S   S T $ ! [         a     Nf = f)Nr   c              3   >   >#    U  H  oT   TS    T   :H  v   M     g7f)r   Nr   ).0itemipartss     r   	<genexpr>__common.<locals>.<genexpr>   s      ?YTq'U1Xa[(Ys   r   )all
IndexError)r   r   s   `@r   __commonr      sl    	A?U12Y???FA ?U12Y???
 8BQ<  s   AA 
AAc                     [        U  Vs/ s H  oR                  PM     sn5      nU S   R                  R                  " U6 $ s  snf r   )r   r   clientr   )pathspcommons      r   _cloudpath_os_path_commonpathr      s;    .1ww./F8??$$f-- /s   Ac                 Z    [        U  Vs/ s H  n[        U5      PM     sn5      nU$ s  snf r   )r   str)rK   r   r   s      r   _cloudpath_os_path_commonprefixr      s)    t,t!s1vt,-FM -s   (c                     U R                   $ r   )parentrG   s    r   _cloudpath_os_path_dirnamer      s    ;;r   c                 8    U R                  5       R                  4$ r   )rQ   st_atimerG   s    r   _cloudpath_os_path_getatimer          IIK  ""r   c                 8    U R                  5       R                  4$ r   )rQ   st_mtimerG   s    r   _cloudpath_os_path_getmtimer      r   r   c                 8    U R                  5       R                  4$ r   )rQ   st_ctimerG   s    r   _cloudpath_os_path_getctimer      r   r   c                 8    U R                  5       R                  4$ r   )rQ   st_sizerG   s    r   _cloudpath_os_path_getsizer      s    IIK!!r   c                      U H  nX-  n M	     U $ r   r   )rH   r   r   s      r   _cloudpath_os_path_joinr      s    	 Kr   c                 2    U R                   U R                  4$ r   )r   r\   rG   s    r   _cloudpath_os_path_splitr      s    ;;		!!r   c                 ^    [        U 5      S [        U R                  5      *  U R                  4$ r   )r   lensuffixrG   s    r   _cloudpath_os_path_splitextr      s)    t9(DKK(()4;;66r   c                   &    \ rS rSrS rS rS rSrg)_OSPatch   c                    S[         R                  [        4S[         R                  [        4S[         R
                  [        4S[         R                  [        4S[         R                  [        4S[         R                  [        4S[         R                  [        4S[         R                  [         4S	[         R"                  [$        4S
[         R&                  [(        4S[         R*                  [,        4S[         R.                  [0        4S[         R2                  [4        4S[         R6                  [8        4S[         R:                  [<        4/n0 U l        U H/  u  p#nX0R>                  U'   [A        X45      n[C        [         X%5        M1     S[         RD                  RF                  [H        [J        4S[         RD                  RL                  [N        [P        4S[         RD                  RR                  [T        [P        4S[         RD                  RV                  [X        [J        4S[         RD                  RZ                  [\        RZ                  [J        4S[         RD                  R^                  [`        [J        4S[         RD                  Rb                  [d        [J        4S[         RD                  Rf                  [h        [J        4S[         RD                  Rj                  [l        [J        4S[         RD                  Rn                  [\        Rp                  [J        4S[         RD                  Rr                  [\        Rt                  [J        4S[         RD                  Rv                  [x        [J        4S[         RD                  Rz                  [|        [J        4S[         RD                  R~                  [        [J        4/n0 U lA        U H8  u  p#pGX0R                  U'   [A        X4US9n[C        [         RD                  X%5        M:     g )NfspathlistdirlstatrV   makedirsremove
removedirsrl   renamesreplacere   scandirrQ   rb   r   basename
commonpathcommonprefixdirnameexistsgetatimegetmtimegetctimegetsizeisfileisdirjoinsplitsplitextr   )Bosr   rI   r   rM   r   rS   rV   rW   r   r^   r   rc   r   rg   rl   rp   r   ru   r   rw   re   ry   r   r{   rQ   r~   rb   r   r   r   os_originalsr    setattrrH   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   is_filer   is_dirr   r   r   r   r   r   os_path_originals)r/   os_levelr\   originalcloudr.   os_path_levelchecks           r   r1   _OSPatch.__init__   s   ryy"34

$9:bhh 01bhh 01&<=ryy"672==*BCryy"67

$9:

$9:bhh 34

$9:RWW01ryy"67RWW01
$ %-!DE&.d#$X5GB& &. ))+FHXY""-,	 $$/,	 )CEUVrww~~y'7'79IJ))+FHXY))+FHXY))+FHXY)CEUVrww~~y'8'8:JKbggmmY%5%57GHRWW\\#:<LMbggmm%=?OP))+FHXY1
6 "$,9(DE+3""4($XFGBGGT+ -:r   c                     g r   r   r4   s    r   r5   _OSPatch.__enter__   s    r   c                     U R                   R                  5        H  u  pE[        [        XE5        M     U R                  R                  5        H  u  pE[        [        R
                  XE5        M!     g r   )r   itemsr   r   r   rH   )r/   r9   r:   r;   r\   r   s         r   r<   _OSPatch.__exit__   sR    "//557NDB' 8 #44::<NDBGGT, =r   )r   r   Nr>   r   r   r   r   r      s    :,x-r   r   c                      [        5       $ r   )r   r   r   r   patch_os_functionsr     s
    :r   c                    [        U R                  5       H7  u  pSU;   d  SU;   d  SU;   d  M  U R                  S U nU R                  US  n  O   U R                  n/ nU R                  " U6 nU(       d  SnXV4$ SR                  U5      nXV4$ )N*?[/)	enumerater   _new_cloudpathr   )pathnamer   part
root_partspattern_partsr   patterns          r   #_get_root_dir_pattern_from_pathnamer   
  s    X^^,$;#+!+J$NN12.M	 - ^^
&&
3H   ((=)r   r   rN   	recursiveinclude_hiddenc                   [        U [        5      (       aO  [        U[        5      (       a:  U R                  U5      (       d  [        SU SU  S35      eU R	                  U5      nOT[        U [        5      (       a  Ub  [        S5      e[        U 5      u  pO#[        U[        5      (       a  U nO[        S5      eUR                  U5      $ )Nz"If both are CloudPaths, root_dir (z ) must be a parent of pathname (z).zFIf pathname is a CloudPath, root_dir must also be a CloudPath or None.z9At least one of pathname or root_dir must be a CloudPath.)r	   r   is_relative_tor   relative_tor   glob)r   r   rN   r   r   r   s         r   _cloudpath_glob_iglobr   !  s    
 (I&&:h	+J+J&&x00+4XJ>^_g^hhjk 
 **84G	Hi	(	(+X  @I'	Hi	(	( (G
 	
 ==!!r   c          
      .    [        [        U UUUUS95      $ )Nr   )rK   r   )r   r   rN   r   r   s        r   _cloudpath_glob_globr   D  s(     )	
 r   c                   &    \ rS rSrS rS rS rSrg)
_GlobPatchiR  c                     [         R                   U l        [         R                  U l        [	        U R                  [
        [        S9U l        [	        U R                  [        [        S9U l	        g )Nr   )
r   original_globigloboriginal_iglobr    r   r   patched_globr   patched_iglobr4   s    r   r1   _GlobPatch.__init__S  sT    !YY"jj* 2
 ,!2
r   c                 X    U R                   [        l        U R                  [        l        g r   )r  r   r  r  r4   s    r   r5   _GlobPatch.__enter__c  s    %%	''
r   c                 X    U R                   [        l        U R                  [        l        g r   )r  r   r  r  r8   s       r   r<   _GlobPatch.__exit__h  s    &&	((
r   )r  r  r  r  Nr>   r   r   r   r   r   R  s    
 
)r   r   c                      [        5       $ r   )r   r   r   r   
patch_globr  m  s
    <r   c                   &    \ rS rSrS rS rS rSrg)_PatchAllBuiltinsiq  c                 ^    [        5       U l         [        5       U l        [        5       U l        g r   )rE   r   r  r4   s    r   r1   _PatchAllBuiltins.__init__r  s    $,"4"6$,r   c                     U R                   R                  5         U R                  R                  5         U R                  R                  5         g r   )rE   r5   r   r  r4   s    r   r5   _PatchAllBuiltins.__enter__w  s7    !!#))+!!#r   c                     U R                   R                  XU5        U R                  R                  XU5        U R                  R                  XU5        g r   )rE   r<   r   r  r8   s       r   r<   _PatchAllBuiltins.__exit__}  s@      i@((iH  i@r   )r  rE   r   Nr>   r   r   r   r  r  q  s    '
Ar   r  c                      [        5       $ r   )r  r   r   r   patch_all_builtinsr    s    r   r   ).)i  F)TNF)2r)   r   r   os.pathcloudpathlib.exceptionsr   	cloudpathr   r   r   r   r    r"   rE   rI   rM   rS   rW   r^   rc   rg   rp   ru   rw   ry   r{   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r   r   <module>r     sP     	  =  *-a =M 
1 10%  &*  &* B *. )
 26$ "
 374  )-  (,T  *. Y	.

###""7E- E-P0 tuU "H tuU) )6A A$r   