
    i,                        d dl Z d dlZd dlZd dlZd dlmZ ddlmZ d Zd Z	d Z
efdZ G d	 d
      Zd9dZd Zd:dZdddZdddZd;dZdddZd ZddddZd ZddddZdddZd:dZddddZdddZd<dZd  Zd! Zd" Zd# Z d$ Z!d% Z"d& Z#d' Z$d( Z%d) Z&d* Z'd+ Z( G d, d-      Z)d. Z*d/ Z+ddddd0d1Z,ddddd0d2Z- G d3 d4      Z.d5 Z/ G d6 d7      Z0d8 Z1y)=    N)InvalidGlobArgumentsError   )	CloudPathc                  (    t        | d   t              S Nr   
isinstancer   argskwargss     e/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/cloudpathlib/patches.py_check_first_argr      s    d1gy))    c                  .    t        | d   d   t              S r   r   r
   s     r   _check_first_arg_first_indexr      s    d1gaj),,r   c                  l    t        | d   t              xs  t        |j                  dd       t              S )Nr   root_dir)r	   r   getr
   s     r   _check_first_arg_or_root_dirr      s+    d1gy)`Z

:t8TV_-``r   c                 "    | fd}|} |S )Nc                  4     | i |r | i |S  | i |S N )r   r   	_original	cpl_checkcpl_versions     r   _patched_versionz(_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                        e Zd ZddZd Zd Zy)
_OpenPatchNc                     |t         j                  }|| _        t        j                  | _        t        |t        j                        | _        | j                  t         _        d t        _        y )Nc                     | S r   r   )xs    r   <lambda>z%_OpenPatch.__init__.<locals>.<lambda>2   s     r   )builtinsopen
_orig_openr   
__fspath___orig_fspathr   patched)selforiginal_opens     r   __init__z_OpenPatch.__init__%   sQ     $MMM'%00%NN
 *	r   c                 "    t         j                  S r   )r&   r'   r,   s    r   	__enter__z_OpenPatch.__enter__4   s    }}r   c                 X    | j                   t        _        | j                  t        _        y r   )r(   r&   r'   r*   r   r)   r,   exc_type	exc_value	tracebacks       r   __exit__z_OpenPatch.__exit__7   s    #00	r   r   __name__
__module____qualname__r.   r1   r7   r   r   r   r!   r!   $   s    +1r   r!   c                     t        |       S r   )r!   )r-   s    r   
patch_openr=   <   s    m$$r   c                     | S r   r   paths    r   _cloudpath_fspathrA   @   s    Kr   c                 4    t        | j                               S r   )listiterdirr?   s    r   _cloudpath_os_listdirrE   D   s    r   )dir_fdc                "    | j                         S r   statr@   rF   s     r   _cloudpath_lstatrK   H       99;r   c                "    | j                         S r   )mkdirrJ   s     r   _cloudpath_mkdirrO   L       ::<r   Fc                 2    t        j                  | d|      S )NT)parentsexist_ok)r   rN   )namemoderS   s      r   _cloudpath_os_makedirsrV   P   s    ??4AAr   c                &    | j                  d      S )NF)
missing_okunlinkrJ   s     r   _cloudpath_os_remover[   T   s    ;;%;((r   c                 F    | j                   D ]  }|j                           y r   )rR   rmdir)rT   ds     r   _cloudpath_os_removedirsr_   X   s    \\ 		r   )
src_dir_fd
dst_dir_fdc                $    | j                  |      S r   renamesrcdstr`   ra   s       r   _cloudpath_os_renamerh   ]       ::c?r   c                 <    | j                  |       t        |        y r   )rd   r_   )oldnews     r   _cloudpath_os_renamesrm   a   s    JJsOS!r   c                $    | j                  |      S r   rc   re   s       r   _cloudpath_os_replacero   f   ri   r   c                "    | j                         S r   )r]   rJ   s     r   _cloudpath_os_rmdirrq   j   rP   r   c                 "    | j                         S r   )rD   r?   s    r   _cloudpath_os_scandirrs   n   s    <<>r   T)rF   follow_symlinksc                "    | j                         S r   rH   )r@   rF   rt   s      r   _cloudpath_os_statrv   r   rL   r   c                "    | j                         S r   rY   rJ   s     r   _cloudpath_os_unlinkrx   v   s    ;;=r   c              #   H   K   | j                  |||      E d {    y 7 w)N)top_downon_errorrt   )walk)toptopdownonerrorfollowlinkss       r   _cloudpath_os_walkr   z   s      
 xx7KxXXXs   " "c                     | j                   S r   )rT   r?   s    r   _cloudpath_os_path_basenamer      s    99r   c                      d	 t         fd dd  D              rdz  t         fd dd  D              r d   d  S # t        $ r Y w xY w)Nr   c              3   :   K   | ]  }|   d       k(    yw)r   Nr   ).0itemipartss     r   	<genexpr>z__common.<locals>.<genexpr>   s"     ?T$q'U1Xa[(?s   r   )all
