Your IP : 18.226.214.1


Current Path : /lib/python3.8/site-packages/setuptools/__pycache__/
Upload File :
Current File : //lib/python3.8/site-packages/setuptools/__pycache__/archive_util.cpython-38.pyc

U

�Qab��@s�dZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddddd	d
dgZGdd	�d	e�Zd
d�Z
e
dfdd�Ze
fdd�Ze
fdd�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�;/usr/lib/python3.8/site-packages/setuptools/archive_util.pyrscCs|S)z@The default progress/filter callback; returns True for all filesr)�src�dstrrrrsc	CsN|ptD]4}z||||�Wntk
r4YqYqXdSqtd|��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_filterZdriversZdriverrrrrs
�cCs�tj�|�std|��|d|fi}t�|�D]�\}}}||\}}|D],}	||	dtj�||	�f|tj�||	�<qH|D]T}
tj�||
�}|||
|�}|s�qzt|�tj�||
�}
t�|
|�t�	|
|�qzq.dS)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$�*c
Cs�t�|�std|f��t�|���}|��D]�}|j}|�d�s,d|�d�krPq,tj	j
|f|�d���}|||�}|sxq,|�d�r�t|�n4t|�|�
|j�}t|d��}|�|�W5QRX|jd?}	|	r,t�||	�q,W5QRXdS)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�..�wb�N)�zipfileZ
is_zipfilerZZipFileZinfolistr�
startswith�splitrrr�endswithr�read�open�writeZ
external_attr�chmod)
rrr�z�info�namer$�datar#Zunix_attributesrrrrZs(




c

Csfzt�|�}Wn$tjk
r2td|f��YnXt�|���dd�|_|D�]�}|j}|�d�sPd|�	d�krPt
jj|f|�	d���}|dk	r�|�
�s�|��r�|j}|��r�t�|j�}t�||�}t�|�}|�|�}q�|dk	rP|���s�|��rP|||�}	|	rP|	�t
j��r"|	dd�}	z|�||	�WqPtjk
�rJYqPXqPW5QR�dSQRXdS)	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 filecWsdS)Nr)�argsrrr�<lambda>��z unpack_tarfile.<locals>.<lambda>rr%N���T)�tarfiler-ZTarErrorr�
contextlib�closing�chownr2r)r*rrrZislnkZissymZlinkname�	posixpath�dirname�normpathZ
_getmember�isfilerr+�sepZ_extract_memberZExtractError)
rrrZtarobj�memberr2Z
prelim_dstZlinkpathrZ	final_dstrrrrs:�




)rr(r8rrr<r9Zdistutils.errorsrZ
pkg_resourcesr�__all__rrrr
rrr	rrrr�<module>s2��
#%.

?>