File: //usr/local/lib/python3.10/dist-packages/pip/_internal/utils/__pycache__/unpacking.cpython-310.pyc
o
��h�. � @ s~ d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z ddl
mZ ddl mZ ddl
mZ ddlmZmZmZmZ ddlmZ e�e�Zee Zz
ddlZee7 ZW n eyi e�d � Y nw z
ddlZee7 ZW n ey� e�d
� Y nw d7d
d�Zd8dd�Zd9dd�Z d:dd�Z!d7dd�Z"d;d d!�Z#d<d$d%�Z$d=d>d*d+�Z%d?d,d-�Z&d@d1d2�Z' dAdBd5d6�Z(dS )CzUtilities related archives.� )�annotationsN)�Iterable)�ZipInfo)�InstallationError)�BZ2_EXTENSIONS�TAR_EXTENSIONS�
XZ_EXTENSIONS�ZIP_EXTENSIONS)�
ensure_dirzbz2 module is not availablezlzma module is not available�return�intc C s t �d�} t �| � | S )zBGet the current umask which involves having to set it temporarily.r )�os�umask)�mask� r �H/usr/local/lib/python3.10/dist-packages/pip/_internal/utils/unpacking.py�
current_umask- s
r �path�str� list[str]c C sd | � d�� d�} d| v r$d| v r| �d�| �d�k sd| vr$| �dd�S d| v r.| �dd�S | dgS )N�/�\� � )�lstrip�find�split�r r r r �split_leading_dir4 s $r �paths�
Iterable[str]�boolc C sD d}| D ]}t |�\}}|s dS |du r|}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�targetc 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&