IndexError)r   r   s   `@r   __commonr      sf    	A?U12Y??FA ?U12Y??
 8BQ<  s   5A 	AAc                     t        | D cg c]  }|j                   c}      } | d   j                  j                  | S c c}w r   )r   r   clientr   )pathspcommons      r   _cloudpath_os_path_commonpathr      s;    .1qww./F$58??$$f-- /s   A c                 T    t        | D cg c]  }t        |       c}      }|S c c}w r   )r   str)rC   r   r   s      r   _cloudpath_os_path_commonprefixr      s%    t,!s1v,-FM -s   %c                     | j                   S r   )parentr?   s    r   _cloudpath_os_path_dirnamer      s    ;;r   c                 8    | j                         j                  fS r   )rI   st_atimer?   s    r   _cloudpath_os_path_getatimer          IIK  ""r   c                 8    | j                         j                  fS r   )rI   st_mtimer?   s    r   _cloudpath_os_path_getmtimer      r   r   c                 8    | j                         j                  fS r   )rI   st_ctimer?   s    r   _cloudpath_os_path_getctimer      r   r   c                 8    | j                         j                  fS r   )rI   st_sizer?   s    r   _cloudpath_os_path_getsizer      s    IIK!!r   c                     |D ]  }| |z  } 	 | S r   r   )r@   r   r   s      r   _cloudpath_os_path_joinr      s     	Kr   c                 2    | j                   | j                  fS r   )r   rT   r?   s    r   _cloudpath_os_path_splitr      s    ;;		!!r   c                 ^    t        |       d t        | j                          | j                  fS r   )r   lensuffixr?   s    r   _cloudpath_os_path_splitextr      s)    t9(DKK(()4;;66r   c                       e Zd Zd Zd Zd Zy)_OSPatchc                    dt         j                  t        fdt         j                  t        fdt         j
                  t        fdt         j                  t        fdt         j                  t        fdt         j                  t        fdt         j                  t        fdt         j                  t         fd	t         j"                  t$        fd
t         j&                  t(        fdt         j*                  t,        fdt         j.                  t0        fdt         j2                  t4        fdt         j6                  t8        fdt         j:                  t<        fg}i | _        |D ]2  \  }}}|| j>                  |<   tA        ||      }tC        t         ||       4 dt         jD                  jF                  tH        tJ        fdt         jD                  jL                  tN        tP        fdt         jD                  jR                  tT        tP        fdt         jD                  jV                  tX        tJ        fdt         jD                  jZ                  t\        jZ                  tJ        fdt         jD                  j^                  t`        tJ        fdt         jD                  jb                  td        tJ        fdt         jD                  jf                  th        tJ        fdt         jD                  jj                  tl        tJ        fdt         jD                  jn                  t\        jp                  tJ        fdt         jD                  jr                  t\        jt                  tJ        fdt         jD                  jv                  tx        tJ        fdt         jD                  jz                  t|        tJ        fdt         jD                  j~                  t        tJ        fg}i | _A        |D ]?  \  }}}}|| j                  |<   tA        |||      }tC        t         jD                  ||       A y )NfspathlistdirlstatrN   makedirsremove
removedirsrd   renamesreplacer]   scandirrI   rZ   r|   basename
commonpathcommonprefixdirnameexistsgetatimegetmtimegetctimegetsizeisfileisdirjoinsplitsplitextr   )Bosr   rA   r   rE   r   rK   rN   rO   r   rV   r   r[   r   r_   rd   rh   r   rm   r   ro   r]   rq   r   rs   rI   rv   rZ   rx   r|   r   os_originalsr   setattrr@   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_levelrT   originalcloudr+   os_path_levelchecks           r   r.   z_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
$ %- 	'!D(E&.Dd#$Xu5GBg&	' ))+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 	,(D(E5+3D""4($XuFGBGGT7+	,r   c                      y r   r   r0   s    r   r1   z_OSPatch.__enter__   s    r   c                     | j                   j                         D ]  \  }}t        t        ||        | j                  j                         D ]   \  }}t        t        j
                  ||       " y r   )r   itemsr   r   r   r@   )r,   r4   r5   r6   rT   r   s         r   r7   z_OSPatch.__exit__   sd    "//557 	(ND(Bh'	( #44::< 	-ND(BGGT8,	-r   Nr8   r   r   r   r   r      s    :,x-r   r   c                      t               S r   )r   r   r   r   patch_os_functionsr     s
    :r   c                    t        | j                        D ]1  \  }}d|v s	d|v sd|v s| j                  d | }| j                  |d  } n | j                  }g } | j                  | }|sd}||fS dj                  |      }||fS )N*?[/)	enumerater   _new_cloudpathr   )pathnamer   part
