HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/utils/__pycache__/unpacking.cpython-310.pyc
o

@%Ne�"�	@s�dZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZddlm
Z
ddlmZmZmZmZddlmZe�e�ZeeZz
ddlZee7ZWneyce�d�Ynwz
ddlZee7ZWney|e�d	�Ynwd
efdd�Zd
ed
e	efdd�Z deed
e!fdd�Z"deded
e!fdd�Z#d
ed
dfdd�Z$ded
e!fdd�Z%d'dedede!d
dfd d!�Z&deded
dfd"d#�Z'	d(deded$e
ed
dfd%d&�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 available�returncCst�d�}t�|�|S)zBGet the current umask which involves having to set it temporarily.r)�os�umask)�mask�r�?/usr/lib/python3/dist-packages/pip/_internal/utils/unpacking.py�
current_umask+s

r�pathcCsd|�d��d�}d|vr$d|vr|�d�|�d�ksd|vr$|�dd�Sd|vr.|�dd�S|dgS)N�/�\��)�lstrip�find�split�rrrr�split_leading_dir2s$r�pathscCsDd}|D]}t|�\}}|sdS|dur|}q||krdSqdS)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�restrrr�has_leading_dir>s�r!�	directory�targetcCs0tj�|�}tj�|�}tj�||g�}||kS)zL
    Return true if the absolute path of target is within the directory
    )r
r�abspath�commonprefix)r"r#�
abs_directory�
abs_targetrrrr�is_within_directoryMsr(cCst�|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��IN)r
�chmodrrrrr�2set_extracted_file_to_default_mode_plus_executableXsr+�infocCs$|jd?}t|ot�|�o|d@�S)N�r))�
external_attr�bool�stat�S_ISREG)r,�moderrr�zip_item_is_executable`s
r3T�filename�location�flattenc
	CsJt|�t|d�}z�tj|dd�}t|���o|}|��D]{}|j}|}|r,t|�d}t	j
�||�}t	j
�|�}	t
||�sId}
t|
�|||���|�d�sS|�d�rXt|�qt|	�|�|�}z)t|d��}t�||�Wd	�n1sxwYW|��t|�r�t|�q|��t|�r�t|�wwW|��d	S|��w)
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)�
allowZip64rzQThe zip file ({}) has a file ({}) trying to install outside target directory ({})rr�wbN)r�open�zipfile�ZipFiler!�namelist�infolistr4rr
r�join�dirnamer(r�format�endswith�shutil�copyfileobj�closer3r+)
r4r5r6�zipfp�zip�leadingr,�name�fn�dir�message�fp�destfprrr�
unzip_filegsF	

�

����
��rOcCs.t|�|���d�s|���d�rd}n&|���t�rd}n|���t�r)d}n|���d�r3d}nt�d|�d	}tj||d
d�}z�t	dd
�|�
�D��}|�
�D]�}|j}|r`t|�d}t
j�||�}t||�swd}t|�|||���|��r�t|�qS|��r�z|�||�WqSty�}	zt�d||j|	�WYd}	~	qSd}	~	wwz|�|�}
Wnttfy�}	zt�d||j|	�WYd}	~	qSd}	~	wwtt
j�|��|
dus�J�t|d��}t�|
|�Wd�n1s�wY|
��|�||�|jd@�r
t |�qSW|��dS|��w)a�
    Untar 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.
    z.gzz.tgzzr:gzzr:bz2zr:xzz.tar�rz-Cannot determine compression type for file %szr:*zutf-8)�encodingcSsg|]}|j�qSr)rI)�.0�memberrrr�
<listcomp>�szuntar_file.<locals>.<listcomp>rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})z/In the tar file %s the member %s is invalid: %sNr9r))!r�lowerrBrr	�logger�warning�tarfiler:r!�
getmembersrIrr
rr?r(rrA�isdir�issym�_extract_member�	Exception�extractfile�KeyError�AttributeErrorr@rCrDrE�utimer2r+)r4r5r2�tarrHrSrJrrL�excrMrNrrr�
untar_file�s�	�
�
������
���3rd�content_typecCs�tj�|�}|dks|���t�st�|�r#t|||�d�d�dS|dks7t	�
|�s7|���ttt
�r>t||�dSt�d|||�td|����)Nzapplication/zipz.whl)r6zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )r
r�realpathrUrBr
r;�
is_zipfilerOrX�
is_tarfilerrr	rdrV�criticalr)r4r5rerrr�unpack_file�s(�����rj)T)N))�__doc__�loggingr
rCr0rXr;�typingrrrr�pip._internal.exceptionsr�pip._internal.utils.filetypesrrr	r
�pip._internal.utils.miscr�	getLogger�__name__rV�SUPPORTED_EXTENSIONS�bz2�ImportError�debug�lzma�intr�strrr/r!r(r+r3rOrdrjrrrr�<module>sX
��.T�����