Spade
Mini Shell
| Directory:~$ /lib/python3.6/site-packages/setuptools/__pycache__/ |
| [Home] [System Details] [Kill Me] |
3
J$�\��@s�dZddlZddlZddlZddlZddlZddlZddlmZddl m
Z
ddddd d
dgZGdd �d e�Zd
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.6/archive_util.pyrscCs|S)z@The
default progress/filter callback; returns True for all
filesr)�src�dstrrrrscCsNxH|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_filterZdriversZdriverrrrrscCs�tjj|�std|��|d|fi}x�tj|�D]�\}}}||\}}x4|D],} || dtjj|| �f|tjj|| �<qLWx\|D]T}
tjj||
�}|||
|�}|s�q�t|�tjj||
�}
tj|
|�tj |
|�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�shutilZcopyfileZcopystat)rrr�paths�base�dirs�filesrr�d�f�targetrrrr
?s
,
c
Cs�tj|�std|f��tj|���}x�|j�D]�}|j}|jd�s.d|jd�krRq.tj j
|f|jd���}|||�}|szq.|jd�r�t|�n4t|�|j
|j�}t|d��}|j|�WdQRX|jd?} | r.tj|| �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�)�zipfileZ
is_zipfilerZZipFileZinfolistr�
startswith�splitrrr�endswithr�read�open�writeZ
external_attr�chmod)
rrr�z�info�namer$�datar#Zunix_attributesrrrrZs(
c
Cshytj|�}Wn$tjk
r2td|f��YnXtj|���dd�|_�x
|D�]}|j}|jd�oxd|j d�krTt
jj|f|j d���}xV|dk r�|j
�s�|j�r�|j}|j�r�tj|j�}tj||�}tj|�}|j|�}q�W|dk rT|j��s|j�rT|||�} | rT| jt
j��r,| dd �} y|j|| �WqTtjk
�rTYqTXqTWdSQRXdS)
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>�sz
unpack_tarfile.<locals>.<lambda>rz..N�T���)�tarfiler,ZTarErrorr�
contextlib�closing�chownr1r(r)rrrZislnkZissymZlinkname� posixpath�dirname�normpathZ
_getmember�isfilerr*�sepZ_extract_memberZExtractError)
rrrZtarobj�memberr1Z
prelim_dstZlinkpathrZ final_dstrrrrs8
)rr'r7rrr;r8Zdistutils.errorsrZ
pkg_resourcesr�__all__rrrr
rrr rrrr�<module>s$
"%.