root_partspattern_partsr   patterns          r   #_get_root_dir_pattern_from_pathnamer   
  s    X^^, 4$;#+!+J$NN12.M	 ^^
&x&&
3H  W ((=)Wr   r   rF   	recursiveinclude_hiddenc                b   t        | t              rEt        |t              r5| j                  |      st        d| d|  d      | j	                  |      }nJt        | t              r|t        d      t        |       \  }}nt        |t              r| }nt        d      |j                  |      S )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   rF   r   r   r   s         r   _cloudpath_glob_iglobr   !  s    
 (I&:h	+J&&x0+4XJ>^_g^hhjk 
 **84G	Hi	(+X  @I'	Hi	( (G
 	
 ==!!r   c          	      4    t        t        | ||||            S )Nr   )rC   r   )r   r   rF   r   r   s        r   _cloudpath_glob_globr   D  s(     )	
 r   c                       e Zd Zd Zd Zd Zy)
_GlobPatchc                     t         j                   | _        t         j                  | _        t	        | j                  t
        t              | _        t	        | j                  t        t              | _	        y )Nr   )
r   original_globigloboriginal_iglobr   r   r   patched_globr   patched_iglobr0   s    r   r.   z_GlobPatch.__init__S  sT    !YY"jj* 2
 ,!2
r   c                 X    | j                   t        _        | j                  t        _        y r   )r   r   r   r   r0   s    r   r1   z_GlobPatch.__enter__c  s    %%	''
r   c                 X    | j                   t        _        | j                  t        _        y r   )r   r   r   r   r3   s       r   r7   z_GlobPatch.__exit__h  s    &&	((
r   Nr8   r   r   r   r   r   R  s    
 
)r   r   c                      t               S r   )r   r   r   r   
patch_globr   m  s
    <r   c                       e Zd Zd Zd Zd Zy)_PatchAllBuiltinsc                 ^    t               | _         t               | _        t               | _        y r   )r=   r   r   r0   s    r   r.   z_PatchAllBuiltins.__init__r  s    $,"4"6$,r   c                     | j                   j                          | j                  j                          | j                  j                          y r   )r=   r1   r   r   r0   s    r   r1   z_PatchAllBuiltins.__enter__w  s7    !!#))+!!#r   c                     | j                   j                  |||       | j                  j                  |||       | j                  j                  |||       y r   )r=   r7   r   r   r3   s       r   r7   z_PatchAllBuiltins.__exit__}  sF      9i@((9iH  9i@r   Nr8   r   r   r   r   r   q  s    '
Ar   r   c                      t               S 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!   r=   rA   rE   rK   rO   rV   r[   r_   rh   rm   ro   rq   rs   rv   rx   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   