Your IP : 216.73.216.213


Current Path : /opt/alt/python310/lib/python3.10/site-packages/wheel/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib/python3.10/site-packages/wheel/__pycache__/wheelfile.cpython-310.pyc

o

��a��@s�ddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZ
ddlmZmZmZddlmZddlmZmZmZmZmZmZe�dej�Zd
d	d
�ZGdd�de�ZdS)�)�print_functionN)�OrderedDict)�log)�ZIP_DEFLATED�ZipInfo�ZipFile)�
WheelError)�urlsafe_b64decode�
as_unicode�native�urlsafe_b64encode�as_bytes�StringIOzt^(?P<namever>(?P<name>.+?)-(?P<ver>.+?))(-(?P<build>\d[^-]*))?
     -(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)\.whl$cCs,ttj�d|p
t����}t�|�dd�S)N�SOURCE_DATE_EPOCHr�)�int�os�environ�get�time�gmtime)�	timestamp�r�B/opt/alt/python310/lib/python3.10/site-packages/wheel/wheelfile.py�get_zipinfo_datetimesrc@sReZdZdZejZdefdd�Zddd�Z	dd	�Z
dd
d�Zddd
�Zdd�Z
dS)�	WheelFilez�A ZipFile derivative class that also reads SHA-256 hashes from
    .dist-info/RECORD and checks any read files against those.
    �rc
Cs�tj�|�}t�|�|_|�d�r|jdurtd�|���t	j
||||dd�d�|j�d��|_|jd|_
t�|_i|_|dkr�d	|j|j
<d	|j|j
d
<d	|j|j
d<z|�|j
�}Wntyotd�|j
���w|�T|D]H}|�d
�}|�dd�\}}}	|r�|�d�\}
}zt�|
�Wnty�td�|
���w|
��dvr�td�|
���|
t|�d��f|j|<quWd�dS1s�wYdSdS)Nz.whlzBad wheel filename {!r}T)�compression�
allowZip64z{}.dist-infoZnameverz/RECORDr�NNz.jwsz.p7szMissing {} filezutf-8�,��=zUnsupported hash algorithm: {}>Zsha1Zmd5z4Weak hash algorithm ({}) is not permitted by PEP 427�ascii)r�path�basename�
WHEEL_INFO_RE�matchZparsed_filename�endswithr�formatr�__init__�groupZdist_info_path�record_pathr�_file_hashes�_file_sizes�open�KeyError�decode�rsplit�split�hashlib�new�
ValueError�lowerr	�encode)�self�file�moderr%�record�liner$Zhash_sum�size�	algorithmrrrr*&sP�
��
���"��zWheelFile.__init__Ncs�d�����fdd�	}tt|t�r|jn|��|dkr.��d�s.�|jvr.td�t�����t	�
||||��|dkrV��d�sV|j�\}��durVt�|���j
|��_
�S)NcsV|dur�j}�|�n�||���|�|r'����kr)td�t�����dSdS)NzHash mismatch for file '{}')�_eof�update�digestrr)r)�newdata�eof�ZefZef_nameZ
expected_hashZrunning_hashZupdate_crc_origrr�_update_crcRs


�z#WheelFile.open.<locals>._update_crcr�/zNo hash found for file '{}'�N)r
�
isinstancer�filenamer(r-rr)rrr/r4r5rF)r9Zname_or_infor;�pwdrFr?rrErr/Qs�
zWheelFile.openc	Cs�t�d|j|�g}t�|�D]G\}}}|��t|�D]9}tj�tj�	||��}tj�
|�rUtj�||��tjj
d�}||jkrBq|�d�rO|�||f�q|�||�qq|��|D]
\}}|�||�q]dS)Nz#creating '%s' and adding '%s' to itrGz
.dist-info)�logger�inforJr�walk�sort�sortedr$�normpath�join�isfile�relpath�replace�sepr,r(�append�write)	r9�base_dirZdeferred�root�dirnames�	filenames�namer$�arcnamerrr�write_filesls&

���zWheelFile.write_filescCs�t|d��}t�|���}|��}Wd�n1swYt|p$|t|j�d�}t�	|j
�t�|j
�Bd>|_|p>|j
|_|�|||�dS)N�rb��	date_time�)r/r�fstat�fileno�readrr�st_mtime�stat�S_IMODE�st_mode�S_IFMT�
external_attrr�
compress_type�writestr)r9rJr^rm�f�st�data�zinforrrrX�s
�zWheelFile.writecCsvt�||||�t|t�r|jn|}t�d|�||jkr9|�|�}|j	t
t|����f|j
|<t|�|j|<dSdS)Nzadding '%s')rrnrIrrJrLrMr,�_default_algorithmr]rrrBr-�lenr.)r9�zinfo_or_arcname�bytesrm�fname�hash_rrrrn�s�

�zWheelFile.writestrcs��jdurN�jdkrN�jrNt�}tj|dddd�}|��fdd��j��D��|�t	�j
�ddf�tt�j
�t
�d	�}�j|_d
|_��|t|����t���dS)N�wr �"�
)�	delimiterZ	quotecharZlineterminatorc3s0�|]\}\}}||d|�j|fVqdS)r"N)r.)�.0rwr?rx�r9rr�	<genexpr>�s�
�
�
�z"WheelFile.close.<locals>.<genexpr>�rai�)�fpr;r-r�csv�writerZ	writerows�itemsZwriterowr)r,rrrrrmrlrnr
�getvaluer�close)r9rqr�rrrr~rr��s�zWheelFile.close)rNrrH)�__name__�
__module__�__qualname__�__doc__r4Zsha256rsrr*r/r_rXrnr�rrrrrs
+



rrH) �
__future__rr�r4�os.pathr�rerhr�collectionsr�	distutilsrrL�zipfilerrrZ	wheel.clirZ
wheel.utilr	r
rrr
r�compile�VERBOSEr&rrrrrr�<module>s$ �