/usr/local/lib/python3.9/site-packages/pip/_internal/utils/__pycache__
a ���h�. � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z ddl mZ ddl mZ ddl mZ ddlmZmZmZmZ ddlmZ e�e�Zee ZzddlZee7 ZW n ey� e�d � Y n0 zddlZee7 ZW n e�y e�d � Y n0 dd�d d�Zddd�dd�Zddd�dd�Z dddd�dd�Z!dd�dd�Z"ddd�dd �Z#d!dd"�d#d$�Z$d4ddddd&�d'd(�Z%dddd)�d*d+�Z&ddd,ddd-�d.d/�Z'd5ddd0dd1�d2d3�Z(dS )6zUtilities related archives.� )�annotationsN)�Iterable)�ZipInfo)�InstallationError)�BZ2_EXTENSIONS�TAR_EXTENSIONS� XZ_EXTENSIONS�ZIP_EXTENSIONS)� ensure_dirzbz2 module is not availablezlzma module is not available�int)�returnc C s t �d�} t �| � | S )zBGet the current umask which involves having to set it temporarily.r )�os�umask)�mask� r �G/usr/local/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py� current_umask- s r �strz list[str])�pathr c C sh | � d�� d�} d| v rHd| v r4| �d�| �d�k s<d| vrH| �dd�S d| v r\| �dd�S | dgS d S )N�/�\� � )�lstrip�find�split�r r r r �split_leading_dir4 s ���r z Iterable[str]�bool)�pathsr c C sD d}| D ]6}t |�\}}|s" dS |du r0|}q||kr dS qdS )zyReturns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)NFT)r )r � common_prefixr �prefix�restr r r �has_leading_dir@ s r# )� directory�targetr c C s0 t j�| �}t j�|�}t j�||g�}||kS )zL Return true if the absolute path of target is within the directory )r r �abspath�commonprefix)r$ r% � abs_directory� abs_targetr! r r r �is_within_directoryO s r* c C s dt � @ dB S )Ni� �I )r r r r r �!_get_default_mode_plus_executableZ s r, �Nonec C s t �| t� � dS )zx Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs N)r �chmodr, r r r r �2set_extracted_file_to_default_mode_plus_executable^ s r/ r )�infor c C s$ | j d? }t|o t�|�o |d@ �S )N� r+ )� external_attrr �stat�S_ISREG)r0 �moder r r �zip_item_is_executablef s r6 T)�filename�location�flattenr c C sH t |� t| d�}�z$tj|dd�}t|�� �o2|}|�� D ]�}|j}|}|rZt|�d }t j �||�}t j �|�} t ||�s�d} t| �| ||���|�d�r�t |� q<t | � |�|�}zTt|d��}t�||� W d � n1 s�0 Y W |�� t|��r,t|� q<|�� t|��r*t|� 0 q<W |�� n |�� 0 dS ) a� Unzip the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Note that for windows, any execute changes using os.chmod are no-ops per the python docs. �rbT)� allowZip64r zQThe zip file ({}) has a file ({}) trying to install outside target directory ({}))r r �wbN)r �open�zipfile�ZipFiler# �namelist�infolistr7 r r r �join�dirnamer* r �format�endswith�shutil�copyfileobj�closer6 r/ ) r7 r8 r9 �zipfp�zip�leadingr0 �name�fn�dir�message�fp�destfpr r r � unzip_filem s<