B ‘–Re¥ã@sÆdZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddddd d d gZ Gd d „d eƒZ d d„Z e dfdd„Ze fdd „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ú/builddir/build/BUILDROOT/alt-python37-setuptools-58.3.0-4.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/setuptools/archive_util.pyrscCs|S)z@The default progress/filter callback; returns True for all filesr)ÚsrcÚdstrrrrsc CsNxH|ptD]0}y||||ƒWntk r4w Yq XdSq Wtd|ƒ‚dS)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_filterZdriversZdriverrrrrsc Csâtj |¡std|ƒ‚|d|fi}x¸t |¡D]ª\}}}||\}}x4|D],} || dtj || ¡f|tj || ¡<qLWx\|D]T} tj || ¡} ||| | ƒ} | s¨q‚t| ƒtj || ¡} t | | ¡t  | | ¡q‚Wq0WdS)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ÚshutilÚcopyfileÚcopystat) rrrÚpathsÚbaseÚdirsÚfilesrrÚdÚfÚtargetrrrr @s      ,  c Csît |¡std|fƒ‚t |¡Â}xº| ¡D]®}|j}| d¡s.d| d¡krRq.tj j |f| d¡žŽ}|||ƒ}|szq.|  d¡rŽt |ƒn4t |ƒ|  |j¡}t|dƒ}| |¡WdQRX|jd?} | r.t || ¡q.WWdQRXdS)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 filerz..ÚwbNé)ÚzipfileÚ is_zipfilerÚZipFileÚinfolistrÚ startswithÚsplitrrrÚendswithrÚreadÚopenÚwriteÚ external_attrÚchmod) rrrÚzÚinfoÚnamer&Údatar%Zunix_attributesrrrr[s(        cCs„xV|dk rV| ¡s| ¡rV|j}| ¡rJt |j¡}t ||¡}t |¡}| |¡}qW|dk on|  ¡pn|  ¡}|rx|St dƒ‚dS)z;Resolve any links and extract link targets as normal files.NzGot unknown file type) ÚislnkÚissymÚlinknameÚ posixpathÚdirnamer7rÚnormpathÚ _getmemberÚisfilerÚ LookupError)Útar_objZtar_member_objÚlinkpathr!Zis_file_or_dirrrrÚ_resolve_tar_file_or_dir€s    rDc csÂdd„|_t |¡¤xœ|D]”}|j}| d¡sd| d¡kr@qtjj|f| d¡žŽ}yt ||ƒ}Wnt k r|wYnX|||ƒ}|sŽq|  tj ¡r¦|dd…}||fVqWWdQRXdS)z1Emit member-destination pairs from a tar archive.cWsdS)Nr)ÚargsrrrÚ˜óz _iter_open_tar..rz..Néÿÿÿÿ) ÚchownÚ contextlibÚclosingr7r-r.rrrrDrAr/Úsep)rBrrÚmemberr7Z prelim_dstÚ final_dstrrrÚ_iter_open_tar•s"      rOc CsŠyt |¡}Wn4tjk rB}ztd|fƒ|‚Wdd}~XYnXx@t|||ƒD]0\}}y| ||¡WqRtjk r€YqRXqRWdS)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)Útarfiler1ÚTarErrorrrOÚ_extract_memberÚ ExtractError)rrrÚtarobjÚerMrNrrrr²s  )rr)rPrrr<rJÚdistutils.errorsrÚ pkg_resourcesrÚ__all__rrrr rrDrOrr rrrrÚs(    "  %