HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-38.pyc
U

�{�eu"�@s�dZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZddlm
Z
ddlmZmZmZmZddlmZe�e�ZeeZzddlZee7ZWnek
r�e�d�YnXzddlZee7ZWnek
r�e�d	�YnXed
�dd�Zee	ed
�dd�Z eee!d�dd�Z"eee!d�dd�Z#edd
�dd�Z$ee!d�dd�Z%d%eee!dd�dd�Z&eedd�d d!�Z'd&eee
edd"�d#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�A/tmp/pip-unpacked-wheel-_0scjqea/pip/_internal/utils/unpacking.py�
current_umask+s

r)�pathrcCsh|�d��d�}d|krHd|kr4|�d�|�d�ks<d|krH|�dd�Sd|kr\|�dd�S|dgSdS)N�/�\��)�lstrip�find�split�rrrr�split_leading_dir2s���r)�pathsrcCsDd}|D]6}t|�\}}|s"dS|dkr0|}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�targetrcCs0tj�|�}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+)�inforcCs$|jd?}t|o t�|�o |d@�S)N�r))�
external_attr�bool�stat�S_ISREG)r,�moderrr�zip_item_is_executable`s
r3T)�filename�location�flattenrc

Cst|�t|d�}z�tj|dd�}t|���o0|}|��D]�}|j}|}|rXt	|�d}t
j�||�}t
j�
|�}	t||�s�d}
t|
�|||���|�d�s�|�d�r�t|�q:t|	�|�|�}z&t|d��}t�||�W5QRXW5|��t|��rt|�Xq:W5|��Xd	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)�
allowZip64rzQThe zip file ({}) has a file ({}) trying to install outside target directory ({})rr�wbN)r�open�close�zipfile�ZipFiler!�namelist�infolistr4rr
r�join�dirnamer(r�format�endswithr3r+�shutil�copyfileobj)
r4r5r6�zipfp�zip�leadingr,�name�fn�dir�message�fp�destfprrr�
unzip_filegs6	

�


rO)r4r5rcCs.t|�|���d�s$|���d�r*d}nL|���t�r>d}n8|���t�rRd}n$|���d�rfd}nt�d|�d	}tj||d
d�}�z�t
dd
�|��D��}|��D�]p}|j}|r�t
|�d}tj�||�}t||�s�d}t|�|||���|���rt|�q�|���rbz|�||�Wn>tk
�r^}	zt�d||j|	�WY�q�W5d}	~	XYnXq�z|�|�}
WnBttfk
�r�}	zt�d||j|	�WY�q�W5d}	~	XYnXttj�|��|
dk	�s�t�t|d��}t�|
|�W5QRX|
�	�|�||�|j d@r�t!|�q�W5|�	�XdS)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�lowerrCrr	�logger�warning�tarfiler:r;r!�
getmembersrIrr
rr@r(rrB�isdir�issym�_extract_member�	Exception�extractfile�KeyError�AttributeErrorrA�AssertionErrorrDrE�utimer2r+)r4r5r2�tarrHrSrJrrL�excrMrNrrr�
untar_file�st	�
�


��
re)r4r5�content_typercCs�tj�|�}|dks,|���t�s,t�|�rDt|||�d�d�nR|dkslt	�
|�sl|���ttt
�rxt||�nt�d|||�td|����dS)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�realpathrUrCr
r<�
is_zipfilerOrX�
is_tarfilerrr	rerV�criticalr)r4r5rfrrr�unpack_file�s,�������rk)T)N))�__doc__�loggingr
rDr0rXr<�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+r3rOrerkrrrr�<module>sL
.S��