HEX
Server: Apache
System: Linux insrv.serversdaddy.com 5.14.0-362.24.2.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Sat Mar 30 14:11:54 EDT 2024 x86_64
User: jsaha (1066)
PHP: 8.3.6
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3.9/site-packages/pip/_internal/utils/__pycache__/unpacking.cpython-39.pyc
a

g��eN$�@sJdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
ddlmZddlm
Z
ddlmZmZmZmZddlmZe�e�ZeeZzddlZee7ZWney�e�d�Yn0zddlZee7ZWney�e�d	�Yn0d
d�Zdd
�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 availablecCst�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

rcCsh|�d��d�}d|vrHd|vr4|�d�|�d�ks<d|vrH|�dd�Sd|vr\|�dd�S|dgSdS)N�/�\��)�lstrip�find�split��pathrrr�split_leading_dir3s���rcCsDd}|D]6}t|�\}}|s"dS|dur0|}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)�pathsZ
common_prefixr�prefix�restrrr�has_leading_dir@srcCs0tj�|�}tj�|�}tj�||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_targetrrrr�is_within_directoryPs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_executable\sr&cCs$|jd?}t|o t�|�o |d@�S)N�r$)Z
external_attr�bool�stat�S_ISREG)�info�moderrr�zip_item_is_executablees
r-Tc
	CsRt|�t|d�}�z.tj|dd�}t|���o2|}|��D]�}|j}|}|rZt|�d}t	j
�||�}t	j
�|�}	t
||�s�d}
t|
�|||���|�d�s�|�d�r�t|�q<t|	�|�|�}zTt|d��}t�||�Wd	�n1s�0YW|��t|��r6t|�q<|��t|��r4t|�0q<W|��n
|��0d	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)Z
allowZip64rzQThe zip file ({}) has a file ({}) trying to install outside target directory ({})rr�wbN)r�open�zipfile�ZipFilerZnamelist�infolist�filenamerrr�join�dirnamer#r�format�endswith�shutil�copyfileobj�closer-r&)
r4�location�flattenZzipfp�zip�leadingr+�name�fn�dir�message�fp�destfprrr�
unzip_filems<


�

,

�
rFc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�]�}|j}|r�t|�d}t
j�||�}t||�s�d}t|�|||���zt�|j|d�|�Wntj�y Yn0|���r6t|�q�|���r�z|�||�WnDt�y�}	z*t�d||j|	�WYd}	~	q�WYd}	~	n
d}	~	00q�z|�|�}
WnHttf�y�}	z*t�d||j|	�WYd}	~	q�WYd}	~	n
d}	~	00tt
j�|��|
du�sJ�t|d��}t�|
|�Wd�n1�s<0Y|
� �|�!||�|j"d@r�t#|�q�W|� �n
|� �0dS)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�r@)�.0�memberrrr�
<listcomp>��zuntar_file.<locals>.<listcomp>rzQThe tar file ({}) has a file ({}) trying to install outside target directory ({})rIz/In the tar file %s the member %s is invalid: %sNr/r$)$r�lowerr8rr	�loggerZwarning�tarfiler0rZ
getmembersr@rrrr5r#rr7Zdata_filter�replaceZLinkOutsideDestinationError�isdirZissymZ_extract_member�	ExceptionZextractfile�KeyError�AttributeErrorr6r9r:r;�utimer,r&)r4r<r,�tarr?rKrArrC�excrDrErrr�
untar_file�s|
�
�


�$�",
rYcCs�tj�|�}|dks,|���t�s,t�|�rDt|||�d�d�nR|dkslt	�
|�sl|���ttt
�rxt||�nt�d|||�td|����dS)Nzapplication/zipz.whl)r=zapplication/x-gzipzZCannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formatz#Cannot determine archive format of )rr�realpathrNr8r
r1�
is_zipfilerFrPZ
is_tarfilerrr	rYrOZcriticalr)r4r<Zcontent_typerrr�unpack_file�s,�������r\)T)N)&�__doc__Zloggingrr9r)rPr1�typingrrrrZpip._internal.exceptionsrZpip._internal.utils.filetypesrrr	r
Zpip._internal.utils.miscrZ	getLogger�__name__rOZSUPPORTED_EXTENSIONS�bz2�ImportError�debug�lzmarrrr#r&r-rFrYr\rrrr�<module>sB

	
/\