grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026o ®û|jøÒã@s.dZddlZddlZddlZddlZddlZddlZz ddlZ[dZWn e y.dZYnwz ddl Z [ dZ Wn e yCdZ Ynwz ddl Z [ dZ Wn e yXdZ YnwejdkZdZZejdkrlddlZnerrddlZervdndZeed ƒo‚ej d ¡aeo‰eed ƒZd Zgd ¢ZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„de ƒZ!Gdd„de ƒZ"dd„Z#dd„Z$efd d!„Z%d¢d"d#„Z&d$d%„Z'd&d'„Z(d(d)„Z)dd*œd+d,„Z*dd*œd-d.„Z+eed/ƒ�rdd*œd0d1„Z,nd2d1„Z,dd*œd3d4„Z-dd*œd5d6„Z.dd*œd7d8„Z/d9d:„Z0 d£d;d<„Z1dde/ddfd=d>„Z2eej3d?ƒ�r@d@dA„Z4dBdC„Z5ndDdA„Z4dEdC„Z5dFdG„Z6dHdI„Z7ej8ejej9ej:hej;k�ojejvZ?d¤dJdK„Z@e?e@_AdLdM„ZBe/fdNdO„ZCdPdQ„ZDdRdS„ZEdTdU„ZFdVdW„ZG  d¥dYdZ„ZH  d¦d[d\„ZId]eHd^gd_dfiZJe�r¸eHd`gdadfeJdb<eIgdcdfeJdd<e �rÄeHdegdfdfeJdg<e �rÐeHdhgdidfeJdj<dkdl„ZKd§dndo„ZLdpdq„ZM  d¨drds„ZNdtdu„ZOdvdw„ZP  md§dxdy„ZQdzd{„ZRd|d}„ZSd~d„ZTdd€œd�d‚„ZUdƒgeUgd_fd„geTgdcfd…œZVe�r"d†d‡geUgdafeVdb<e �r/dˆd‰geUgdffeVdg<e �rórc@r$)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"r#rAr'rc@r$)rz+Raised when a command could not be executedNr%r"r"r"r#rEr'rc@r$)Ú ReadErrorz%Raised when an archive cannot be readNr%r"r"r"r#r(Hr'r(c@r$)Ú RegistryErrorzVRaised when a registry operation with the archiving and unpacking registries failsNr%r"r"r"r#r)Kr'r)c@r$)Ú_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"r#r*Or'r*c Cs”z | ¡}| ¡}Wnty}zt|ƒ‚d}~wwz t |||¡WdStyI}z|j|_|j|_|j t j t j hvrBt|ƒ‚|d‚d}~ww)zhCopy a regular file content or metadata by using high-performance fcopyfile(3) syscall (macOS). N) ÚfilenoÚ Exceptionr*rrÚOSErrorÚnameÚfilenameÚ filename2ÚerrnoÚEINVALÚENOTSUP)ÚfsrcÚfdstÚflagsÚinfdÚoutfdÚerrr"r"r#Ú_fastcopy_fcopyfileTs" €ÿ€úr:c Cs$z | ¡}| ¡}Wnty}zt|ƒ‚d}~wwz tt |¡jdƒ}Wn ty1d}Ynwtj dkr= 2.6.33 only. Ni€ili@rTF)r+r,r*ÚmaxÚosÚfstatÚst_sizer-ÚsysÚmaxsizeÚminrr.r/r0r1ZENOTSOCKÚ_USE_CP_SENDFILEZENOSPCÚlseekÚSEEK_CUR)r4r5r7r8r9Z blocksizeÚoffsetZsentr"r"r#Ú_fastcopy_sendfilehsF €ÿ ÿ    €íærFc Cs˜|j}|j}tt|ƒƒ�6} ||ƒ}|sn%||kr5|d|…� }| |¡Wdƒn1s/wYn||ƒqWdƒdS1sEwYdS)z–readinto()/memoryview() based variant of copyfileobj(). *fsrc* must support readinto() method and both files must be open in binary mode. TN)ÚreadintoÚwriteÚ memoryviewÚ bytearray)r4r5ÚlengthZ fsrc_readintoÚ fdst_writeZmvÚnZsmvr"r"r#Ú_copyfileobj_readinto¨s  ÿ€ø"ürNcCs0|st}|j}|j} ||ƒ}|sdS||ƒq )z=copy data from file-like object fsrc to file-like object fdstTN)Ú COPY_BUFSIZEÚreadrH)r4r5rKZ fsrc_readrLZbufr"r"r#r»sürcCs¢t|tjƒr$ttjdƒr$z tj | ¡t |¡¡WSty#YdSwttjdƒr=ztj ||¡WSty<YdSwtj  tj  |¡¡tj  tj  |¡¡kS)NÚsamestatFÚsamefile) Ú isinstancer<ÚDirEntryÚhasattrÚpathrQÚstatr-rRÚnormcaseÚabspath©ÚsrcÚdstr"r"r#Ú _samefileÈs ÿ  ÿÿr]cCst|tjƒr | ¡St |¡S©N)rSr<rTrW©Úfnr"r"r#Ú_statÚsracCs t|tjƒr | ¡Stj |¡Sr^)rSr<rTÚ is_symlinkrVÚislinkr_r"r"r#Ú_islinkÝs rd©Úfollow_symlinksc Cs:t d||¡t||ƒrtd ||¡ƒ‚d}t||gƒD]4\}}zt|ƒ}Wn ty/Yqwt  |j ¡rGt |t j ƒr?|jn|}td|ƒ‚trP|dkrP|j}q|sbt|ƒrbt  t  |¡|¡|St|dƒ�«}z„t|dƒ�u}tr”zt||tjƒ|WWdƒWWdƒSty“YnDwtr·zt||ƒ|WWdƒWWdƒSty¶Yn!wtr×|dkr×t||t|tƒƒ|WdƒWWdƒSt ||ƒWdƒn1sæwYWnt!�y } zt j "|¡�st#d|›�ƒ| ‚‚d} ~ wwWdƒ|S1�swY|S) zÎCopy 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 pipeÚrbÚwbNzDirectory does not exist: )$r?Úauditr]rÚformatÚ enumeraterar-rWÚS_ISFIFOÚst_moderSr<rTrVrÚ_WINDOWSr>rdÚsymlinkÚreadlinkÚopenÚ_HAS_FCOPYFILEr:rZ_COPYFILE_DATAr*rBrFrNrArOrÚIsADirectoryErrorÚexistsÚFileNotFoundError) r[r\rfÚ file_sizeÚir`Ústr4r5Úer"r"r#ràsv   þ   € " à ûþ ÿ ôþ ÿ íþ 뀀ü€ æ à rcCsnt d||¡|s"t|ƒr"tj |¡r"ttdƒr tjtj}}ndSt tj }}||ƒ}||t   |j ¡ƒdS)zàCopy 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. zshutil.copymodeÚlchmodN)r?rirdr<rVrcrUÚlstatrzraÚchmodrWÚS_IMODErm)r[r\rfZ stat_funcZ chmod_funcrxr"r"r#r s  rÚ listxattrc CsÆz tj||d�}Wnty(}z|jtjtjtjfvr‚WYd}~dSd}~ww|D]5}ztj|||d�}tj||||d�Wq+ty`}z|jtj tjtjtjfvrV‚WYd}~q+d}~wwdS)z®Copy extended filesystem attributes from `src` to `dst`. Overwrite existing attributes. If `follow_symlinks` is false, symlinks won't be followed. reN) r<r~r-r1r3ZENODATAr2ÚgetxattrÚsetxattrZEPERM)r[r\rfÚnamesryr.Úvaluer"r"r#Ú _copyxattr6s* €ýÿ þ€ÿürƒcOódSr^r")ÚargsÚkwargsr"r"r#rƒNóc sXt d||¡dddœdd„‰|pt|ƒotj |¡ }|r%‡fdd„}n‡fdd„}t|tjƒr8|j|d �}n|d ƒ||d �}t  |j ¡}|d ƒ||j |j f|d�t |||d �z |d ƒ|||d �Wn tynYnwt|d ƒrªz |dƒ||j|d �WdSty©}zdD]}tt|ƒrœ|jtt|ƒkrœnq‹‚WYd}~dSd}~wwdS)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. zshutil.copystatN)ÚnsrfcWr„r^r")rˆrfr…r"r"r#Ú_nop_r‡zcopystat.._nopcs tt|ˆƒSr^)Úgetattrr<©r.©r‰r"r#Úlookupfó zcopystat..lookupcstt|ˆƒ}|tjvr |SˆSr^)rŠr<Úsupports_follow_symlinks)r.r`rŒr"r#r�ks  rerWÚutimer|Úst_flagsZchflags)Z EOPNOTSUPPr3)r?rirdr<rVrcrSrTrWr}rmÚ st_atime_nsÚ st_mtime_nsrƒÚNotImplementedErrorrUr‘r-r1rŠ) r[r\rfZfollowr�rxÚmodeÚwhyr9r"rŒr#r Qs@    ÿ  õ €þ€ýýr cCóBtj |¡rtj |tj |¡¡}t|||d�t|||d�|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. re)r<rVÚisdirÚjoinÚbasenamerr©r[r\rfr"r"r#r “s r cCr—)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". re)r<rVr˜r™ršrr r›r"r"r#r ¥s r cs‡fdd„}|S)z�Function that can be used as copytree() ignore parameter. Patterns is a sequence of glob-style patterns that are used to exclude filescs(g}ˆD] }| t ||¡¡qt|ƒSr^)ÚextendÚfnmatchÚfilterÚset)rVr�Ú ignored_namesÚpattern©Úpatternsr"r#Ú_ignore_patterns»sz)ignore_patterns.._ignore_patternsr")r£r¤r"r¢r#r¶s rc Cs2|dur|t |¡dd„|Dƒƒ}ntƒ}tj||d�g} |tup%|tu} |D]¹} | j|vr0q(tj || j¡} tj || j¡} | rD| n| }zf|   ¡}|r`tjdkr`| j dd�}|j t j kr`d}|r—t  | ¡}|rxt || ¡t|| | d�n3tj |¡s‚|r‚Wq(|  ¡r‘t|| |||||ƒn||| ƒn|  ¡r¦t|| |||||ƒn||| ƒWq(tyÆ}z|  |jd¡WYd}~q(d}~wtyá}z|  | | t|ƒf¡WYd}~q(d}~wwzt||ƒWn&t�y}zt|ddƒdu�r|  ||t|ƒf¡WYd}~nd}~ww| �rt| ƒ‚|S) NcSsg|]}|j‘qSr"r‹)Ú.0Úxr"r"r#Ú Åsz_copytree..)Úexist_okrFrerZwinerror)r<ÚfspathrŸÚmakedirsr r r.rVr™rbrWÚst_reparse_tagÚIO_REPARSE_TAG_MOUNT_POINTrpror rtÚis_dirr rrœr…r-ÚappendÚstrrŠ)Úentriesr[r\ÚsymlinksÚignoreÚ copy_functionÚignore_dangling_symlinksÚ dirs_exist_okr ÚerrorsZ use_srcentryZsrcentryZsrcnameZdstnameZsrcobjrbr{Úlinktor9r–r"r"r#Ú _copytreeÂsl       þ  ÿ €€ €ÿ€ýr¸c CsXt d||¡t |¡� }t|ƒ}Wdƒn1swYt||||||||d�S)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 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)r°r[r\r±r²r³r´rµ)r?rir<ÚscandirÚlistr¸) r[r\r±r²r³r´rµZitrr°r"r"r#r s(  ÿ ýr Úst_file_attributescCsJz|jdd�}t |j¡o|jtj@o|jtjk WSty$YdSw©NFre)rWÚS_ISDIRrmr»ÚFILE_ATTRIBUTE_REPARSE_POINTr«r¬r-)Úentryrxr"r"r#Ú _rmtree_isdir8s    þ ÿrÀcCsFzt |¡}t |j¡p|jtj@o|jtjkWSt y"YdSw)NF) r<r{rWÚS_ISLNKrmr»r¾r«r¬r-)rVrxr"r"r#Ú_rmtree_islinkAs    þ ÿrÂcCs$z|jdd�WStyYdSwr¼)r­r-)r¿r"r"r#rÀJs  ÿcCs tj |¡Sr^)r<rVrc)rVr"r"r#rÂPrŽc Cs*zt |¡� }t|ƒ}Wdƒn1swYWnty/|tj|t ¡ƒg}Ynw|D]F}|j}t|ƒr_z | ¡rDtdƒ‚WntyX|tjj |t ¡ƒYq2wt ||ƒq2zt  |¡Wq2tyx|tj |t ¡ƒYq2wzt  |¡WdSty”|tj |t ¡ƒYdSw)Nú%Cannot call rmtree on a symbolic link) r<r¹rºr-r?Úexc_inforVrÀrbrcÚ_rmtree_unsafeÚunlinkÚrmdir)rVÚonerrorÚ scandir_itr°r¿Úfullnamer"r"r#rÅTs>  ÿ€ þü þ  ÿ ÿrÅc CsDzt |¡� }t|ƒ}Wdƒn1swYWnty:}z||_|tj|t ¡ƒWYd}~dSd}~ww|D]â}tj ||j ¡}z|j dd�}Wn tyZd}Yn$w|r~z|j dd�} t   | j ¡}Wnty}|tj|t ¡ƒYq=w|�rztj|j tj|d�} d} Wnty¡|tj|t ¡ƒYq=wzUtj | t | ¡¡r×t| ||ƒzt | ¡d} tj|j |d�Wn*tyÖ|tj|t ¡ƒYnwztdƒ‚tyî|tjj|t ¡ƒYnwW| s÷t | ¡q=| �st | ¡wwz tj|j |d�Wq=t�y|tj|t ¡ƒYq=wdS)NFre)Údir_fdTrÃ)r<r¹rºr-r/r?rÄrVr™r.r­rWr½rmr{rqÚO_RDONLYrQr=Ú_rmtree_safe_fdÚcloserÇrcrÆ) ÚtopfdrVrÈrÉr°r9r¿rÊr­Úorig_stÚdirfdZ dirfd_closedr"r"r#rÍssz  ÿ€€ý ÿ  þ ÿ   ÿ ÿ€ €ÿ ÿÿÓrÍc Cs¼t d|¡|r dd„}n|durdd„}trºt|tƒr!t |¡}zt |¡}Wnty;|tj|t  ¡ƒYdSwz t  |tj ¡}d}WntyZ|tj |t  ¡ƒYdSwzUtj   |t |¡¡r�t|||ƒzt |¡d}t |¡Wn*tyŒ|tj|t  ¡ƒYnwztdƒ‚ty¤|tj j|t  ¡ƒYnwW|s¯t |¡dSdS|s¹t |¡wwz t|ƒrÃtdƒ‚WntyØ|tj j|t  ¡ƒYdSwt||ƒS) aÄRecursively delete a directory tree. If ignore_errors is set, errors are ignored; otherwise, if 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 exc_info is a tuple returned by sys.exc_info(). If ignore_errors is false and onerror is None, an exception is raised. z shutil.rmtreecWr„r^r"©r…r"r"r#rȽr‡zrmtree..onerrorNcWs‚r^r"rÒr"r"r#rÈÀsFTrÃ)r?riÚ_use_fd_functionsrSÚbytesr<Úfsdecoder{r,rÄrqrÌrVrQr=rÍrÎrÇr-rcrÂrÅ)rVÚ ignore_errorsrÈrÐÚfdZ fd_closedr"r"r#r°sf     þ þ   ÿ ÿ€ÿ ÿþ ý rcCs0t |¡}tjjtjjp d}tj | |¡¡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' Ú)r<r©rVÚsepÚaltsepršÚrstrip)rVrÙr"r"r#Ú _basenameôs rÜc CsNt d||¡|}tj |¡r1t||ƒrt ||¡dStj |t|ƒ¡}tj  |¡r1t d|ƒ‚z t ||¡W|St y¦tj  |¡rZt  |¡}t ||¡t |¡Y|Stj |¡r™t||ƒrmt d||fƒ‚t|ƒs‚t |tj¡sŠt |¡rŠtjdkrŠtd||fƒ‚t|||dd�t|ƒY|S|||ƒt |¡Y|Sw) 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 the destination is a directory or a symlink to a directory, the source is moved inside the directory. The destination path must not already exist. If the destination 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 '%s' into itself '%s'.ÚdarwinzKCannot move the non-empty directory '%s': Lacking write permission to '%s'.T)r³r±)r?rir<rVr˜r]Úrenamer™rÜrtrr-rcrprorÆÚ _destinsrcÚ _is_immutableÚaccessÚW_OKÚlistdirÚplatformÚPermissionErrorr r)r[r\r³Zreal_dstr·r"r"r#r sR      ë     ð ÿ ÿÿ þÿ  þ ër cCsVtj |¡}tj |¡}| tjj¡s|tjj7}| tjj¡s&|tjj7}| |¡Sr^)r<rVrYÚendswithrÙÚ startswithrZr"r"r#rßHs     rßcCs(t|ƒ}tjtjg}t|dƒo|j|vS)Nr‘)rarWÚ UF_IMMUTABLEÚ SF_IMMUTABLErUr‘)r[rxZimmutable_statesr"r"r#ràQs ràcCój|durdSzddlm}Wn tyYdSwz||ƒ}Wn ty*d}Ynw|dur3|dSdS)z"Returns a gid, given a group name.Nr)Úgetgrnamé)ZgrprëÚ ImportErrorÚKeyError)r.rëÚresultr"r"r#Ú_get_gidVó ÿ  ÿrðcCrê)z"Returns an uid, given a user name.Nr)Úgetpwnamrì)Úpwdròrírî)r.ròrïr"r"r#Ú_get_uidhrñrôÚgzipc sV|durd} n"tr|dkrd} ntr|dkrd} ntr"|dkr"d} ntd |¡ƒ‚d dl} |r3d | nd} |d | } tj | ¡} | rZtj  | ¡sZ|durS|  d | ¡|sZt  | ¡|durc|  d ¡t ˆƒ‰t ˆƒ‰‡‡‡‡fdd„}|sŸ|  | d| ¡}|}|dur‹tj ||¡}z|j|||d�W| ¡n| ¡w|dur©tj | ¡} | S)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. NrØrõZgzÚbzip2Úbz2ÚxzzCbad value for 'compress', or compression format not supported : {0}rÚ.ú.tarú creating %szCreating tar archivecs,ˆdur ˆ|_ˆ|_ˆdurˆ|_ˆ|_|Sr^)ÚgidZgnameÚuidÚuname)Ztarinfo©rüÚgroupÚownerrýr"r#Ú _set_uid_gid©sz#_make_tarball.._set_uid_gidzw|%s©rž)Ú_ZLIB_SUPPORTEDÚ_BZ2_SUPPORTEDÚ_LZMA_SUPPORTEDÚ ValueErrorrjÚtarfiler<rVÚdirnamertÚinforªrôrðrqr™ÚaddrÎrY)Ú base_nameÚbase_dirÚcompressÚverboseÚdry_runrrÚloggerÚroot_dirZtar_compressionrZ compress_extZ archive_nameÚ archive_dirrÚtarÚarcnamer"rÿr#Ú _make_tarballzsH   ÿ       rcCsîddl}|d} tj |¡} | r'tj | ¡s'|dur | d| ¡|s't | ¡|dur2| d| |¡|së|j| d|jd��¦} tj  |¡} |durOtj  ||¡}tj  |¡}| tj krj|   || ¡|durj| d|¡t  |¡D]l\} }}| }|dur�tj ||¡}tj  |¡}t|ƒD] }tj  | |¡}tj  ||¡} |   || ¡|dur«| d|¡q‹|D],}tj  | |¡}tj  |¡}tj |¡rÚtj  ||¡} |   || ¡|durÚ| d|¡q®qoWdƒn1sæwY|durõtj | ¡} | S) z¦Create 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ú.ziprûz#creating '%s' and adding '%s' to itÚw)Z compressionz adding '%s')Úzipfiler<rVr rtr rªÚZipFileZ ZIP_DEFLATEDÚnormpathr™ÚcurdirrHÚwalkÚrelpathÚsortedÚisfilerY)r r rrrrrrrZ zip_filenamerZzfrÚdirpathZdirnamesÚ filenamesZ arcdirpathr.rVr"r"r#Ú _make_zipfileÀsh   ÿÿ         €    €ùõö r#r)rNzuncompressed tar file)rrõzgzip'ed tar-fileZgztarzZIP fileÚzip)rrözbzip2'ed tar-fileZbztar)rrøzxz'ed tar-fileZxztarcCódd„t ¡Dƒ}| ¡|S)z‘Returns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description) cSsg|] \}}||df‘qS)rìr")r¥r.Úregistryr"r"r#r§sz'get_archive_formats..)Ú_ARCHIVE_FORMATSÚitemsÚsort©Zformatsr"r"r#rs ÿrrØcCsv|durg}t|ƒstd|ƒ‚t|ttfƒstdƒ‚|D]}t|ttfƒr,t|ƒdkr0tdƒ‚q|||dft|<dS)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 sequencerìz+extra_args elements are : (arg_name, value)F)ÚcallableÚ TypeErrorrSÚtuplerºÚlenr')r.ÚfunctionÚ extra_argsÚ descriptionZelementr"r"r#rs  ÿrcCs t|=dSr^)r'r‹r"r"r#r/s rc  CsFt d||||¡zt|} Wntytd|ƒd‚w||||dœ} | d} | dD]\} } | | | <q-|dur=tj}| d}d}|durn|rSt |¡}|| d<nt ¡}|dura|  d |¡tj   |¡}|snt  |¡z| ||fi| ¤Ž}W|durŒ|dur‡|  d |¡t  |¡|S|dur¢|durœ|  d |¡t  |¡ww) 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)rrrrréérzchanging into '%s'zchanging back to '%s') r?rir'rîrr<rr©ÚgetcwdÚdebugrVrYÚchdir)r rjrr rrrrrÚ format_infor†ÚfuncÚargÚvalZsupport_root_dirZsave_cwdr/r"r"r#r2sL  ÿÿ        û  ýrcCr%)z‘Returns a list of supported formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description) cSs"g|] \}}||d|df‘qS)rr3r")r¥r.r r"r"r#r§ts"z&get_unpack_formats..)Ú_UNPACK_FORMATSr(r)r*r"r"r#rns ÿrc Csji}t ¡D]\}}|dD]}|||<qq|D]}||vr*d}t||||fƒ‚qt|ƒs3tdƒ‚dS)z+Checks what gets registered as an unpacker.rz!%s is already registered for "%s"z*The registered function must be a callableN)r;r(r)r+r,) Ú extensionsr/r0Zexisting_extensionsr.r ÚextÚ extensionÚmsgr"r"r#Ú_check_unpack_optionsys  ÿÿþÿr@cCs,|durg}t|||ƒ||||ft|<dS)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)r@r;)r.r<r/r0r1r"r"r#r‹s rcCs t|=dS)z*Removes the pack format from the registry.N)r;r‹r"r"r#r¡s rcCs*tj |¡}tj |¡st |¡dSdS)z1Ensure that the parent directory of `path` existsN)r<rVr r˜rª)rVr r"r"r#Ú_ensure_directory¥s  ÿrAcCs^ddl}| |¡std|ƒ‚| |¡�}d|_| |¡WdƒdS1s(wYdS)z+Unpack zip `filename` to `extract_dir` rNz%s is not a zip fileT)rZ is_zipfiler(rZ_ignore_invalid_namesÚ extractall)r/Ú extract_dirrr$r"r"r#Ú_unpack_zipfile«s    "þrDrcCs\ddl}z| |¡}Wn|jytd|ƒ‚wz|j||d�W| ¡dS| ¡w)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar filer)rrqZTarErrorr(rBrÎ)r/rCržrZtarobjr"r"r#Ú_unpack_tarfile·sÿÿrErúr)rr$z.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzcCs:t ¡D]\}}|dD] }| |¡r|Sq qdS)Nr)r;r(ræ)r/r.r r>r"r"r#Ú_find_unpack_formatÛs   ÿÿrFcCsüt d|||¡|durt ¡}t |¡}t |¡}|dur!i}nd|i}|durTzt|}Wnty>td |¡ƒd‚w|d}|||fit |dƒ¤|¤ŽdSt |ƒ}|durct d |¡ƒ‚t|d}t t|dƒ|B}|||fi|¤ŽdS)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_archiveNržzUnknown unpack format '{0}'r2rìzUnknown archive format '{0}') r?rir<r4r©r;rîrrjÚdictrFr()r/rCrjržZ filter_kwargsr7r8r†r"r"r#râs,    ÿ" rÚstatvfsÚ disk_usageZusageztotal used freezTotal space in byteszUsed space in byteszFree space in bytescCs@t |¡}|j|j}|j|j}|j|j|j}t|||ƒS)zÖReturn 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. )r<rHÚf_bavailÚf_frsizeÚf_blocksÚf_bfreeÚ_ntuple_diskusage)rVrxÚfreeÚtotalÚusedr"r"r#rIs    cCs"t |¡\}}||}t|||ƒS)z×Return 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. )rZ _getdiskusagerN)rVrPrOrQr"r"r#rI,s cCs®t d|||¡|dur|durtdƒ‚|}|}|durd}nt|tƒr3t|ƒ}|dur3td |¡ƒ‚|dur:d}nt|tƒsNt |ƒ}|durNtd |¡ƒ‚t   |||¡dS)z¹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. z shutil.chownNzuser and/or group must be setéÿÿÿÿzno such user: {!r}zno such group: {!r}) r?rirrSr¯rôÚ LookupErrorrjÚintrðr<r)rVÚuserrZ_userZ_groupr"r"r#r7s$  r©éPéc CsÎz ttjdƒ}Wn ttfyd}Ynwz ttjdƒ}Wn ttfy-d}Ynw|dks6|dkr`z t tj ¡¡}Wnt tt fyQt  |¡}Ynw|dkrY|j }|dkr`|j }t  ||f¡S)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. ZCOLUMNSrZLINES)rTr<Úenvironrîrrr?Ú __stdout__r+ÚAttributeErrorr-Ú terminal_sizeÚcolumnsÚlines)Zfallbackr]r^Úsizer"r"r#rWs*ÿÿýrcCs&tj |¡ot ||¡otj |¡ Sr^)r<rVrtrár˜)r`r•r"r"r#Ú _access_checkˆs ÿr`c s²tj ˆ¡rtˆ|ƒr ˆSdStˆtƒ}|dur9tj dd¡}|dur9zt d¡}Wnt t fy8tj }Ynw|s=dS|rNt  |¡}|  t  tj¡¡}n t |¡}|  tj¡}tjdkr¦tj}|rht  |¡}||vrr| d|¡t d¡pxt}dd„|  tj¡Dƒ}|r�d d„|Dƒ}t‡fd d „|Dƒƒrœˆg}n ‡fd d„|Dƒ}nˆg}tƒ}|D](} tj | ¡} | |vrÖ| | ¡|D]} tj | | ¡} t| |ƒrÕ| SqÁq®dS) 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. NÚPATHÚCS_PATHZwin32rZPATHEXTcSsg|]}|r|‘qSr"r"©r¥r=r"r"r#r§Áózwhich..cSsg|]}t |¡‘qSr")r<Úfsencodercr"r"r#r§Äsc3s"�|] }ˆ ¡ | ¡¡VqdSr^)Úlowerrærc©Úcmdr"r#Ú És€ zwhich..csg|]}ˆ|‘qSr"r"rcrgr"r#r§Ìrd)r<rVr r`rSrÔrYÚgetÚconfstrr[rÚdefpathreÚsplitÚpathseprÕr?rärÚinsertÚgetenvÚ_WIN_DEFAULT_PATHEXTÚanyrŸrXr r™) rhr•rVZ use_bytesrZpathext_sourceZpathextÚfilesÚseenÚdirZnormdirZthefiler.r"rgr#r�s\   þ          ÿ€r)r)F)FN)rõrrNNNN)rrNNNN)NrØ)NNrrNNN)NN)rV)fr&r<r?rWr�Ú collectionsr1Úzlibrrír÷rZlzmarr.rnrrrOrUrärçrBrrrqÚ__all__r-rrrrr(r,r)r*r:rFrNrr]rardrrrƒr r r rr¸r Ú stat_resultrÀrÂrÅrÍrqrÆrÇÚsupports_dir_fdr¹Ú supports_fdr�rÓrZavoids_symlink_attacksrÜr rßràrðrôrr#r'rrrrrr@rrrArDrEr;rFrr®Ú namedtuplerNrPrQrOrIrrr`ÚF_OKÚX_OKrr"r"r"r#Ús> ÿ ÿ ÿ      @  @ B ÿB ÿ0  8ÿ þ ý B B  ÿF ÿ?ÿÿÿÿÿ  ÿ<  ÿ  þ ÿ ÿ ÿ 1      1