grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 ”qcpœãA@srdZddlZddlZddlZddlZddlZddlZyddlZ[dZWne k r�dZYnXyddl Z [ dZ Wne k rµdZ YnXyddl Z [ dZ Wne k rédZ YnXyddlmZWne k rdZYnXyddlmZWne k rGdZYnXddd d d d d ddddddddddddddddddgZGd d„deƒZGd!d„deƒZGd"d„deƒZGd#d„deƒZGd$d%„d%eƒZGd&d'„d'eƒZd€d*d„Zd+d,„Zd-dd.d„Zd-dd/d „Zeed0ƒr€d-dd1d2„Z n d3d2„Z d-dd4d „Z!d-dd5d „Z"d-dd6d „Z#d7d„Z$dde#dd8d „Z%d9d:„Z&d;d<„Z'ej(ejej)ej*hej+koFej,ej-koFejej.kZ/ddd=d„Z0e/e0_1d>d?„Z2e#d@d„Z3dAdB„Z4dCdD„Z5dEdF„Z6dGddddddHdI„Z7ddddJdK„Z8dLe7d�gdNfiZ9ere7d‚gdOfe9dPd_d`„Z?ddZdad„Z@dbd„ZAdcdd„ZBdedf„ZCdgdh„ZDdLdigeDgdNfdRdjgeCgdQfiZEerLdkdlgeDgdOfeEdP._nopcstt|ˆƒS)N)Úgetattrr,)rL)rRr r!Úlookup»szcopystat..lookupcs)tt|ˆƒ}|tjkr%|SˆS)N)rSr,Úsupports_follow_symlinks)rLr?)rRr r!rTÀsr8ÚutimerBÚst_flagsZchflagsÚ EOPNOTSUPPrG)rXrG)r,r-r;r8rDr:Ú st_atime_nsÚ st_mtime_nsÚNotImplementedErrorr+rWr.rFrSrN) r1r2r4ZfollowrTr@ÚmodeÚwhyÚerrr )rRr!r­s,+!   'cCs]tjj|ƒr3tjj|tjj|ƒƒ}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. r4)r,r-ÚisdirÚjoinÚbasenamerr)r1r2r4r r r!rãs !cCs]tjj|ƒr3tjj|tjj|ƒƒ}t||d|ƒt||d|ƒ|S)zéCopy data and all stat info ("cp -p 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". r4)r,r-r_r`rarr)r1r2r4r r r!r õs !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}x'ˆD]}|jtj||ƒƒq Wt|ƒS)N)ÚextendÚfnmatchÚfilterÚset)r-rJÚ ignored_namesÚpattern)Úpatternsr r!Ú_ignore_patterns s z)ignore_patterns.._ignore_patternsr )rhrir )rhr!rscCsstj|ƒ}|dk r-|||ƒ}n tƒ}tj|ƒg}x¤|D]œ} | |kreqPtjj|| ƒ} tjj|| ƒ} yátjj| ƒr7tj| ƒ} |ràtj| | ƒt | | d| ƒqotjj | ƒ rü|rüwPtjj | ƒr't | | |||ƒqo|| | ƒn8tjj | ƒrbt | | |||ƒn || | ƒWqPt k r«} z|j| jdƒWYdd} ~ XqPtk rë}z!|j| | t|ƒfƒWYdd}~XqPXqPWyt ||ƒWnYtk r\}z9t|ddƒdkrJ|j||t|ƒfƒWYdd}~XnX|rot |ƒ‚|S)aüRecursively copy a directory tree. The destination directory must not already exist. 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. Nr4rZwinerror)r,ÚlistdirreÚmakedirsr-r`r;r=r<rÚexistsr_r r rbrOr.ÚappendÚstrrS)r1r2ÚsymlinksÚignoreÚ copy_functionZignore_dangling_symlinksrJrfÚerrorsrLZsrcnameZdstnameÚlinktor^r]r r r!r sL$      &3/ c$Cs–y"tjj|ƒr!tdƒ‚Wn2tk rV|tjj|tjƒƒdSYnXg}ytj|ƒ}Wn+tk r�|tj|tjƒƒYnXx²|D]ª}tjj||ƒ}ytj|ƒj }Wntk rðd}YnXt j |ƒrt ||ƒq¥ytj |ƒWq¥tk rN|tj |tjƒƒYq¥Xq¥Wytj|ƒWn+tk r‘|tj|tjƒƒYnXdS)Nz%Cannot call rmtree on a symbolic linkr)r,r-r;r.ÚsysÚexc_inforjr`rCr:r8ÚS_ISDIRÚ_rmtree_unsafeÚunlinkÚrmdir)r-ÚonerrorrJrLÚfullnamer\r r r!rwks6       " rwc 0Cs@g}ytj|ƒ}WnGtk rb}z'||_|tj|tjƒƒWYdd}~XnXxÖ|D]Î}tjj||ƒ}y(tj|d|ddƒ}|j }Wntk rÇd}YnXtj |ƒróytj |tj d|ƒ} Wn+tk r#|tj |tjƒƒYq8Xz»tjj |tj| ƒƒr�t| ||ƒytj|d|ƒWqÞtk r™|tj|tjƒƒYqÞXnAytdƒ‚Wn.tk rÝ|tjj|tjƒƒYnXWdtj| ƒXqjytj|d|ƒWqjtk r7|tj|tjƒƒYqjXqjWdS)NÚdir_fdr4Frz%Cannot call rmtree on a symbolic link)r,rjr.Úfilenamertrur-r`r8r:rvr>ÚO_RDONLYÚsamestatÚfstatÚ_rmtree_safe_fdryr;Úcloserx) Útopfdr-rzrJr^rLr{Úorig_str\Údirfdr r r!r�ŒsD ,      ! % r�c!Cs»|rdd„}n|dkr-dd„}trªt|tƒrQtj|ƒ}ytj|ƒ}Wn/tk r•|tj|tjƒƒdSYnXytj |tj ƒ}Wn/tk rà|tj|tjƒƒdSYnXzµtj j |tj |ƒƒrTt|||ƒytj|ƒWq•tk rP|tj|tjƒƒYq•XnAytdƒ‚Wn.tk r”|tj j|tjƒƒYnXWdtj|ƒXn t||ƒSdS)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. cWsdS)Nr )rOr r r!rzÉszrmtree..onerrorNcWs‚dS)Nr )rOr r r!rzÌsz%Cannot call rmtree on a symbolic link)Ú_use_fd_functionsÚ isinstanceÚbytesr,ÚfsdecoderCÚ Exceptionrtrur>r~r-rr€r�ryr.r;r‚rw)r-Ú ignore_errorsrzr„Úfdr r r!r ½s<        ! %cCs5tjjtjjpd}tjj|j|ƒƒS)NÚ)r,r-ÚsepÚaltsepraÚrstrip)r-rŽr r r!Ú _basenameôsr‘c Cs]|}tjj|ƒrxt||ƒr;tj||ƒdStjj|t|ƒƒ}tjj|ƒrxtd|ƒ‚ytj||ƒWnÊt k rXtjj |ƒrÝtj |ƒ}tj ||ƒtj |ƒnwtjj|ƒr:t||ƒrtd||fƒ‚t||d|ddƒt|ƒn|||ƒtj |ƒYnX|S)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. Nz$Destination path '%s' already existsz.Cannot move a directory '%s' into itself '%s'.rqroT)r,r-r_r3Úrenamer`r‘rlr r.r;r=r<rxÚ _destinsrcr r )r1r2rqZreal_dstrsr r r!r ús2   cCs{tjj|ƒ}tjj|ƒ}|jtjjƒsI|tjj7}|jtjjƒsn|tjj7}|j|ƒS)N)r,r-r0ÚendswithrŽÚ startswith)r1r2r r r!r“2sr“c Cs_tdks|dkrdSyt|ƒ}Wntk rFd}YnX|dk r[|dSdS)z"Returns a gid, given a group name.Né)rÚKeyError)rLÚresultr r r!Ú_get_gid;s   r™c Cs_tdks|dkrdSyt|ƒ}Wntk rFd}YnX|dk r[|dSdS)z"Returns an uid, given a user name.Nr–)rr—)rLr˜r r r!Ú_get_uidGs   ršÚgzipc s–|dkrd}nftr0|dkr0d}nKtrK|dkrKd}n0trf|dkrfd}ntdj|ƒƒ‚d dl} |r—d |nd} |d | } tjj| ƒ} | rtjj | ƒ r|dk rò|j d | ƒ|stj | ƒ|dk r|j d ƒt ˆƒ‰t ˆƒ‰‡‡‡‡fdd†} |s’| j| d|ƒ}z|j|d| ƒWd|jƒX| 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Ú.z.tarz creating %szCreating tar archivecs@ˆdk rˆ|_ˆ|_ˆdk r<ˆ|_ˆ|_|S)N)ÚgidZgnameÚuidÚuname)Ztarinfo)r ÚgroupÚownerr¡r r!Ú _set_uid_gid‚s      z#_make_tarball.._set_uid_gidzw|%srd)Ú_ZLIB_SUPPORTEDÚ_BZ2_SUPPORTEDÚ_LZMA_SUPPORTEDÚ ValueErrorr7Útarfiler,r-ÚdirnamerlÚinforkršr™r>Úaddr‚)Ú base_nameÚbase_dirÚcompressÚverboseÚdry_runr¤r£ÚloggerZtar_compressionrªZ compress_extZ archive_nameÚ archive_dirr¥Útarr )r r£r¤r¡r!Ú _make_tarballSs<                r¶c Csddl}|d}tjj|ƒ}|rptjj|ƒ rp|dk r]|jd|ƒ|sptj|ƒ|dk r�|jd||ƒ|sþ|j|dd|jƒ�K}tjj |ƒ} | tj kr|j | | ƒ|dk r|jd| ƒxôtj |ƒD]ã\} } } xat | ƒD]S} tjj tjj| | ƒƒ} |j | | ƒ|dk r,|jd| ƒq,Wxm| D]e} tjj tjj| | ƒƒ} tjj| ƒrŠ|j | | ƒ|dk rŠ|jd| ƒqŠWqWWdQRX|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. rNz.zipz creating %sz#creating '%s' and adding '%s' to itÚwZ compressionz adding '%s')Úzipfiler,r-r«rlr¬rkÚZipFileZ ZIP_DEFLATEDÚnormpathÚcurdirr'ÚwalkÚsortedr`Úisfile)r®r¯r±r²r³r¸Z zip_filenamer´Zzfr-ÚdirpathZdirnamesÚ filenamesrLr r r!Ú _make_zipfile”s@        !  ! rÁrµr°zuncompressed tar filezgzip'ed tar-fileZgztarzZIP fileÚziprœzbzip2'ed tar-fileZbztarržzxz'ed tar-fileZxztarcCs'dd„tjƒDƒ}|jƒ|S)z‘Returns a list of supported formats for archiving and unarchiving. Each element of the returned sequence is a tuple (name, description) cSs&g|]\}}||df‘qS)r–r )Ú.0rLÚregistryr r r!ú Ös z'get_archive_formats..)Ú_ARCHIVE_FORMATSÚitemsÚsort)Úformatsr r r!rÑs  r�cCs«|dkrg}t|ƒs.td|ƒ‚t|ttfƒsOtdƒ‚xB|D]:}t|ttfƒ s„t|ƒdkrVtdƒ‚qVW|||ft|.)Ú_UNPACK_FORMATSrÇrÈ)rÉr r r!r*s  c Cs›i}x9tjƒD]+\}}x|dD]}|||r'r‚) r}Ú extract_dirr¸rÂr¬rLÚtargetÚdataÚfr r r!Ú_unpack_zipfilegs*     récCsjddl}y|j|ƒ}Wn%|jk rFtd|ƒ‚YnXz|j|ƒWd|jƒXdS)zAUnpack tar/tar.gz/tar.bz2/tar.xz `filename` to `extract_dir` rNz/%s is not a compressed or uncompressed tar file)rªr>ZTarErrorr#Z extractallr‚)r}rårªZtarobjr r r!Ú_unpack_tarfile‰s rêz.tarz.zipz.tar.gzz.tgzz.tar.bz2z.tbz2z.tar.xzz.txzcCsIxBtjƒD]4\}}x%|dD]}|j|ƒr$|Sq$Wq WdS)Nr)rÜrÇr”)r}rLr¬rßr r r!Ú_find_unpack_format¨s  rëcCsæ|dkrtjƒ}|dk rƒyt|}Wn'tk r[tdj|ƒƒ‚YnX|d}|||t|dƒ�n_t|ƒ}|dkr°tdj|ƒƒ‚t|d}tt|dƒ}||||�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. NzUnknown unpack format '{0}'rÓr–zUnknown archive format '{0}') r,rÔrÜr—r©r7Údictrër#)r}rår7r×rØrPr r r!r¯s       ÚstatvfsÚ disk_usageZusageztotal used freecCsVtj|ƒ}|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,ríÚf_bavailÚf_frsizeÚf_blocksÚf_bfreeÚ_ntuple_diskusage)r-r@ÚfreeÚtotalÚusedr r r!rîÙs ÚntcCs/tj|ƒ\}}||}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. )r÷Z _getdiskusageró)r-rõrôrör r r!rîës cCsé|dkr$|dkr$tdƒ‚|}|}|dkrEd}n<t|tƒr�t|ƒ}|dkr�tdj|ƒƒ‚|dkr–d}n<t|tƒsÒt|ƒ}|dkrÒtdj|ƒƒ‚tj |||ƒ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. Nzuser and/or group must be setrÓzno such user: {!r}zno such group: {!r}éÿÿÿÿrø) r©r‡rnršÚ LookupErrorr7Úintr™r,r)r-Úuserr£Z_userZ_groupr r r!rös"         éPécCsyttjdƒ}Wnttfk r7d}YnXyttjdƒ}Wnttfk rod}YnX|dksˆ|dkrûytjtjjƒƒ}Wn*t tt fk rÐtj |ƒ}YnX|dkræ|j }|dkrû|j }tj ||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)rúr,Úenvironr—r©rrtÚ __stdout__ÚfilenoÚAttributeErrorr.Ú terminal_sizeÚcolumnsÚlines)ZfallbackrrÚsizer r r!rs$      c s™dd„}tjjˆƒr5|ˆ|ƒr1ˆSdS|dkrYtjjdtjƒ}|scdS|jtjƒ}tj dkrtj |kr¦|j dtj ƒtjjddƒjtjƒ}t ‡fd d †|Dƒƒròˆg}q‡fd d †|Dƒ}n ˆg}t ƒ}xr|D]j}tjj|ƒ}||kr'|j|ƒx6|D].} tjj|| ƒ} || |ƒr_| Sq_Wq'WdS) 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. cSs5tjj|ƒo4tj||ƒo4tjj|ƒ S)N)r,r-rlÚaccessr_)r?r\r r r!Ú _access_checkOs$zwhich.._access_checkNÚPATHÚwin32rZPATHEXTr�c3s*|] }ˆjƒj|jƒƒVqdS)N)Úlowerr”)rÃrÞ)Úcmdr r!ú lszwhich..csg|]}ˆ|‘qSr r )rÃrÞ)r r r!rÅos zwhich..)r,r-r«rþÚgetÚdefpathräÚpathseprtÚplatformr»ÚinsertÚanyrer/r­r`) r r\r-rZpathextÚfilesÚseenÚdirZnormdirZthefilerLr )r r!rBs8  !        i@)r°N)r°r›)r°rœ)r°rž)rürý)Sr"r,rtr8rcÚ collectionsrFÚzlibr¦Ú ImportErrorr�r§Zlzmar¨ÚpwdrZgrprÚ__all__r.r rrrr#rŠr$rr3rrr+rNrrr rr rwr�r>rxryÚsupports_dir_fdrjÚ supports_fdrUr†r Zavoids_symlink_attacksr‘r r“r™ršr¶rÁrÆrrrrrrárrrârérêrÜrërrmÚ namedtuplerórîrLr÷rrÚF_OKÚX_OKrr r r r!Úsø                           6 Y ! , 5  8 @-         6    "     %     -