관리-도구
편집 파일: unpacking.cpython-37.pyc
B ��Re% � @ st d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl m Z ddlmZm Z mZmZ ddlmZ ddlmZ er�ddlmZmZmZmZmZ dd lmZ e�e�Zee ZyddlZee7 ZW n e k r� e�!d � Y nX yddl"Z"ee7 ZW n e k �r" e�!d� Y nX dd � Z#dd� Z$dd� Z%dd� Z&dd� Z'dd� Z(ddd�Z)dd� Z*d dd�Z+dS )!zUtilities related archives. � )�absolute_importN)�InstallationError)�BZ2_EXTENSIONS�TAR_EXTENSIONS� XZ_EXTENSIONS�ZIP_EXTENSIONS)� ensure_dir)�MYPY_CHECK_RUNNING)�Iterable�List�Optional�Text�Union)�ZipInfozbz2 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 ��/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/utils/unpacking.py� current_umask/ s r c C sh | � d�� d�} d| krHd| kr4| �d�| �d�k s<d| krH| �dd�S d| kr\| �dd�S | dgS d S )N�/�\� � )�lstrip�find�split)�pathr r r �split_leading_dir7 s r c C sD d}x:| D ]2}t |�\}}|s"dS |dkr0|}q ||kr dS q W dS )zyReturns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)NFT)r )�paths� common_prefixr �prefix�restr r r �has_leading_dirG 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)� directory�target� abs_directory� abs_targetr! r r r �is_within_directoryW 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_executablec s r- c C s$ | j d? }t|o t�|�o |d@ �S )N� r+ )� external_attr�bool�stat�S_ISREG)�info�moder r r �zip_item_is_executablel s r5 Tc C s t |� t| d�}z�tj|dd�}t|�� �o0|}x�|�� D ]�}|j}|}|rZt|�d }t j �||�}t j �|�} t ||�s�d} t| �| ||���|�d�s�|�d�r�t |� q<t | � |�|�}z&t|d��}t�||� W d Q R X W d |�� t|��rt|� X q<W W d |�� X d S ) 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�infolist�filenamer r r �join�dirnamer* r �format�endswith�shutil�copyfileobj�closer5 r- ) r>