Re@sdZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z ddddd d d gZ Gd d d eZ d dZedddZedd ZeddZeddZeeefZdS)z/Utilities for extracting common archive formatsN)DistutilsError)ensure_directoryContextualZipFileunpack_archiveunpack_zipfileunpack_tarfiledefault_filterUnrecognizedFormatextraction_driversunpack_directoryc@seZdZdZdS)r z#Couldn't recognize the archive typeN)__name__ __module__ __qualname____doc__rr/builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/archive_util.pyr s cCs|S)z@The default progress/filter callback; returns True for all filesr)srcdstrrrrsc Cs[xT|p tD]6}y||||Wntk r>w Yq XdSq Wtd|dS)aUnpack `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_dirprogress_filterZdriversZdriverrrrrs c Cs3tjj|s"td||d|fi}xtj|D]\}}}||\}}xD|D]<} || dtjj|| f|tjj|| d|jdkrtq>tj j ||jd}|||}|sq>|j drt |nBt ||j |j}t|d}|j|WdQRX|jd?} | r>tj|| q>WWdQRXdS)zUnpack 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 rinfolistr startswithsplitrrrendswithrreadopenwrite external_attrchmod) rrrzinfonamer'datar&Zunix_attributesrrrrZs( $   c Csytj|}Wn(tjk r=td|fYnXtj|~dd|_xc|D][}|j}|jd rdd|j dkrdt j j ||j d}x|dk r7|j s|jr7|j}|jr%tj|j}tj ||}tj|}|j|}qW|dk rd|js\|jrd|||} | rd| jt jr| dd } y|j|| Wqdtjk rYqdXqdWdSWdQRXdS) zUnpack 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 filecWsdS)Nr)argsrrrsz unpack_tarfile..rz..NT)tarfiler1TarErrorr contextlibclosingchownr7r-r.rrrislnkissymlinkname posixpathdirnamenormpath _getmemberisfilerr/sep_extract_member ExtractError) rrrtarobjmemberr7Z prelim_dstlinkpathr"Z final_dstrrrrs8  %'  $ )rr*r=rrrEr?distutils.errorsr pkg_resourcesrr__all__r rrr rrr rrrrs$        "%.