File: //usr/lib/python3.9/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-39.pyc
a
g��eN$ � @ sJ d Z ddlZddlZddlZddlZddlZddlZddlmZm Z m
Z
ddlmZ ddlm
Z
ddlmZmZmZmZ ddlmZ e�e�Zee ZzddlZee7 ZW n ey� e�d� Y n0 zddlZee7 ZW n ey� e�d � Y n0 d
d� Zdd
� Zdd� Zdd� Z dd� Z!dd� Z"ddd�Z#dd� Z$ddd�Z%dS )zUtilities related archives.
� N)�Iterable�List�Optional)�ZipInfo)�InstallationError)�BZ2_EXTENSIONS�TAR_EXTENSIONS�
XZ_EXTENSIONS�ZIP_EXTENSIONS)�
ensure_dirzbz2 module is not availablezlzma module is not availablec C s t �d�} t �| � | S )zBGet the current umask which involves having to set it temporarily.r )�os�umask)�mask� r �A/usr/lib/python3.9/site-packages/pip/_internal/utils/unpacking.py�
current_umask+ s
r 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��pathr r r �split_leading_dir3 s ���r 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 )�pathsZ
common_prefixr �prefix�restr r r �has_leading_dir@ s r 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)Z directory�targetZ
abs_directoryZ
abs_targetr r r r �is_within_directoryP s r# c C s t �| dt� @ dB � dS )zx
Make file present at path have execute for user/group/world
(chmod +x) is no-op on windows per python docs
i� �I N)r �chmodr r r r r �2set_extracted_file_to_default_mode_plus_executable\ s r&