o ¯)»a¥ã@s¼dZddlZddlZddlZddlZddlZddlZddlmZddl m Z gd¢Z Gdd„deƒZ dd „Z e dfd d „Ze fd d „Ze fdd„Zdd„Zdd„Ze fdd„ZeeefZdS)z/Utilities for extracting common archive formatséN)ÚDistutilsError)Úensure_directory)Úunpack_archiveÚunpack_zipfileÚunpack_tarfileÚdefault_filterÚUnrecognizedFormatÚextraction_driversÚunpack_directoryc@seZdZdZdS)rz#Couldn't recognize the archive typeN)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrúJ/opt/alt/python310/lib/python3.10/site-packages/setuptools/archive_util.pyrsrcCs|S)z@The default progress/filter callback; returns True for all filesr)ÚsrcÚdstrrrrsrc Cs@|ptD]}z ||||ƒWdStyYqwtd|ƒ‚)a¡Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path where it will be extracted. The callback must return the desired extract path (which may be the same as the one passed in), or else ``None`` to skip that file or directory. The callback can thus be used to report on the progress of the extraction, as well as to filter the items extracted or alter their extraction paths. `drivers`, if supplied, must be a non-empty sequence of functions with the same signature as this function (minus the `drivers` argument), that raise ``UnrecognizedFormat`` if they do not support extracting the designated archive type. The `drivers` are tried in sequence until one is found that does not raise an error, or until all are exhausted (in which case ``UnrecognizedFormat`` is raised). If you do not supply a sequence of drivers, the module's ``extraction_drivers`` constant will be used, which means that ``unpack_zipfile`` and ``unpack_tarfile`` will be tried, in that order. Nz!Not a recognized archive type: %s)r r)ÚfilenameÚ extract_dirÚprogress_filterZdriversZdriverrrrrs  ýÿÿrc CsÖtj |¡s td|ƒ‚|d|fi}t |¡D]Q\}}}||\}}|D]} || dtj || ¡f|tj || ¡<q$|D]*} tj || ¡} ||| | ƒ} | sPq=t| ƒtj || ¡} t | | ¡t  | | ¡q=qdS)z‡"Unpack" a directory, using the same interface as for archives Raises ``UnrecognizedFormat`` if `filename` is not a directory z%s is not a directoryÚú/N) ÚosÚpathÚisdirrÚwalkÚjoinrÚshutilZcopyfileZcopystat) rrrÚpathsÚbaseÚdirsÚfilesrrÚdÚfÚtargetrrrr @s&  ÿ * ÷ür c Cst |¡s td|fƒ‚t |¡p}| ¡D]b}|j}| d¡s'd| d¡vr(qtj j |g| d¡¢RŽ}|||ƒ}|s=q|  d¡rGt |ƒn$t |ƒ|  |j¡}t|dƒ }| |¡Wdƒn1sfwY|jd?} | rxt || ¡qWdƒdS1s„wYdS)zòUnpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument. z%s is not a zip filerú..ÚwbNé)ÚzipfileZ is_zipfilerZZipFileZinfolistrÚ startswithÚsplitrrrÚendswithrÚreadÚopenÚwriteZ external_attrÚchmod) rrrÚzÚinfoÚnamer$Údatar#Zunix_attributesrrrr[s0         ÿ  €ê"ÿrcCs’|dur5| ¡s | ¡r5|j}| ¡r$t |j¡}t ||¡}t |¡}| |¡}|dur5| ¡s | ¡s |duo@|  ¡p@|  ¡}|rE|St dƒ‚)z;Resolve any links and extract link targets as normal files.NzGot unknown file type) ZislnkZissymZlinknameÚ posixpathÚdirnamer2rÚnormpathZ _getmemberÚisfilerÚ LookupError)Útar_objZtar_member_objZlinkpathrZis_file_or_dirrrrÚ_resolve_tar_file_or_dir€s,ÿÿ    ùÿÿ þr:c csÔdd„|_t |¡U|D]I}|j}| d¡sd| d¡vr qtjj|g| d¡¢RŽ}zt ||ƒ}Wn t y=Yqw|||ƒ}|sFq|  tj ¡rR|dd…}||fVqWdƒdS1scwYdS)z1Emit member-destination pairs from a tar archive.cWsdS)Nr)ÚargsrrrÚ˜sz _iter_open_tar..rr%Néÿÿÿÿ) ÚchownÚ contextlibÚclosingr2r)r*rrrr:r8r+Úsep)r9rrÚmemberr2Z prelim_dstÚ final_dstrrrÚ_iter_open_tar•s*€   ÿ    ì"ÿrDc Csxzt |¡}Wntjy}ztd|fƒ|‚d}~wwt|||ƒD]\}}z| ||¡Wq#tjy9Yq#wdS)zûUnpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument. z/%s is not a compressed or uncompressed tar fileNT)Útarfiler-ZTarErrorrrDZ_extract_memberZ ExtractError)rrrZtarobjÚerBrCrrrr²s&ÿþ€ÿ ÿþr)rr(rErrr4r?Zdistutils.errorsrZ pkg_resourcesrÚ__all__rrrr rr:rDrr rrrrÚs*   þ $ %