← Back
Editing: archive_util.cpython-312.pyc
� $��j�# � �� � d Z ddlZddlZddlZddlZddlZddlZddlZddlm Z ddl mZ g d�Z G d� de� Z G d � d e� Zd� Zd� Zedf dd�Zefdd�Zefdd�Zefd�Zd� Zd� Zefd efd�ZeeefZy)z/Utilities for extracting common archive formats� N� )�ensure_directory)�DistutilsError)�UnrecognizedFormat�UnsafeMember�default_filter�extraction_drivers�unpack_archive�unpack_directory�unpack_tarfile�unpack_zipfilec � � e Zd ZdZy)r z#Couldn't recognize the archive typeN��__name__� __module__�__qualname__�__doc__� � �S/root/parts/certbot/install/lib/python3.12/site-packages/setuptools/archive_util.pyr r s � �-r r c � � e Zd ZdZy)r a An archive member that would be extracted outside the destination Deliberately not an `UnrecognizedFormat`, which ``unpack_archive`` catches to fall through to the next driver; an unsafe member must abort the extraction rather than hand the archive to another driver. Nr r r r r r s � �r r c � � |S )z@The default progress/filter callback; returns True for all filesr )�src�dsts r r r ( s � ��Jr c � � |j d� sd|v st j |� d rt |�d| ��� �|j d� }d|v rt |�d| ��� �t j j | g|��� }t j j | � }t j j |� }||k7 r?|j t j j |d� � st |�d| ��� �|S )a� Return the path where archive member `name` belongs under `extract_dir`, raising `UnsafeMember` if the member would be written outside of it. Both the tar and zip formats specify '/' as the only path separator, so a backslash is never a legitimate separator in a member name and must not be allowed to act as one on Windows (GHSA-grgh-hr87-3jpw). Names that are absolute, drive-qualified, or UNC are rejected for the same reason. A directory member keeps its trailing separator, as callers rely on it to distinguish a directory from a file. >>> _resolve_dest('dest', 'sub/file.txt') == os.path.join('dest', 'sub', 'file.txt') True >>> _resolve_dest('dest', 'sub/dir/') == os.path.join('dest', 'sub', 'dir', '') True >>> _resolve_dest('dest', '..\\escaped.txt') Traceback (most recent call last): ... setuptools.archive_util.UnsafeMember: '..\\escaped.txt' would be extracted outside of 'dest' �/�\r z would be extracted outside of z..� ) � startswith�ntpath� splitdriver �split�os�path�join�realpath)�extract_dir�name�parts�dest�root�resolveds r � _resolve_destr- - s� � �, ���s��t�t�|�v�/@�/@��/F�q�/I��d�X�%D�[�O�T�U�U��J�J�s�O�E��u�}��d�X�%D�[�O�T�U�U� �7�7�<�<��,�e�,�D� �7�7���K�(�D��w�w����%�H��4��� 3� 3�B�G�G�L�L��r�4J� K��d�X�%D�[�O�T�U�U��Kr �returnc �r � |xs t D ] } || ||� y t d| � �� �# t $ r Y �*w xY w)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. NzNot a recognized archive type: )r r )�filenamer'