QfVdZddlZddlZddlZddlZddlZddlZddlZ ddlZ[dZ ddl Z [ dZ ddl Z [ dZejdk(ZdxZZejdk(rddlZnerddlZej&dk(rddlZndZerdnd Zeed xrej&j/d aexr eed Zd ZgdZGddeZGddeZGddeZGddeZ GddeZ!Gdde"Z#Gdde"Z$dZ%dZ&efdZ'drd Z(d!Z)d"Z*d#Z+dd$d%Z,dd$d&Z-eed'rdd$d(Z.nd)Z.dd$d*Z/dd$d+Z0dd$d,Z1d-Z2 dsd.Z3dde1ddfd/Z4eejjd0rd1Z6nd2Z6d3Z7d4Z8ejrejejtejvhejxkxr2ejzej|vxrejej~vZ@dtddd5d6ZAe@eA_Bd7ZCe1fd8ZDd9ZEd:ZFd;ZGd<ZH dud=ZI dvd>ZJdeI_KdeJ_Kd?eId@gdAfiZLe reIdBgdCfeLdD<eJgdEfeLdF<e r eIdGgdHfeLdI<er eIdJgdKfeLdL<dMZMdwdNZNdOZO dxdPZPdQZQdRZR dwdSZSdTZTdUZUdVZVddWdXZWdYgeWgdAfdZgeVgdEfd[ZXe r d\d]geWgdCfeXdD<e r d^d_geWgdHfeXdI<er d`dageWgdKfeXdL<dbZYdyddWdcZZeeddr[ejdeejdfdgZ]dhe]j_die]j_dje]j_dkZan)er'ejdeejdfdgZ]dlZadydmZbdzdnZcdoZddpZeejejzdfdqZhy#e $rdZ YdwxYw#e $rdZ YjwxYw#e $rdZYpwxYw){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. NTFntposixwin32iisendfilelinux _fcopyfilez%.COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC) copyfileobjcopyfilecopymodecopystatcopycopy2copytreemovermtreeErrorSpecialFileError ExecError make_archiveget_archive_formatsregister_archive_formatunregister_archive_formatget_unpack_formatsregister_unpack_formatunregister_unpack_formatunpack_archiveignore_patternschownwhichget_terminal_size SameFileErrorc eZdZy)rN)__name__ __module__ __qualname__-/opt/alt/python312/lib64/python3.12/shutil.pyrrCsr'rceZdZdZy)r!z5Raised when source and destination are the same file.Nr#r$r%__doc__r&r'r(r!r!Fs?r'r!ceZdZdZy)rz|Raised when trying to do a kind of operation (e.g. copying) which is not supported on a special file (e.g. a named pipe)Nr*r&r'r(rrIs;r'rceZdZdZy)rz+Raised when a command could not be executedNr*r&r'r(rrMs5r'rceZdZdZy) ReadErrorz%Raised when an archive cannot be readNr*r&r'r(r/r/Ps/r'r/ceZdZdZy) RegistryErrorzVRaised when a registry operation with the archiving and unpacking registries failsNr*r&r'r(r1r1Ss&r'r1ceZdZdZy)_GiveupOnFastCopyzuRaised as a signal to fallback on using raw read()/write() file copy when fast-copy functions fail to do so. Nr*r&r'r(r3r3Wsr'r3c |j}|j} tj|||y#t$r}t|d}~wwxYw#t $ra}|j |_|j |_|jtjtjhvr t||dd}~wwxYw)zhCopy a regular file content or metadata by using high-performance fcopyfile(3) syscall (macOS). N) fileno Exceptionr3rrOSErrornamefilename filename2errnoEINVALENOTSUP)fsrcfdstflagsinfdoutfderrs r(_fastcopy_fcopyfilerD\s%{{}   ue, %$$%  yy   99u}}5 5#C( (4   s- ;A A AA C AB<<Cc |j}|j} tt j |j d}tjdkr t|d}d} t j||||}|dk(ry||z }%#t$r}t|d}~wwxYw#t$rd}YpwxYw#t$r}|j|_ |j|_|jtj k(r dat||jtj$k(r|d|dk(r3t j&|dtj(dk(r t||d}~wwxYw)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. Niili@rF)r5r6r3maxosfstatst_sizer7sysmaxsizeminrr8r9r:r;ENOTSOCK_USE_CP_SENDFILEENOSPClseekSEEK_CUR)r>r?rArBrC blocksizeoffsetsents r(_fastcopy_sendfilerUpsV%{{} ..8  {{W 7+ F  ;;udFI>D,qy dNF5 % %$$%   99CL IICMyyENN*$) ',,yyELL(t#{rxxq"++>!C',,I' sA B)B//C B, B''B,/ B=<B= E4 B&E//E4c|j}|j}tt|5} ||}|sn%||kr|d|5}||dddn ||0dddy#1swYxYw#1swYyxYw)zreadinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode. N)readintowrite memoryview bytearray)r>r?length fsrc_readinto fdst_writemvnsmvs r(_copyfileobj_readintoras~ MMMJ If% &"b!AVVssO2 ' & V ' &s#A4 A( A4(A1 -A44A=c|st}|j}|j}||x}r||||x}ryy)z=copy data from file-like object fsrc to file-like object fdstN) COPY_BUFSIZEreadrX)r>r?r[ fsrc_readr]bufs r(r r sE  IJ6" "# "36" "# "r'ct|tjr\ttjdrB tjj |j tj |Sttjdr! tjj||Stjjtjj|tjjtjj|k(S#t$rYywxYw#t$rYywxYw)NsamestatFsamefile) isinstancerGDirEntryhasattrpathrhstatr7rinormcaseabspathsrcdsts r( _samefilerts#r{{#(D 77##CHHJ = =rww # 77##C- - GG  RWW__S1 2 GG  RWW__S1 2 34     s$AD+D:+ D76D7: EEct|tjr|jStj|SN)rjrGrkrnfns r(_statrys("2r{{32779DDr'ct|tjr|jStjj |Srv)rjrGrk is_symlinkrmislinkrws r(_islinkr}s-(R[[92==?Qrww~~b?QQr'follow_symlinksc tjd||t||rtdj ||d}t ||gD]\}} t |}tj|jr6t|tjr |jn|}td|ztsn|dk(st|j }|s6t%|r+tj&tj(|||St+|d5} t+|d5}t,r0 t/||t0j2|cdddcdddSt6r! t9|||cdddcdddStr4|dkDr/t;||t=|t>|cdddcdddStA||dddddd|S#t"$rYwxYw#t4$rY9wxYw#t4$rYHwxYw#1swYAxYw#tB$r4} tjjE|stGd|| d} ~ wwxYw#1swY|SxYw) 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. zshutil.copyfilez{!r} and {!r} are the same filerz`%s` is a named piperbwbNzDirectory does not exist: )$rJauditrtr!format enumerateryrnS_ISFIFOst_moderjrGrkrmr_WINDOWSrIr7r}symlinkreadlinkopen_HAS_FCOPYFILErDr_COPYFILE_DATAr3rNrUrarLrcr IsADirectoryErrorexistsFileNotFoundError) rrrsr file_sizeirxstr>r?es r(r r s1IIc*c=DDS#NOOIC:&2 'rB }}RZZ( *2r{{ ;RWW&'='BCCAFJJ ' ws| 2;;s#S)D JA#t_ #t_%!/dE._nopirr'c&tt|Srv)getattrrG)r8rs r(lookupzcopystat..lookupps2tT* *r'cRtt|}|tjvr|SSrv)rrGsupports_follow_symlinks)r8rxrs r(rzcopystat..lookupus)T4(BR000 Kr'r~rnutimerrTrc(tj|yrv)rGrrs r(_chmodzcopystat.._chmods $r'st_flagschflags) EOPNOTSUPPr=)rJrr}rGrmr|rjrkrnrr st_atime_ns st_mtime_nsrr8rNotImplementedErrorrlrr7r;r) rrrsrfollowrrmoderwhyrCrs @r(r r [sIIc*T  JWS\%IbggnnS6I JF  +   #r{{# XXfX - VF^C 8 << #DF7OCR^^R^^< sC0 G_F ww$ ww~~c"gg&&s4&8   sD&1r:  F9 c2;; G       .5#&399s8K+K/ s6 F)F FF G G4GGG ctjj|r=tjj|tjj |}t |||t ||||S)a3Copy 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~)rGrmisdirjoinbasenamer r )rrrsrs r(r r sT ww}}Sggll3 0 0 56 S#7 S#7 Jr'ctjj|r=tjj|tjj |}t t dritj|}tj|}t j}|s|t jz} t j||||St|||t!||||S#t$rI}|jt jk(r|sn|jt jk(rnYd}~kd}~wwxYw)a0Copy 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~)rGrmrrrrl_winapifsdecode%COPY_FILE_ALLOW_DECRYPTED_DESTINATIONCOPY_FILE_COPY_SYMLINKrr7winerrorERROR_PRIVILEGE_NOT_HELDERROR_ACCESS_DENIEDr r )rrrsrsrc_dst_r@excs r(rrs ww}}Sggll3 0 0 56w ${{3{{3== W33 3E    dD% 0J S#7 S#7 J   @ @@'!._ignore_patternss6 G  w!? @ =!!r'r&)rrs` r(rrs " r'c X|5|tj||Dcgc]}|jc}} nd} tj||g} |tuxs|t u} |D]|} | j| vrtj j|| j} tj j|| j}| r| n| } | j}|rDtjdk(r1| jd}|jtjk(rd}|rtj| }|r&tj||t||| nztj j|s|r&| j!rt#|||||||n5|||n+| j!rt#|||||||n ||| t||| r t%| |Scc}w#t$$r)}| j'|j(dYd}~d}~wt*$r(}| j-| |t/|fYd}~d}~wwxYw#t*$r4}t1|dd| j-||t/|fYd}~d}~wwxYw)Nr&)exist_okrFr~rr)rGfspathr8makedirsrr rmrr{rnst_reparse_tagIO_REPARSE_TAG_MOUNT_POINTrrr ris_dirrrrrr7appendstrr)entriesrrrssymlinksignore copy_functionignore_dangling_symlinks dirs_exist_okxrerrors use_srcentrysrcentrysrcnamedstnamesrcobjr{rlinktorCrs r( _copytreersQ ryy~/H1/HI  KKm, F E)B]d-BL ==M ) '',,sHMM2'',,sHMM2)w& 8!,,.Jbggo! e <''4+J+JJ!&JW-JJvw/VW(lK77>>&16N ( (F!.0H!.0&fg6"(FM1=Bfg.MZ0c Fm J{0Ib ' MM#((1+ & & 8 MM7GSX6 7 7 8 0 3 D ) 1 MM3SX. /0sIH B6H AH( I, I)H55 I)I$$I), J)5*J$$J)c tjd||tj|5}t |}dddt |||||||S#1swYxYw)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. zshutil.copytreeN)rrrrsrrrrr)rJrrGscandirlistr) rrrsrrrrritrrs r(rr-sYPIIc* CCs)  W#3"-.F#0 22 s AAst_file_attributesc tj|}tj|jxs<|j tj zxr|jtjk(S#t$rYywxYw)NF) rGrrnS_ISLNKrrFILE_ATTRIBUTE_REPARSE_POINTrrr7)rmrs r(_rmtree_islinkr^sr $BLL,K&&)J)JJJ&&$*I*II L  sA1A44 B?Bc@tjj|Srv)rGrmr|)rms r(rrgsww~~d##r'cfd}tj|d|tj}|D]\}}}|D]8}tjj ||} tj |:|D]8}tjj ||} tj|: tj |y#t $r"} tj || Yd} ~ d} ~ wwxYw#t $r"} tj|| Yd} ~ d} ~ wwxYw#t $r"} tj || Yd} ~ yd} ~ wwxYw)NcJtj|j|yrv)rGrr9)rConexcs r(onerrorz_rmtree_unsafe..onerrorls bjj#,,,r'F)topdownr followlinks)rGwalk_walk_symlinks_as_filesrmrrmdirr7unlink) rmrrresultsdirpathdirnames filenamesr8fullnamerCs ` r(_rmtree_unsaferks-ggdE7HbHbcG(/$9Dww||GT2H /" Dww||GT2H 0 (#)0#  /bhh#.. /  0bii3// 0 # bhhc""#sHC C84D& C5C00C58 D#DD#& E/E  Ec|j\}}}}||n |j} |tjurtj|y|tjurtj||y|tj usJ|tj ||}n|j d}tj}tj|tjtjz|}tjj} tjj|tj|s td|jtj|||f|jtj|||ftj }tj |5} t#| } ddd D]} tjj%|| j} | j'dr$|jtj || | fd tj(| j|y#|jtj|||fwxYw#1swYxYw#t$rYdwxYw#t$r"} |tj(| | Yd} ~ d} ~ wwxYw#t$r} || _|||| Yd} ~ yd} ~ wwxYw)N)dir_fdFr~%Cannot call rmtree on a symbolic link)popr8rGcloserrrnrO_RDONLY O_NONBLOCKrmr|rhrHr7rrrrrrr9)stackrfuncdirfdrm orig_entryr8orig_sttopfd scandir_itrentryr rCs r(_rmtree_safe_fdrsG%*IIK!D%z%4:??D. 288  HHUO  288  HHT% ( rxx  hhtE2G ooeo77##GRXXe_=EFF LL"((E4< = LL"((E4< =zz ZZ *:&GEww||D%**5H <<<6LL"((E8U!CD7  0 %**U3 LL"((E4< =    0bii3// 0   dD#s'K)K9B!KA!I$.onexcs r'Ncrvr&r!s r(rzrmtree..onexcs r'crvr&r!s r(rzrmtree..onexcsr'c^|\}}}|d}nt|||jf}|||S)N)NNN)type __traceback__)rrrmrexc_infors r(rzrmtree..onexcs="&dC;/H#Cy#s/@/@@HtT844r'z#dir_fd unavailable on this platformr)rJr_use_fd_functionsrjbytesrGrrrrrr7rrrmr|r) rm ignore_errorsrrrrrfdrrCs ` r(rrs*IIotV,  U]   ?  5 dE ";;t$D((FD$/0 /u-(- %b$rxx'/HHRL   %&KL L d#EFF$dE**/"((D#../ (- %b$rxx'/HHRL/"((D#../   "''..$ ,  sl5D*1C<F"< D'D""D'*+FE,+F, F5F FFFF" G+"GGctj|}tjjtjjxsdz}tjj |j |S)aHA 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' )rGrrmsepaltseprrstrip)rmr.s r( _basenamer1sN 99T?D ''++-2 .C 77  DKK, --r'c|tjd|||}tjj |rt ||r6tjj |stj||ytjj|t|}tjj|rtd|z tj|||S#t$rGtjj |rCtj|}tj||tj|Y|Stjj |rt!||rtd|d|dt#|sLtj$|tj&s:tj(|r%tj*dk(rt-d|d |dt/|||d t1|Y|S|||tj|Y|SwxYw) 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 existszCannot move a directory 'z' into itself 'z'.darwinz%Cannot move the non-empty directory 'z ': Lacking write permission to 'T)rr)rJrrGrmrrtr|renamerr1rrr7rrr _destinsrc _is_immutableaccessW_OKlistdirplatformPermissionErrorrr)rrrsrreal_dstrs r(rr%s4IImS#&H ww}}S S# rww~~c': IIc3  77<<Ys^4 77>>( #>IJ J #x , O+  77>># [[%F JJvx ( IIcN" O!WW]]3 #s#(+S233c"IIc2773 3LLH4%),c'344 S(-" $ 3K O #x ( IIcN O+s C**A)H;CH;H;:H;ctjj|}tjj|}|jtjjs|tjjz }|jtjjs|tjjz }|j |Srv)rGrmrpendswithr. startswithrqs r(r5r5gs ''//# C ''//# C << $ rww{{ << $ rww{{ >># r'ct|}tjtjg}t |dxr|j |vS)Nr)ryrn UF_IMMUTABLE SF_IMMUTABLErlr)rrrimmutable_statess r(r6r6ps> sB))4+<+<= 2z " Fr{{6F'FFr'cx|y ddlm} ||}||dSy#t$rYywxYw#t$rd}Y$wxYw)z"Returns a gid, given a group name.Nr)getgrnam)grprE ImportErrorKeyError)r8rEresults r(_get_gidrKu^ | $ay   + (( 99cx|y ddlm} ||}||dSy#t$rYywxYw#t$rd}Y$wxYw)z"Returns an uid, given a user name.Nr)getpwnamrF)pwdrOrHrI)r8rOrJs r(_get_uidrQrLrMc .|d} nDtr|dk(rd} n6tr|dk(rd} n(tr|dk(rd} ntdj |d dl} |rd | znd} |d z| z} t jj| } | rJt jj| s+||jd | |st j| ||jd ttfd}|s^| j| d| z}|}| t jj||} |j!||||j#|t jj%| } | S#|j#wxYw)aCreate 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. Nr-gzipgzbzip2bz2xzzCbad value for 'compress', or compression format not supported : {0}r..tar creating %szCreating tar archivecH|_|_|_|_|Srv)gidgnameuiduname)tarinfor\groupownerr^s r( _set_uid_gidz#_make_tarball.._set_uid_gids. ?GK!GM ?GK!GMr'zw|%sr)_ZLIB_SUPPORTED_BZ2_SUPPORTED_LZMA_SUPPORTED ValueErrorrtarfilerGrmdirnamerinforrQrKrraddrrp) base_namebase_dircompressverbosedry_runrbraloggerroot_dirtar_compressionri compress_ext archive_name archive_dirrctararcnamer\r^s `` @@r( _make_tarballrzsr  X/ H/ X-++16(+;= =,43("Lv% 4L''//,/K277>>+6   KK { 3 KK $ *+ 5/C 5/C ll</)AB  ww||Hh7H  GGHglG ; IIKww|4  IIKs ;FFcddl}|dz} tjj|} | rJtjj | s+||j d| |stj | ||j d| ||sH|j| d|j5} tjj|} | tjj||}tjj|}| tjk7r&| j|| ||j d|tj|D]n\} }}| }| tjj||}tjj|}t|D]i}tjj| |}tjj||} | j|| |X|j d|k|D]}tjj| |}tjj|}tjj!|sbtjj||} | j|| ||j d|q ddd|tjj#| } | S#1swY,xYw) 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. rN.ziprZz#creating '%s' and adding '%s' to itw) compressionz adding '%s')zipfilerGrmrjrrkrZipFile ZIP_DEFLATEDnormpathrcurdirrXrrelpathsortedisfilerp)rmrnrprqrrrbrarsr zip_filenamerwzfryr r r  arcdirpathr8rms r( _make_zipfilersZv%L''//),K277>>+6   KK { 3 KK $  9 ( ,  __\3)0)=)=?BDgg&&x0G#77<<(;ww''1H"))#7+%KK x8020A,9$ '!#X!FJWW--j9 "8,D77<<6D ggll:tc|g}t|std|zt|ttfs td|D]1}t|ttfrt |dk7s(td|||ft |<y)auRegisters 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. NzThe %s object is not callablez!extra_args needs to be a sequencerFz+extra_args elements are : (arg_name, value))callable TypeErrorrjtuplerlenr)r8function extra_args descriptionelements r(rr;s H 7(BCC j5$- 0;<<'E4=1S\A5EIJ J' K@Tr'ct|=yrv)rr8s r(rrPs r'c htjd|||| t|} ||||d} | d} | dD] \} } | | | < |t j }t| dd}d}|t j|j}tj|sttjd ||rt j|}|| d <n^t j}||j!d |t j"j%|}|st j&| | ||fi| }|)||j!d |t j&||S#t$rt d|zdwxYw#|*||j!d |t j&|wwxYw) aCreate 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. zshutil.make_archivezunknown archive format '%s'N)rqrrrbrarsupports_root_dirFzNot a directoryrszchanging into '%s'zchanging back to '%s')rJrrrIrhrGrrrnrS_ISDIRNotADirectoryErrorr;ENOTDIRrgetcwddebugrmrpchdir)rmrrsrnrprqrbrarr format_inforrargvalrsave_cwdstmdr9s r(rrSs$II#Y(KK&v. !Fu.F q>DNSs #99&95AHwwx ((||D!$U]]4ExP P  ),I!)F: yy{H! 18< 2I" 86v6  ! 4h? HHX  OQ K6?@dJKF  ! 4h? HHX  s E'0 F'F.F1ctjDcgc]\}}||d|df}}}|j|Scc}}w)zReturns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description) r)_UNPACK_FORMATSrr)r8rkrs r(rrsS$$&(&-7D$d1gtAw'& ( LLN N(sAci}tjD]\}}|dD]}|||< |D]}||vsd}t||||fzt|s t dy)z+Checks what gets registered as an unpacker.rz!%s is already registered for "%s"z*The registered function must be a callableN)rrr1rr) extensionsrrexisting_extensionsr8rkext extensionmsgs r(_check_unpack_optionsrs%++- d7C'+  $. + +5Cy':9'E'G!GH H H DEE r'c@|g}t|||||||ft|<y)aMRegisters 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)rr)r8rrrrs r(rrs." *h ;&*kIODr'ct|=y)z*Removes the pack format from the registry.N)rrs r(rrs r'ctjj|}tjj|stj|yy)z1Ensure that the parent directory of `path` existsN)rGrmrjrr)rmrjs r(_ensure_directoryrs5ggood#G 77== ! G "r'cnddl}|j|std|z|j|} |j D]}|j }|j dsd|vr%tjj|g|jd}|sWt||jdrt|j|d5}t|d5}t||dddddd |jy#1swY%xYw#1swYxYw#|jwxYw)z+Unpack zip `filename` to `extract_dir` rNz%s is not a zip file/z..rr)r is_zipfiler/rinfolistr9r?rGrmrsplitrr>rr r) r9 extract_dirrrrkr8 targetpathsourcetargets r(_unpack_zipfilers   h '.9:: //( #CLLND==Ds#tt|kDDJJsODJ j )==%XXdC(FZ.&//)(#$ /.)( sBBD":D" D D &D. D" D DD D""D4rdcddl} |j|} |j |||j y#|j$rtd|zwxYw#|j wxYw)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar filerd)rirTarErrorr/ extractallr)r9rrritarobjs r(_unpack_tarfilersxJh'+f5    J = HJ JJ  s<AAA/rYr|)rxrz.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzc~tjD]&\}}|dD]}|j|s|ccS(y)Nr)rrr>)r9r8rkrs r(_find_unpack_formatrs?%++- daI  + !. r'ctjd||||tj}tj|}tj|}|i}nd|i}|( t |}|d}|||fit|d|yt|}|tdj|t |d}tt |d|z}|||fi|y#t $rtdj|dwxYw)a]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. zshutil.unpack_archiveNrzUnknown unpack format '{0}'rrFzUnknown archive format '{0}') rJrrGrrrrIrhrdictrr/)r9rrr filter_kwargsrrrs r(rrs"$II%xfEiik ))K(Kyy"H ~ !6*   U)&1K1~ X{Ld;q>&:LmL%X. >:AA(KL Lv&q)of-a01MA X{-f- U:AA&IJPT T Us % C""%Dstatvfs disk_usageusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytesctj|}|j|jz}|j|jz}|j|j z |jz}t |||S)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. )rGrf_bavailf_frsizef_blocksf_bfree_ntuple_diskusage)rmrfreetotaluseds r(rrRs` ZZ {{R[[( bkk) bjj(BKK7 d33r'cVtj|\}}||z }t|||S)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)rmrrrs r(rrcs0 &&t, tt| d33r'cxtjd|||| | td|}|}|d}n7t|tr't |}|t dj||d}n7t|ts't|}|t dj|tj|||y)zChange 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. z shutil.chownNzuser and/or group must be setzno such user: {!r}zno such group: {!r}) rJrrhrjrrQ LookupErrorrintrKrGr)rmuserra_user_groups r(rrns IIndD%0 | 899 E F | D#  =299$?@ @ } s #% >3::5AB BHHT5&!r'c6 ttjd} ttjd}|dks|dkrb tj t jj}|dkr|jxs|d}|dkr|jxs|d}tj||fS#ttf$rd}YwxYw#ttf$rd}YwxYw#tttf$rtj|}YwxYw)aGet 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. COLUMNSrLINESr)rrGenvironrIrhr rJ __stdout__r5AttributeErrorr7 terminal_sizecolumnslines)fallbackrrsizes r(r r s (bjj+,BJJw'( !|uz .''(=(=(?@D a<ll1hqkG A:JJ-(1+E  We, --+ j ! j ! G4 .##H-D .s4B>C1C,>CCC)(C),)DDctjj|xr8tj||xr tjj | Srv)rGrmrr7r)rxrs r( _access_checkrsA GGNN2  &299R#6 &GGMM"%%'r'c~|tjz xs(tjtj|S)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. )rGX_OKrNeedCurrentDirectoryForExePathr)cmdrs r(_win_path_needs_curdirrs5   "W%K%K C &""r'c8t|t}tjj |\}}|r|g}n|8tj j dd}| tjd}|sy|rHtj|}|j tjtj}n4tj|}|j tj}tjdk(rEt!||r9tj"}|rtj|}|j%d|tjdk(rtj&dxst(}|j tjDcgc]}|s| }}|r"|Dcgc]}tj|}}|g|Dcgc]}||z c}z} tjj+| ddj-|tj.zr8t1fd|Ds$| j3| j5dn|g} t7} |D]p} tjj9| } | | vs'| j;| | D]4} tjj=| | }t?||s0|ccSry#ttf$rtj}YwxYwcc}wcc}wcc}w) a3Given 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. NPATHCS_PATHrrPATHEXTrc3DK|]}|jk(ywrv)upper).0rsuffixs r( zwhich..s%Owf &;ws ) rjr)rGrmrrgetconfstrrrhdefpathfsencodepathseprrJr:rrinsertgetenv_WIN_DEFAULT_PATHEXTsplitextrranyrrrrorlrr)rrrm use_bytesrjrpathext_sourcerpathextfilesseendirnormdirthefiler8rs @r(rrsp3&I 77==%LGSy <::>>&$/D|&::i0D ;;t$D::bkk"**56D;;t$D::bjj)D <<7 "'=c4'HYYFV, KK6 " ||w9-E1E"0"6"6rzz"BJ"B3c3"BJ 3:;7Cr{{3'7G;w7w#)w77!!%(+A.446 "''>#%Ow%O"O LL1 & 5D''""3'$ HHW  ww||C1 t,K!  q' 3&::D&6K<7s* K' L (L 4L L'L  L )r)F)FN)rSrrNNNN)rrNNNN)Nr-)NNrrNNN)NN))P)ir+rGrJrnr collectionsr;warningszlibrerHrVrflzmargr8rrrr:rrcrlr?rNrr__all__r7rr!rrr/r6r1r3rDrUrar rtryr}r r rr r rrrr stat_resultrrrrrrsupports_dir_fdr supports_fdrr(ravoids_symlink_attacksr1rr5r6rKrQrzrrrrrrrrrrrrrrrrrr namedtuplerrrrrrr rrF_OKrrr&r'r(r s;    O N O 77d? 77g  <<7G&{I 2z*Os||/F/Fw/O775,7?  G @E@;w;6600&I&   (>@.:(4$ER+/>@+/.2 2{040 +/HT'+$(,&P 7<@D!&d%&+5.2` 2>>/0$#.=~ggrww 288<''(<ZZ2>>1<WW ; ;; G+T$G+V!2.$"'@DG $$LM@DDL;<@D7r#' "&  m01%' !.1E0F 2!4W,b*=U!.1F0G 3!5W!.1C0D 0!2WA*KL;?=@ F$CG')J, <6: (h-D EhZ 8 !*F 3_b 2 4OG!+W 5 3 5OG!*F 3_b 0 2OG..d..b 2y NN< . ..w8IJ&<#%:"%:" 4 NN< . ..w8IJ4"@+.b' "GGbgg%DPw-ONOs3NNNN  N NNN('N(