
    F\hw                     6   S r SSKrSSKrSSKrSSKrSSKrSSKr SSKrCSr SSK
r
C
Sr SSKrCSr\R                  S:H  rS=rr\R                  S:X  a  SSKrO\(       a  SSKr\R$                  S:X  a  SSKrOSr\(       a  SOS	r\" \S
5      =(       a    \R$                  R-                  S5      q\=(       a	    \" \S5      rSr/ SQr " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r  " S S\!5      r" " S S\!5      r#S r$S r%\4S jr&SsS  jr'S! r(S" r)S# r*SS$.S% jr+SS$.S& jr,\" \S'5      (       a  SS$.S( jr-OS) r-SS$.S* jr.SS$.S+ jr/SS$.S, jr0S- r1 StS. jr2SS\0SS4S/ jr3\" \Rh                  S05      (       a  S1 r5OS2 r5S3 r6S4 r7\Rp                  \R                  \Rr                  \Rt                  1\Rv                  :*  =(       a9    \Rx                  \Rz                  ;   =(       a    \R                  \R|                  ;   r?SuSSS5.S6 jjr@\?\@lA        S7 rB\04S8 jrCS9 rDS: rES; rFS< rG  SvS= jrH  SwS> jrIS\HlJ        S\IlJ        S?\HS@/SA40rK\(       a  \HSB/SC4\KSD'   \I/ SE4\KSF'   \(       a	  \HSG/SH4\KSI'   \(       a	  \HSJ/SK4\KSL'   SM rLSxSN jrMSO rN  SySP jrOSQ rPSR rQ  SxSS jrRST rSSU rTSV rUSSW.SX jrVSY/\V/ SA4SZ/\U/ SE4S[.rW\(       a  S\S]/\V/ SC4\WSD'   \(       a  S^S_/\V/ SH4\WSI'   \(       a  S`Sa/\V/ SK4\WSL'   Sb rXSzSSW.Sc jjrY\" \Sd5      (       a[  \R                  Se5        \R                  " SfSg5      r\Sh\\R                  l         Si\\R                  l         Sj\\R                  l         Sk r`O.\(       a'  \R                  Se5        \R                  " SfSg5      r\Sl r`SzSSSm.Sn jjraS{So jrbSp rcSq rd\R                  \R                  -  S4Sr jrgg! \	 a    Sr GNf = f! \	 a    Sr GNf = f! \	 a    Sr GNf = f)|zUtility functions for copying and archiving files and directory trees.

XXX The functions here don't copy the resource fork or other metadata on Mac.

    NTFntposixwin32i   i   sendfile)linuxandroid
_fcopyfilez%.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC)copyfileobjcopyfilecopymodecopystatcopycopy2copytreemovermtreeErrorSpecialFileError	ExecErrormake_archiveget_archive_formatsregister_archive_formatunregister_archive_formatget_unpack_formatsregister_unpack_formatunregister_unpack_formatunpack_archiveignore_patternschownwhichget_terminal_sizeSameFileErrorc                       \ rS rSrSrg)r   C    N)__name__
__module____qualname____firstlineno____static_attributes__r%       /usr/lib/python3.13/shutil.pyr   r   C   s    r+   r   c                       \ rS rSrSrSrg)r"   F   z5Raised when source and destination are the same file.r%   Nr&   r'   r(   r)   __doc__r*   r%   r+   r,   r"   r"   F   s    ?r+   r"   c                       \ rS rSrSrSrg)r   I   zxRaised when trying to do a kind of operation (e.g. copying) which is
not supported on a special file (e.g. a named pipe)r%   Nr/   r%   r+   r,   r   r   I   s    ;r+   r   c                       \ rS rSrSrSrg)r   M   z+Raised when a command could not be executedr%   Nr/   r%   r+   r,   r   r   M   s    5r+   r   c                       \ rS rSrSrSrg)	ReadErrorP   z%Raised when an archive cannot be readr%   Nr/   r%   r+   r,   r6   r6   P   s    /r+   r6   c                       \ rS rSrSrSrg)RegistryErrorS   zRRaised when a registry operation with the archiving
and unpacking registries failsr%   Nr/   r%   r+   r,   r9   r9   S   s    &r+   r9   c                       \ rS rSrSrSrg)_GiveupOnFastCopyW   zmRaised as a signal to fallback on using raw read()/write()
file copy when fast-copy functions fail to do so.
r%   Nr/   r%   r+   r,   r<   r<   W   s    r+   r<   c                     U R                  5       nUR                  5       n [        R                  " X4U5        g! [         a  n[        U5      eSnAff = f! [
         ac  nU R                  Ul        UR                  Ul        UR                  [        R                  [        R                  1;   a  [        U5      eUSeSnAff = f)z`Copy a regular file content or metadata by using high-performance
fcopyfile(3) syscall (macOS).
N)fileno	Exceptionr<   r   r	   OSErrornamefilename	filename2errnoEINVALENOTSUP)fsrcfdstflagsinfdoutfderrs         r,   _fastcopy_fcopyfilerN   \   s    %{{} e,	  %$$%
   yy		99u}}55#C((4 s-    ; A 
AAA
C"AC  Cc                     U R                  5       nUR                  5       n [        [        R
                  " U5      R                  S5      n[        R                  S:  a  [        US5      nSn  [        R                  " X2Xe5      nUS:X  a  gXg-  nM%  ! [         a  n[        U5      eSnAff = f! [         a    Sn Nsf = f! [         a  nU R                  Ul        UR                  Ul        UR                  [        R                   :X  a  Sq[        U5      eUR                  [        R$                  :X  a  USeUS:X  a5  [        R&                  " US[        R(                  5      S:X  a  [        U5      eUeSnAff = f)zCopy data from one regular mmap-like fd to another by using
high-performance sendfile(2) syscall.
This should work on Linux >= 2.6.33 only.
Ni   i   l        i   @r   F)r?   r@   r<   maxosfstatst_sizerA   sysmaxsizeminr   rB   rC   rD   rE   ENOTSOCK_USE_CP_SENDFILEENOSPClseekSEEK_CUR)rH   rI   rK   rL   rM   	blocksizeoffsetsents           r,   _fastcopy_sendfiler_   p   sP   %{{}..8	
 {{W	7+	F
	;;uF>D, qyNF5 %  %$$%  	  	99CL IICMyyENN* $) ',,yyELL(t# {rxxq"++>!C',,I'	sA    B *B2 1C 
B/B**B/2C C
E>B+E99E>c                     U R                   nUR                  n[        [        U5      5       n U" U5      nU(       d  O&Xb:  a  USU  nU" U5        SSS5        O
U" U5        M6  SSS5        g! , (       d  f       N"= f! , (       d  f       g= f)zreadinto()/memoryview() based variant of copyfileobj().
*fsrc* must support readinto() method and both files must be
open in binary mode.
N)readintowrite
memoryview	bytearray)rH   rI   lengthfsrc_readinto
fdst_writemvnsmvs           r,   _copyfileobj_readintork      s|     MMMJ	If%	&"b!AVssO 2  
'	& V 
'	&s#   A?		A.A?.
A<	8A??
Bc                     U(       d  [         nU R                  nUR                  nU" U5      =n(       a  U" U5        U" U5      =n(       a  M  gg)z=copy data from file-like object fsrc to file-like object fdstN)COPY_BUFSIZEreadrb   )rH   rI   re   	fsrc_readrg   bufs         r,   r
   r
      sH    		IJ6"
"#
"3 6"
"#
"
"r+   c                    [        U [        R                  5      (       ab  [        [        R                  S5      (       aC   [        R                  R                  U R                  5       [        R                  " U5      5      $ [        [        R                  S5      (       a    [        R                  R                  X5      $ [        R                  R                  [        R                  R                  U 5      5      [        R                  R                  [        R                  R                  U5      5      :H  $ ! [         a     gf = f! [         a     gf = f)NsamestatFsamefile)
isinstancerQ   DirEntryhasattrpathrr   statrA   rs   normcaseabspathsrcdsts     r,   	_samefiler~      s    #r{{##(D(D	77##CHHJ== rww
##	77##C--
 GGRWW__S12GGRWW__S123 4  		  		s%    AD: "E
 :
EE

EEc                     [        U [        R                  5      (       a  U R                  5       $ [        R                  " U 5      $ N)rt   rQ   ru   rx   fns    r,   _statr      s+    "2r{{332779DDr+   c                     [        U [        R                  5      (       a  U R                  5       $ [        R                  R                  U 5      $ r   )rt   rQ   ru   
is_symlinkrw   islinkr   s    r,   _islinkr      s0    (R[[992==?Qrww~~b?QQr+   follow_symlinksc          
      B   [         R                  " SX5        [        X5      (       a  [        SR	                  X5      5      eSn[        X/5       H  u  pE [        U5      n[        R                  " UR                  5      (       a;  [        U[        R                  5      (       a  UR                  OUn[        SU-  5      e[        (       a  US:X  a  UR                   nM  M  M     U(       d=  [%        U 5      (       a-  [        R&                  " [        R(                  " U 5      U5        U$ [+        U S5       n [+        US5       n[,        (       a/   [/        Xx[0        R2                  5        UsSSS5        sSSS5        $ [6        (       a    [9        Xx5        UsSSS5        sSSS5        $ [        (       a4  US:  a.  [;        Xx[=        U[>        5      5        UsSSS5        sSSS5        $ [A        Xx5        SSS5        SSS5        U$ ! ["         a     GM  f = f! [4         a     N;f = f! [4         a     NKf = f! , (       d  f       NJ= f! [B         a9  n	[        R                  RE                  U5      (       d  [G        SU 35      U	ee Sn	A	ff = f! , (       d  f       U$ = f)	zCopy data from src to dst in the most efficient way possible.

If follow_symlinks is not set and src is a symbolic link, a new
symlink will be created instead of copying the file it points to.

zshutil.copyfilez{!r} and {!r} are the same filer   z`%s` is a named piperbwbNzDirectory does not exist: )$rT   auditr~   r"   format	enumerater   rx   S_ISFIFOst_modert   rQ   ru   rw   r   _WINDOWSrS   rA   r   symlinkreadlinkopen_HAS_FCOPYFILErN   r   _COPYFILE_DATAr<   rX   r_   rk   rV   rm   r
   IsADirectoryErrorexistsFileNotFoundError)
r|   r}   r   	file_sizeir   strH   rI   es
             r,   r   r      s-    II*=DDSNOOIC:&	'rB }}RZZ(( *2r{{ ; ;RWW&'='BCCxAFJJ	 #x ' ws||


2;;s#S)D JA #t_#t_%~!/E<P<PQ#& %_ _ *)!.t:#& %_ _& "i!m-d#i:VW"' %_ _.  ++ % @ J]  		,  1 ! !  1 ! ! %_0 % ww~~c**+.H,NOUVV	5 _@ Js   H6J8I	H8H,	I	?H8H(	I	*,H8	I	)H84I	
HH
H%"H8$H%%H8(
H52H84H55H88
I	I	JI		
J4JJJ
Jc                   [         R                  " SX5        U(       dj  [        U 5      (       aZ  [        R                  R                  U5      (       a6  [        [        S5      (       a   [        R                  [        R                  pCOSg[        n[        R                  S:X  a(  [        R                  R                  U5      (       a  S nO[        R                  nU" U 5      nU" U[        R                  " UR                  5      5        g)zCopy mode bits from src to dst.

If follow_symlinks is not set, symlinks aren't followed if and only
if both `src` and `dst` are symlinks.  If `lchmod` isn't available
(e.g. Linux) this method does nothing.

zshutil.copymodelchmodNr   c                  0    [         R                  " U SS06  g )Nr   T)rQ   chmodargss    r,   
chmod_funccopymode.<locals>.chmod_func8  s    $55r+   )rT   r   r   rQ   rw   r   rv   lstatr   r   rB   r   rx   S_IMODEr   )r|   r}   r   	stat_funcr   r   s         r,   r   r   &  s     II*ws||s0C0C2x  $&HHbiiz	77d?rww~~c226 J	3BsDLL,-r+   	listxattrc                (    [         R                  " XS9nU H.  n [         R                  " XUS9n[         R                  " XXbS9  M0     g! [         aH  nUR                  [        R                  [        R
                  [        R                  4;  a  e  SnAgSnAff = f! [         ag  nUR                  [        R                  [        R                  [        R
                  [        R                  [        R                  4;  a  e  SnAM  SnAff = f)zCopy extended filesystem attributes from `src` to `dst`.

Overwrite existing attributes.

If `follow_symlinks` is false, symlinks won't be followed.

r   N)rQ   r   rA   rE   rG   ENODATArF   getxattrsetxattrEPERMEACCES)r|   r}   r   namesr   rB   values          r,   
_copyxattrr   A  s    	LLFE
 DCOCuN 	  	wwu}}emmU\\JJ	  775;;u}}#(<<#? ??s/   A *B 
B>BB 
D*ADDc                      g r   r%   )r   kwargss     r,   r   r   Y      r+   c                8  ^	 [         R                  " SX5        SSS.S jm	U=(       d6    [        U 5      =(       a    [        R                  R                  U5      (       + nU(       a  U	4S jnOU	4S jn[        U [        R                  5      (       a  U R                  US9nOU" S5      " XS9n[        R                  " UR                  5      nU" S	5      " XR                  UR                  4US9  [        XUS9   U" S
5      " XUS9  [        US5      (       a   U" S5      " XR                   US9  gg! [         a     N7f = f! ["         aJ  nS H>  n[        [$        U5      (       d  M  UR$                  ['        [$        U5      :X  d  M:     SnAg   e SnAff = f)a  Copy file metadata

Copy the permission bits, last access time, last modification time, and
flags from `src` to `dst`. On Linux, copystat() also copies the "extended
attributes" where possible. The file contents, owner, and group are
unaffected. `src` and `dst` are path-like objects or path names given as
strings.

If the optional flag `follow_symlinks` is not set, symlinks aren't
followed if and only if both `src` and `dst` are symlinks.
zshutil.copystatN)nsr   c                     g r   r%   )r   r   r   s      r,   _nopcopystat.<locals>._nopj  r   r+   c                 &   > [        [        U T5      $ r   )getattrrQ   )rB   r   s    r,   lookupcopystat.<locals>.lookupq  s    2tT**r+   c                 V   > [        [        U T5      nU[        R                  ;   a  U$ T$ r   )r   rQ   supports_follow_symlinks)rB   r   r   s     r,   r   r   v  s)    T4(BR000	Kr+   r   rx   utimer   st_flagschflags)
EOPNOTSUPPrG   )rT   r   r   rQ   rw   r   rt   ru   rx   r   r   st_atime_nsst_mtime_nsr   NotImplementedErrorrv   r   rA   rE   r   )
r|   r}   r   followr   r   modewhyrM   r   s
            @r,   r   r   \  sT    II*T  JWS\%IbggnnS6I JF	+
	 #r{{##XXfX-F^C8<<

#D
7OC^^R^^<  s0w6: r:	9c;;G    	  	.5#&&399s8K+K / 	s<   =D5 E 5
EE
FF+FFFFc                    [         R                  R                  U5      (       a=  [         R                  R                  U[         R                  R	                  U 5      5      n[        XUS9  [        XUS9  U$ )a  Copy data and mode bits ("cp src dst"). Return the file's destination.

The destination may be a directory.

If follow_symlinks is false, symlinks won't be followed. This
resembles GNU's "cp -P src dst".

If source and destination are the same file, a SameFileError will be
raised.

r   )rQ   rw   isdirjoinbasenamer   r   )r|   r}   r   s      r,   r   r     sS     
ww}}Sggll3 0 0 56S7S7Jr+   c                   [         R                  R                  U5      (       a=  [         R                  R                  U[         R                  R	                  U 5      5      n[        [        S5      (       ap  [         R                  " U 5      n[         R                  " U5      n[        R                  nU(       d  U[        R                  -  n [        R                  " X4U5        U$ [        XUS9  [!        XUS9  U$ ! [         aS  nUR                  [        R                  :X  a  U(       d   SnANJUR                  [        R                  :X  a   SnANme SnAff = f)a  Copy data and metadata. Return the file's destination.

Metadata is copied with copystat(). Please see the copystat function
for more information.

The destination may be a directory.

If follow_symlinks is false, symlinks won't be followed. This
resembles GNU's "cp -P src dst".
	CopyFile2Nr   )rQ   rw   r   r   r   rv   _winapifsdecode%COPY_FILE_ALLOW_DECRYPTED_DESTINATIONCOPY_FILE_COPY_SYMLINKr   rA   winerrorERROR_PRIVILEGE_NOT_HELDERROR_ACCESS_DENIEDr   r   )r|   r}   r   src_dst_rJ   excs          r,   r   r     s     
ww}}Sggll3 0 0 56w$${{3{{3==W333E	d%0J S7S7J  	 @ @@' !<!<< 	s$   C= =
E%E1EEEc                     ^  U 4S jnU$ )zFunction that can be used as copytree() ignore parameter.

Patterns is a sequence of glob-style patterns
that are used to exclude filesc                 z   > / nT H(  nUR                  [        R                  " X5      5        M*     [        U5      $ r   )extendfnmatchfilterset)rw   r   ignored_namespatternpatternss       r,   _ignore_patterns)ignore_patterns.<locals>._ignore_patterns  s4    G  !?@  =!!r+   r%   )r   r   s   ` r,   r   r     s    
"
 r+   c           
         Ub8  U" [         R                  " U5      U  Vs/ s H  oR                  PM     sn5      n	OSn	[         R                  " X'S9  / n
U[        L =(       d    U[
        L nU  GH  nUR                  U	;   a  M  [         R                  R                  XR                  5      n[         R                  R                  X,R                  5      nU(       a  UOUn UR                  5       nU(       aC  [         R                  S:X  a/  UR                  SS9nUR                  [        R                  :X  a  SnU(       a  [         R                  " U5      nU(       a)  [         R                  " UU5        [        XU(       + S9  GM  [         R                  R                  U5      (       d
  U(       a  GMI  UR!                  5       (       a  [#        XX4XVU5        GMo  U" X5        GMz  UR!                  5       (       a  [#        XX4UXg5        GM  U" X5        GM      [        X5        U
(       a  [%        U
5      eU$ s  snf ! [$         a*  nU
R'                  UR(                  S   5         S nAGM  S nAf[*         a(  nU
R-                  X[/        U5      45         S nAGM1  S nAff = f! [*         a4  n[1        USS 5      c  U
R-                  X[/        U5      45         S nANS nAff = f)Nr%   )exist_okr   Fr   r   r   )rQ   fspathrB   makedirsr   r   rw   r   r   rx   st_reparse_tagIO_REPARSE_TAG_MOUNT_POINTr   r   r   r   is_dirr   r   r   r   rA   appendstrr   )entriesr|   r}   symlinksignorecopy_functionignore_dangling_symlinksdirs_exist_okxr   errorsuse_srcentrysrcentrysrcnamedstnamesrcobjr   r   linktorM   r   s                        r,   	_copytreer     s8   ryy~/H1/HIKK,F E)B]d-BL==M)'',,sMM2'',,sMM2)w&	8!,,.Jbggo !e<''4+J+JJ!&JW- JJvw/V(lK 77>>&116N (( (!.!.0 &f6""(M1B f.M Z0
 FmJ{ 0Ib  	'MM#((1+&& 	8MM7SX677	8  03
D)1MM3SX./0s`   H:
!B$H?+H?6#H?H?'#H?H?J& ?
J#	I..J#;JJ#&
K$0*KK$c                     [         R                  " SX5        [        R                  " U 5       n[	        U5      nSSS5        [        WXUX4UUS9$ ! , (       d  f       N= f)a  Recursively copy a directory tree and return the destination directory.

If exception(s) occur, an Error is raised with a list of reasons.

If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
links are copied. If the file pointed to by the symlink doesn't
exist, an exception will be added in the list of errors raised in
an Error exception at the end of the copy process.

You can set the optional ignore_dangling_symlinks flag to true if you
want to silence this exception. Notice that this has no effect on
platforms that don't support os.symlink.

The optional ignore argument is a callable. If given, it
is called with the `src` parameter, which is the directory
being visited by copytree(), and `names` which is the list of
`src` contents, as returned by os.listdir():

    callable(src, names) -> ignored_names

Since copytree() is called recursively, the callable will be
called once for each directory that is copied. It returns a
list of names relative to the `src` directory that should
not be copied.

The optional copy_function argument is a callable that will be used
to copy each file. It will be called with the source path and the
destination path as arguments. By default, copy2() is used, but any
function that supports the same signature (like copy()) can be used.

If dirs_exist_ok is false (the default) and `dst` already exists, a
`FileExistsError` is raised. If `dirs_exist_ok` is true, the copying
operation will continue if it encounters existing directories, and files
within the `dst` tree will be overwritten by corresponding files from the
`src` tree.
zshutil.copytreeN)r   r|   r}   r   r   r   r   r   )rT   r   rQ   scandirlistr   )	r|   r}   r   r   r   r   r   itrr   s	            r,   r   r   &  sS    P II*	CCs) 
W#".F#02 2 
s   A
Ast_file_attributesc                     [         R                  " U R                  5      =(       dA    U R                  [         R                  -  =(       a    U R
                  [         R                  :H  $ r   )rx   S_ISLNKr   r  FILE_ATTRIBUTE_REPARSE_POINTr   r   r   s    r,   _rmtree_islinkr  W  sL    RZZ( J""T%F%FF I%%)H)HH	Kr+   c                 B    [         R                  " U R                  5      $ r   )rx   r  r   r  s    r,   r  r  \  s    ||BJJ''r+   c                   ^ U4S jn[         R                  " U SU[         R                  S9nU H  u  pEnU H9  n[         R                  R	                  XG5      n [         R
                  " U5        M;     U H9  n[         R                  R	                  XG5      n [         R                  " U5        M;     M      [         R
                  " U 5        g ! [         a     M  [         a"  n	T" [         R
                  X5         S n	A	M  S n	A	ff = f! [         a     M  [         a"  n	T" [         R                  X5         S n	A	M  S n	A	ff = f! [         a     g [         a!  n	T" [         R
                  X	5         S n	A	g S n	A	ff = f)Nc                 v   > [        U [        5      (       d#  T" [        R                  U R                  U 5        g g r   )rt   r   rQ   r   rC   )rM   onexcs    r,   onerror_rmtree_unsafe.<locals>.onerrora  s*    #011"**cllC0 2r+   F)topdownr  followlinks)	rQ   walk_walk_symlinks_as_filesrw   r   rmdirr   rA   unlink)
rw   r  r  resultsdirpathdirnames	filenamesrB   fullnamerM   s
    `        r,   _rmtree_unsafer  `  s'   1 ggdE7HbHbcG(/$9Dww||G2H/"  Dww||G2H0		(#  )0"#
 %  /bhh../ %  0bii//0   #bhh""#sZ   CD
8E 
D	D%DD

E	E D==E
E;	E;E66E;c                    U R                  5       u  p#pEUc  UOUR                  n U[        R                  L a  [        R                  " U5        g U[        R                  L a  [        R                  " XcS9  g U[        R
                  L d   eUc  [        R
                  " XcS9nOUR                  SS9n[        R                  n[        R                  " U[        R                  [        R                  -  US9n[        R                  R                  n [        R                  R                  U[        R                  " U5      5      (       d  [        S5      eU R                  [        R                  X4U45        U R                  [        R                  XU45        [        R                   n[        R                   " U5       n	[#        U	5      n
S S S 5        W
 H  n[        R                  R%                  XKR                  5      n UR'                  SS9(       a$  U R                  [        R
                  XU45        Me    [        R*                  " UR                  US9  M     g ! U R                  [        R                  XU45        f = f! , (       d  f       N= f! [(         a     M  [         a     Nuf = f! [(         a     M  [         a#  nU" [        R*                  X5         S nAGM  S nAff = f! [(         a4  nUb  U[        R                  L a  XMl        U" X$U5         S nAg  S nAg S nAf[         a  nXMl        U" X$U5         S nAg S nAff = f)N)dir_fdFr   %Cannot call rmtree on a symbolic link)poprB   rQ   closer  r   rx   r   O_RDONLY
O_NONBLOCKrw   r   rr   rR   rA   r   r   r  r   r   r   r  rC   )stackr  funcdirfdrw   
orig_entryrB   orig_sttopfd
scandir_itr   entryr  rM   s                 r,   _rmtree_safe_fdr*  ~  s{    %*IIK!D%4:??D6288HHUO288HHT( rxxhht2G ooeo<GwwbkkBMM9%Hww~~	>77##GRXXe_==EFFLL"((E<=LL"((E<=zzZZ*:&G Eww||D**5H<<<6LL"((EU!CD 70		%**U3  LL"((E<=  %   %  0bii//0 #!1L$c"" "2  d#s   )K3 'K3 8BK3 A&I# :AK3 J
6K3 6J;K3 ?J7K3 #$JK3 

JK3 
J4%K3 (	J41K3 3J44K3 7
K0K3 	K0K+$K3 +K00K3 3
M=%L,,M9MM)r  r  c                  ^ [         R                  " SX5        U(       a  S nOTc  Uc  S nOUc  Tc  S nOU4S jn[        (       a  [        U [        5      (       a  [
        R                  " U 5      n [
        R                  X@S4/n U(       a  [        XS5        U(       a  M  U(       aI  UR                  5       u  pgpU[
        R                  La  M/   [
        R                  " U5        U(       a  MH  ggUb  [        S5      e [
        R                  " U 5      n
 [        U
5      (       a  [        S5      e [!        X5      $ ! [         a!  n	U" [
        R                  X	5         Sn	A	N~Sn	A	ff = f! U(       ax  UR                  5       u  pgpU[
        R                  La  M/   [
        R                  " U5        O.! [         a!  n	U" [
        R                  X	5         Sn	A	OSn	A	ff = fU(       a  Mw  f f = f! [         a!  n	U" [
        R                  X	5         Sn	A	gSn	A	ff = f! [         a+  n	U" [
        R                  R                  X	5         Sn	A	gSn	A	ff = f)	a  Recursively delete a directory tree.

If dir_fd is not None, it should be a file descriptor open to a directory;
path will then be relative to that directory.
dir_fd may not be implemented on your platform.
If it is unavailable, using it will raise a NotImplementedError.

If ignore_errors is set, errors are ignored; otherwise, if onexc or
onerror is set, it is called to handle the error with arguments (func,
path, exc_info) where func is platform and implementation dependent;
path is the argument to that function that caused it to fail; and
the value of exc_info describes the exception. For onexc it is the
exception instance, and for onerror it is a tuple as returned by
sys.exc_info().  If ignore_errors is false and both onexc and
onerror are None, the exception is reraised.

onerror is deprecated and only remains for backwards compatibility.
If both onerror and onexc are set, onerror is ignored and onexc is used.
zshutil.rmtreec                      g r   r%   r   s    r,   r  rmtree.<locals>.onexc  s    r+   Nc                      e r   r%   r   s    r,   r  r-    s    r+   c                      e r   r%   r   s    r,   r  r-    s    r+   c                  Z   > U u  pnUc  SnO[        U5      X3R                  4nT" XU5      $ )N)NNN)type__traceback__)r   r#  rw   r   exc_infor  s        r,   r  r-    s7    "&C;/H#Cy#/@/@@Ht844r+   z#dir_fd unavailable on this platformr  )rT   r   _use_fd_functionsrt   bytesrQ   r   r   r*  r  r  rA   r   r  rw   r   r  )rw   ignore_errorsr  r  r  r"  r#  fdr)  rM   r   s     `        r,   r   r     s   * IIot,		U]		?5 dE"";;t$D((F$/0	/- % (-		%$rxx'/HHRL % %&KLL	$B	b!!EFF " d**%  /"((D../ (-		%$rxx'/HHRL /"((D../ %  	"((D&	  	"''..$,	s   	E0 E G4 H" 
E-E((E-00G1!F87G18
G#GG1G##
G1/G14
H>HH"
I,!IIc                    [         R                  " U 5      n [         R                  R                  [         R                  R                  =(       d    S-   n[         R                  R                  U R                  U5      5      $ )a   A basename() variant which first strips the trailing slash, if present.
Thus we always get the last component of the path, even for directories.

path: Union[PathLike, str]

e.g.
>>> os.path.basename('/bar/foo')
'foo'
>>> os.path.basename('/bar/foo/')
''
>>> _basename('/bar/foo/')
'foo'
 )rQ   r   rw   sepaltsepr   rstrip)rw   r:  s     r,   	_basenamer=    sN     99T?D
''++-2
.C77DKK,--r+   c                    [         R                  " SX5        Un[        R                  R	                  U5      (       a  [        X5      (       a;  [        R                  R                  U 5      (       d  [        R                  " X5        g[        R                  R                  U[        U 5      5      n[        R                  R                  U5      (       a  [        SU-  5      e [        R                  " X5        U$ ! [         Gai    [        R                  R                  U 5      (       aE  [        R                  " U 5      n[        R                  " XC5        [        R                  " U 5         U$ [        R                  R	                  U 5      (       a  [!        X5      (       a  [        SU < SU< S35      e[#        U 5      (       dY  [        R$                  " U [        R&                  5      (       dC  [        R(                  " U 5      (       a(  [         R*                  S:X  a  [-        SU < S	U < S35      e[/        XUS
S9  [1        U 5         U$ U" X5        [        R                  " U 5         U$ f = f)a  Recursively move a file or directory to another location. This is
similar to the Unix "mv" command. Return the file or directory's
destination.

If dst is an existing directory or a symlink to a directory, then src is
moved inside that directory. The destination path in that directory must
not already exist.

If dst already exists but is not a directory, it may be overwritten
depending on os.rename() semantics.

If the destination is on our current filesystem, then rename() is used.
Otherwise, src is copied to the destination and then removed. Symlinks are
recreated under the new name if os.rename() fails because of cross
filesystem renames.

The optional `copy_function` argument is a callable that will be used
to copy the source or it will be delegated to `copytree`.
By default, copy2() is used, but any function that supports the same
signature (like copy()) can be used.

A lot more could be done here...  A look at a mv.c shows a lot of
the issues this implementation glosses over.

zshutil.moveNz$Destination path '%s' already existszCannot move a directory 'z' into itself 'z'.darwinz%Cannot move the non-empty directory 'z ': Lacking write permission to 'T)r   r   )rT   r   rQ   rw   r   r~   r   renamer   r=  r   r   rA   r   r   r  
_destinsrc_is_immutableaccessW_OKlistdirplatformPermissionErrorr   r   )r|   r}   r   real_dstr   s        r,   r   r   .  s   4 IImS&H	ww}}SSrww~~c':': IIc 77<<Ys^477>>(##>IJJ
		# , O+  77>>#[[%FJJv(IIcN" O! WW]]3###(+S2 3 3c""IIc27733

3LLH4%),c'3 4 4 S-"$3K O #(IIcNO+s    %C= =A1I11CI1I10I1c                    [         R                  R                  U 5      n [         R                  R                  U5      nU R                  [         R                  R                  5      (       d  U [         R                  R                  -  n UR                  [         R                  R                  5      (       d  U[         R                  R                  -  nUR                  U 5      $ r   )rQ   rw   rz   endswithr:  
startswithr{   s     r,   rA  rA  p  s    
''//#
C
''//#
C<<$$rww{{<<$$rww{{>>#r+   c                     [        U 5      n[        R                  [        R                  /n[	        US5      =(       a    UR
                  U;   $ )Nr   )r   rx   UF_IMMUTABLESF_IMMUTABLErv   r   )r|   r   immutable_statess      r,   rB  rB  y  s>    	sB))4+<+<=2z"Fr{{6F'FFr+   c                     U c  g SSK Jn   U" U 5      nUb  US   $ g! [         a     gf = f! [         a    Sn N'f = f)z"Returns a gid, given a group name.Nr   )getgrnam   )grprQ  ImportErrorKeyError)rB   rQ  results      r,   _get_gidrW  ~  ^    | $ ay  
      . 
++==c                     U c  g SSK Jn   U" U 5      nUb  US   $ g! [         a     gf = f! [         a    Sn N'f = f)z"Returns an uid, given a user name.Nr   )getpwnamrR  )pwdr[  rT  rU  )rB   r[  rV  s      r,   _get_uidr]    rX  rY  c	                   ^^^^ Uc  Sn	OV[         (       a	  US:X  a  Sn	OB[        (       a	  US:X  a  Sn	O.[        (       a	  US:X  a  Sn	O[        SR	                  U5      5      eS	SKn
U(       a  S
U	-   OSnU S-   U-   n[        R                  R                  U5      nU(       aV  [        R                  R                  U5      (       d2  Ub  UR                  SU5        U(       d  [        R                  " U5        Ub  UR                  S5        [        T5      m[        T5      mUUUU4S jnU(       d[  U
R                  USU	-  5      nUnUb  [        R                  R                  X5      n UR!                  UUUS9  UR#                  5         Ub  [        R                  R%                  U5      nU$ ! UR#                  5         f = f)a  Create a (possibly compressed) tar file from all the files under
'base_dir'.

'compress' must be "gzip" (the default), "bzip2", "xz", or None.

'owner' and 'group' can be used to define an owner and a group for the
archive that is being built. If not provided, the current owner and group
will be used.

The output tar file will be named 'base_name' +  ".tar", possibly plus
the appropriate compression extension (".gz", ".bz2", or ".xz").

Returns the output filename.
Nr9  gzipgzbzip2bz2xzzCbad value for 'compress', or compression format not supported : {0}r   ..tarcreating %szCreating tar archivec                 L   > Tb  TU l         TU l        Tb  TU l        TU l        U $ r   )gidgnameuiduname)tarinforh  groupownerrj  s    r,   _set_uid_gid#_make_tarball.<locals>._set_uid_gid  s.    ?GK!GM?GK!GMr+   zw|%sr   )_ZLIB_SUPPORTED_BZ2_SUPPORTED_LZMA_SUPPORTED
ValueErrorr   tarfilerQ   rw   dirnamer   infor   r]  rW  r   r   addr  rz   )	base_namebase_dircompressverbosedry_runrn  rm  loggerroot_dirtar_compressionrv  compress_extarchive_namearchive_dirro  tararcnamerh  rj  s        ``          @@r,   _make_tarballr    s~     	X/	H/	X- ++16(+;= 	= ,43("Lv%4L''//,/K277>>+66KK{3KK$ *+
5/C
5/C  ll</)ABww||H7H	GGHglG;IIKww|4	 IIKs   +F0 0Gc                 \   SSK nU S-   n	[        R                  R                  U 5      n
U
(       aV  [        R                  R	                  U
5      (       d2  Ub  UR                  SU
5        U(       d  [        R                  " U
5        Ub  UR                  SX5        U(       GdV  UR                  U	SUR                  S9 n[        R                  R                  U5      nUb  [        R                  R                  Xq5      n[        R                  R                  U5      nU[        R                  :w  a&  UR                  X5        Ub  UR                  SU5        [        R                  " U5       GH}  u  pnUnUb   [        R                  R                  UU5      n[        R                  R                  U5      n[        U5       Hl  n[        R                  R                  UU5      n[        R                  R                  UU5      nUR                  UU5        Uc  MZ  UR                  SU5        Mn     U H  n[        R                  R                  UU5      n[        R                  R                  U5      n[        R                  R!                  U5      (       d  Mh  [        R                  R                  UU5      nUR                  UU5        Uc  M  UR                  SU5        M     GM     SSS5        Ub  [        R                  R#                  U	5      n	U	$ ! , (       d  f       N2= f)	zCreate a zip file from all the files under 'base_dir'.

The output zip file will be named 'base_name' + ".zip".  Returns the
name of the output zip file.
r   N.ziprf  z#creating '%s' and adding '%s' to itw)compressionzadding '%s')zipfilerQ   rw   rw  r   rx  r   ZipFileZIP_DEFLATEDnormpathr   curdirrb   r  relpathsortedisfilerz   )rz  r{  r}  r~  r  rn  rm  r  r  zip_filenamer  zfr  r  r  r  
arcdirpathrB   rw   s                      r,   _make_zipfiler    sX    v%L''//),K277>>+66KK{3KK$9 	, __\3)0)=)=  ?BDgg&&x0G#77<<;ww''1H"))#+%KKx8020A,9$
'!#X!FJWW--j9
"8,D77<<6D ggll:t<GHHT7+)M48 - &D77<<6D77++D1Dww~~d++"$'',,z4"@w/!-"KKt< & 1B?< ww|4A? ?s    >ELA<L3LL
L+r  )r|  Nzuncompressed tar file)r|  r_  zgzip'ed tar-filegztarzZIP filezip)r|  ra  zbzip2'ed tar-filebztar)r|  rc  zxz'ed tar-filexztarc                      [         R                  5        V Vs/ s H  u  pXS   4PM     nn nUR                  5         U$ s  snn f )zReturns a list of supported formats for archiving and unarchiving.

Each element of the returned sequence is a tuple (name, description)
rR  )_ARCHIVE_FORMATSitemssort)rB   registryformatss      r,   r   r   :  sI      %%')' (6tqk"'  )LLNN)s   ?c                 (   Uc  / n[        U5      (       d  [        SU-  5      e[        U[        [        45      (       d  [        S5      eU H8  n[        U[        [        45      (       a  [        U5      S:w  d  M/  [        S5      e   XU4[        U '   g)a]  Registers an archive format.

name is the name of the format. function is the callable that will be
used to create archives. If provided, extra_args is a sequence of
(name, value) tuples that will be passed as arguments to the callable.
description can be provided to describe the format, and will be returned
by the get_archive_formats() function.
NzThe %s object is not callablez!extra_args needs to be a sequencerR  z+extra_args elements are : (arg_name, value))callable	TypeErrorrt   tupler  lenr  )rB   function
extra_argsdescriptionelements        r,   r   r   D  s     
H7(BCCj5$-00;<<'E4=11S\A5EIJJ  'K@Tr+   c                     [         U 	 g r   )r  rB   s    r,   r   r   Y  s
    r+   c	                    [         R                  " SXX#5         [        U   n	XXXgS.n
U	S   nU	S    H	  u  pXU'   M     Uc  [
        R                  n[        USS5      nSnUb  [
        R                  " U5      R                  n[        R                  " U5      (       d  [        [        R                  S	U5      eU(       a  [
        R                  " U 5      n X*S
'   Of[
        R                  " 5       nUb  UR!                  SU5        [
        R"                  R%                  U 5      n U(       d  [
        R&                  " U5         U" X40 U
D6nUb+  Ub  UR!                  SU5        [
        R&                  " U5        U$ ! [         a    [	        SU-  5      Sef = f! Ub,  Ub  UR!                  SU5        [
        R&                  " U5        f f = f)a  Create an archive file (eg. zip or tar).

'base_name' is the name of the file to create, minus any format-specific
extension; 'format' is the archive format: one of "zip", "tar", "gztar",
"bztar", or "xztar".  Or any other registered format.

'root_dir' is a directory that will be the root directory of the
archive; ie. we typically chdir into 'root_dir' before creating the
archive.  'base_dir' is the directory where we start archiving from;
ie. 'base_dir' will be the common prefix of all files and
directories in the archive.  'root_dir' and 'base_dir' both default
to the current directory.  Returns the name of the archive file.

'owner' and 'group' are used when creating a tar archive. By default,
uses the current owner and group.
zshutil.make_archivezunknown archive format '%s'N)r~  r  rn  rm  r      supports_root_dirFzNot a directoryr  zchanging into '%s'zchanging back to '%s')rT   r   r  rU  ru  rQ   r  r   rx   r   S_ISDIRNotADirectoryErrorrE   ENOTDIRr   getcwddebugrw   rz   chdir)rz  r   r  r{  r}  r~  rn  rm  r  format_infor   r#  argvalr  save_cwdstmdrC   s                     r,   r   r   \  s   $ II#YKK&v. !.F q>DNs # 99&95AHwwx ((||D!!$U]]4ExPP		),I!):yy{H!18<	2I"	6v6!4h?HHXOQ  K6?@dJKF !4h?HHX  s   	E< 	F <F1G
c                      [         R                  5        V Vs/ s H  u  pXS   US   4PM     nn nUR                  5         U$ s  snn f )zReturns a list of supported formats for unpacking.

Each element of the returned sequence is a tuple
(name, extensions, description)
r      )_UNPACK_FORMATSr  r  )rB   rx  r  s      r,   r   r     sO     $$&(& -7D1gtAw'&  (LLNN(s   Ac                     0 n[         R                  5        H  u  pEUS    H  nXCU'   M	     M     U  H  nXs;   d  M
  Sn[        XX7   4-  5      e   [        U5      (       d  [	        S5      eg)z+Checks what gets registered as an unpacker.r   z!%s is already registered for "%s"z*The registered function must be a callableN)r  r  r9   r  r  )	
extensionsr  r  existing_extensionsrB   rx  ext	extensionmsgs	            r,   _check_unpack_optionsr    s     %++-
7C'+$  .  	+5C':'E'G !G H H   HDEE r+   c                 <    Uc  / n[        XU5        XX44[        U '   g)a!  Registers an unpack format.

`name` is the name of the format. `extensions` is a list of extensions
corresponding to the format.

`function` is the callable that will be
used to unpack archives. The callable will receive archives to unpack.
If it's unable to handle an archive, it needs to raise a ReadError
exception.

If provided, `extra_args` is a sequence of
(name, value) tuples that will be passed as arguments to the callable.
description can be provided to describe the format, and will be returned
by the get_unpack_formats() function.
N)r  r  )rB   r  r  r  r  s        r,   r   r     s(    " 
*
;&*IODr+   c                     [         U 	 g)z*Removes the pack format from the registry.N)r  r  s    r,   r   r     s
    r+   c                     [         R                  R                  U 5      n[         R                  R                  U5      (       d  [         R                  " U5        gg)z1Ensure that the parent directory of `path` existsN)rQ   rw   rw  r   r   )rw   rw  s     r,   _ensure_directoryr    s8    ggood#G77==!!
G "r+   c                    SSK nUR                  U 5      (       d  [        SU -  5      eUR                  U 5      n UR	                  5        H  nUR
                  nUR                  S5      (       d  SU;   a  M-  [        R                  R                  " U/UR                  S5      Q76 nU(       d  Mf  [        U5        UR                  S5      (       a  M  UR                  US5       n[        US5       n[        Xx5        SSS5        SSS5        M     UR                  5         g! , (       d  f       N+= f! , (       d  f       M  = f! UR                  5         f = f)z+Unpack zip `filename` to `extract_dir`
    r   Nz%s is not a zip file/z..rr   )r  
is_zipfiler6   r  infolistrC   rK  rQ   rw   r   splitr  rJ  r   r
   r  )	rC   extract_dirr  r  rx  rB   
targetpathsourcetargets	            r,   _unpack_zipfiler    s    h''.9::
//(
#CLLND==D s##tt|kDDJJsODJj)==%%XXdC(FZ.&/ / )( #$ 			 /. )( 			sB   BE E &D53D$?D5E $
D2.D55
E	?E Erq  c                    SSK n UR                  U 5      n UR	                  XS9  UR                  5         g! UR                   a    [        SU -  5      ef = f! UR                  5         f = f)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir`
    r   Nz/%s is not a compressed or uncompressed tar filerq  )rv  r   TarErrorr6   
extractallr  )rC   r  r   rv  tarobjs        r,   _unpack_tarfiler    sv     Jh'+5  J=HJ 	JJ 	s   8 A AA,re  r  )r  r  z.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzc                     [         R                  5        H-  u  pUS    H  nU R                  U5      (       d  M  Us  s  $    M/     g )Nr   )r  r  rJ  )rC   rB   rx  r  s       r,   _find_unpack_formatr    s@    %++-
aI  ++ ! . r+   c                    [         R                  " SXU5        Uc  [        R                  " 5       n[        R                  " U5      n[        R                  " U 5      n Uc  0 nOSU0nUb'   [
        U   nUS   nU" X40 [        US   5      DUD6  g[        U 5      nUc  [        SR                  U 5      5      e[
        U   S   n[        [
        U   S   5      U-  nU" X40 UD6  g! [         a    [        SR                  U5      5      Sef = f)a1  Unpack an archive.

`filename` is the name of the archive.

`extract_dir` is the name of the target directory, where the archive
is unpacked. If not provided, the current working directory is used.

`format` is the archive format: one of "zip", "tar", "gztar", "bztar",
or "xztar".  Or any other registered format.  If not provided,
unpack_archive will use the filename extension and see if an unpacker
was registered for that extension.

In case none is found, a ValueError is raised.

If `filter` is given, it is passed to the underlying
extraction function.
zshutil.unpack_archiveNr   zUnknown unpack format '{0}'r  rR  zUnknown archive format '{0}')rT   r   rQ   r  r   r  rU  ru  r   dictr  r6   )rC   r  r   r   filter_kwargsr  r#  r   s           r,   r   r   "  s   $ II%xfEiik))K(Kyy"H~!6*	U)&1K 1~XLd;q>&:LmL %X.>:AA(KLLv&q)of-a01MAX-f-  	U:AA&IJPTT	Us   +	C' '&Dstatvfs
disk_usageusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytesc                     [         R                  " U 5      nUR                  UR                  -  nUR                  UR                  -  nUR                  UR
                  -
  UR                  -  n[        X4U5      $ )zReturn disk usage statistics about the given path.

Returned value is a named tuple with attributes 'total', 'used' and
'free', which are the amount of total, used and free space, in bytes.
)rQ   r  f_bavailf_frsizef_blocksf_bfree_ntuple_diskusage)rw   r   freetotaluseds        r,   r  r  [  s^     ZZ{{R[[(bkk)bjj(BKK7 d33r+   c                 R    [         R                  " U 5      u  pX-
  n[        XU5      $ )zReturn disk usage statistics about the given path.

Returned values is a named tuple with attributes 'total', 'used' and
'free', which are the amount of total, used and free space, in bytes.
)r   _getdiskusager  )rw   r  r  r  s       r,   r  r  l  s*     &&t,| d33r+   r  r   c                   [         R                  " SXU5        Uc  Uc  [        S5      eUnUnUc  SnO=[        U[        5      (       a(  [        U5      nUc  [        SR                  U5      5      eUc  SnO=[        U[        5      (       d(  [        U5      nUc  [        SR                  U5      5      e[        R                  " XXcUS9  g)a  Change owner user and group of the given path.

user and group can be the uid/gid or the user/group names, and in that case,
they are converted to their respective uid/gid.

If dir_fd is set, it should be an open file descriptor to the directory to
be used as the root of *path* if it is relative.

If follow_symlinks is set to False and the last element of the path is a
symbolic link, chown will modify the link itself and not the file being
referenced by the link.
zshutil.chownNzuser and/or group must be setzno such user: {!r}zno such group: {!r}r  )rT   r   ru  rt   r   r]  LookupErrorr   intrW  rQ   r   )rw   userrm  r  r   _user_groups          r,   r   r   w  s     IInd%0|899EF |	D#		=299$?@@}s##%>3::5ABBHHT&,.r+   c                 \    [        [        R                  S   5      n [        [        R                  S   5      nUS::  d  US::  ao   [        R
                  " [        R                  R                  5       5      nUS::  a  UR                  =(       d    U S   nUS::  a  UR                  =(       d    U S   n[        R                  " X45      $ ! [        [        4 a    Sn Nf = f! [        [        4 a    Sn Nf = f! [        [        [        4 a    [        R                  " U 5      n Nf = f)a  Get the size of the terminal window.

For each of the two dimensions, the environment variable, COLUMNS
and LINES respectively, is checked. If the variable is defined and
the value is a positive integer, it is used.

When COLUMNS or LINES is not defined, which is the common case,
the terminal connected to sys.__stdout__ is queried
by invoking os.get_terminal_size.

If the terminal size cannot be successfully queried, either because
the system doesn't support querying, or because we are not
connected to a terminal, the value given in fallback parameter
is used. Fallback defaults to (80, 24) which is the default
size used by many terminal emulators.

The value returned is a named tuple of type os.terminal_size.
COLUMNSr   LINESr  )r  rQ   environrU  ru  r!   rT   
__stdout__r?   AttributeErrorrA   terminal_sizecolumnslines)fallbackr  r  sizes       r,   r!   r!     s	   (bjj+,BJJw'(
 !|uz	.''(=(=(?@D
 a<ll1hqkGA:JJ-(1+EW,--+ j! 
 j!  
G4 	. ##H-D	.s4   C C% 2C= C"!C"%C:9C:=+D+*D+c                     [         R                  R                  U 5      =(       aA    [         R                  " X5      =(       a$    [         R                  R	                  U 5      (       + $ r   )rQ   rw   r   rC  r   )r   r   s     r,   _access_checkr     s?    GGNN2 &299R#6 &GGMM"%%'r+   c                     U[         R                  -  (       + =(       d*    [        R                  " [         R                  " U 5      5      $ )z
On Windows, we can use NeedCurrentDirectoryForExePath to figure out
if we should add the cwd to PATH when searching for executables if
the mode is executable.
)rQ   X_OKr   NeedCurrentDirectoryForExePathr   )cmdr   s     r,   _win_path_needs_curdirr    s5       "W%K%KC &" "r+   c                   ^ [        U [        5      n[        R                  R	                  U 5      u  p@U(       a  U/nGO.Uc:  [        R
                  R                  SS5      nUc   [        R                  " S5      nU(       d  gU(       aJ  [        R                  " U5      nUR	                  [        R                  " [        R                  5      5      nO5[        R                  " U5      nUR	                  [        R                  5      n[        R                  S:X  aO  [!        X5      (       a?  [        R"                  nU(       a  [        R                  " U5      nUR%                  SU5        [        R                  S:X  Ga  [        R&                  " S5      =(       d    [(        nUR	                  [        R                  5      nU Vs/ s H  o(       d  M  UR+                  S5      PM     nnU(       a&  U Vs/ s H  n[        R                  " U5      PM     nnU Vs/ s H  oU-   PM	     n	nU R-                  5       mU[        R.                  -  (       a  [1        U4S jU 5       5      (       a  U	R%                  SU 5        OU /n	[3        5       n
U Hx  n[        R                  R5                  U5      nX;  d  M)  U
R7                  U5        U	 H8  n[        R                  R9                  X5      n[;        X5      (       d  M4  Us  s  $    Mz     g! [        [        4 a    [        R                  n GNf = fs  snf s  snf s  snf )	a  Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such
file.

`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
of os.environ.get("PATH"), or can be overridden with a custom search
path.

NPATHCS_PATHr   r   PATHEXTrd  c              3   b   >#    U  H$  nTR                  UR                  5       5      v   M&     g 7fr   )rJ  upper).0r  normcmds     r,   	<genexpr>which.<locals>.<genexpr>  s'     &XPWw'7'7		'D'DPWs   ,/)rt   r5  rQ   rw   r  r  getconfstrr  ru  defpathfsencodepathsepr   rT   rF  r  r  insertgetenv_WIN_DEFAULT_PATHEXTr<  r  r  anyr   ry   ry  r   r   )r  r   rw   	use_bytesrw  r  pathext_sourcepathextr  filesseendirnormdirthefilerB   r  s                  @r,   r    r      sT    3&I
 77==%LGy<::>>&$/D|&::i0D ;;t$D::bkk"**56D;;t$D::bjj)D<<7"'=c'H'HYYFV,KK6"
||w9-E1E &&rzz2.5=gs?3::c?g=3:;7Cr{{3'7G;&-.gssg. ))+rww3&XPW&X#X#XLLC  5D''""3'HHW ww||C1 ,,K !	  q '
3 &::D&8 > <.s*   &L 
L6L68 L;M  L32L3)r   )F)FN)r_  r   r   NNNN)r   r   NNNN)Nr9  )NNr   r   NNN)NN))r7      )hr0   rQ   rT   rx   r   collectionsrE   zlibrr  rT  rb  rs  lzmart  rB   r   r   r   rF  r   rm   rv   rK  rX   r   r  __all__rA   r   r"   r   r   r6   r@   r9   r<   rN   r_   rk   r
   r~   r   r   r   r   r   r   r   r   r   r   r   stat_resultr  r  r*  r   r  r  supports_dir_fdr   supports_fdr   r4  r   avoids_symlink_attacksr=  r   rA  rB  rW  r]  r  r  r  r  r   r   r   r   r   r  r   r   r  r  r  r  r  r   r   
namedtupler  r  r  r  r  r   r!   r   r  F_OKr  r    r%   r+   r,   <module>r,     sO   
 
    ONO 77d? 77g<<7G&{I B
+ F//0DE 775,7 ? 	G 	@E @;w ;6 60 0&I &	 
 (>@ .: (4$ER +/ >@ +/ .4 2{04 0 +/ @D '+ $ (, &P
 7<@D !&d%&+5.2` 2>>/00K
(#<EN ggrww		288<''( <ZZ2>>1< WW ; ;; 
L+T$ L+` !2 .$ "' @DG
$$ LM@DDL ;<@D7r #' "&  
m01%' 
 !.1E0F 2!4W,b*=U!.1F0G 3!5W !.1C0D 0!2WA* KL;?=@	F$ CG')J,< 6: ( h-DEhZ8
 !*F 3_b 2 4OG !+W 5 3 5OG !*F 3_b 0 2OG..d ..b 2yNN< #..w8IJ&<#%:"%:"
4 NN< #..w8IJ4&.t &.P+.b'
" GGbgg%D P[.  O  N  Os3   O. O= P .O:9O:=P	P	PP