U
    ZÊ¹jZ1  ã                   @  sœ  d dl mZ d dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! e "dej#¡Z$e "dej#¡Z%e "d¡Z&e "d¡Z'eddd d�Z(de› �Z)ddddœdd„Z*ddd œd!d"„Z+ddd#œd$d%„Z,G d&d'„ d'ed(�Z-G d)d*„ d*e-ƒZ.G d+d,„ d,e.ƒZ/G d-d.„ d.e-ƒZ0d/dd0dd1œd2d3„Z1dS )4é    )ÚannotationsN)ÚABCMetaÚabstractmethod)Údefaultdict)ÚIterator)ÚMessage)ÚParser)ÚEmailPolicy)Úiglob)ÚPath)Údedent)ÚZipFileé   )Ú__version__)Úgenerate_requirements)Ú	parse_tag)Ú	WheelFilez]
    (?P<name>.+?)-(?P<ver>.+?)
    (-(?P<pyver>py\d\.\d+)
     (-(?P<arch>.+?))?
    )?.egg$zL
    ^(?P<name>.+?)-(?P<ver>.+?)
    (-(?P<pyver>py\d\.\d+)
    )?.egg-info/z>\.(?P<platform>win32|win-amd64)(?:-(?P<pyver>py\d\.\d))?\.exe$z8\.(?P<abi>[a-z0-9]+)-(?P<platform>win32|win_amd64)\.pyd$TF)Úutf8Úmangle_from_Úmax_line_lengthzwheel Ústrr   ÚNone)ÚrequiresÚmetadataÚreturnc                 C  sz   d }t tƒ}|  ¡ D ]B}| ¡ }|s&q| d¡rH| d¡rH|dd… }q||  |¡ qt|ƒD ]\}}| ||¡ q`d S )Nú[ú]é   éÿÿÿÿ)	r   ÚlistÚ
splitlinesÚstripÚ
startswithÚendswithÚappendr   Ú
add_header)r   r   ÚextraÚrequirementsÚlineÚkeyÚvalue© r+   úP/var/www/html/bwave/python/venv/lib/python3.8/site-packages/wheel/cli/convert.pyÚconvert_requires0   s    r-   )Úpkginfor   c              
   C  sÊ   t ƒ  | ¡}| ¡ D ]¤\}}| ¡ }|dkr.q|dkrt| ¡ }d |d  ¡ td |dd … ¡ƒdf¡}| |¡ q|dkr�| 	dd|› �¡ q|d	kr¬| 	dd
|› �¡ q| 	||¡ q| 
dd¡ d S )NÚUNKNOWNÚdescriptionÚ
r   r   z	home-pagezProject-URLz
Homepage, zdownload-urlz
Download, zMetadata-Versionz2.4)r   ÚparsestrÚitemsÚlowerr    ÚjoinÚlstripr   Úset_payloadr%   Úreplace_header)r.   r   Zparsed_messager)   r*   Ú	key_lowerZdescription_linesr+   r+   r,   Úconvert_pkg_infoB   s(    
ýÿr:   )Únamer   c                 C  s   t  dd| ¡ ¡  dd¡S )Nz[-_.]+ú-Ú_)ÚreÚsubr4   Úreplace)r;   r+   r+   r,   Ú	normalize]   s    rA   c                   @  sn   e Zd ZU ded< ded< dZded< dZded< dZded	< d
ed< eddœdd„ƒZe	ddœdd„ƒZ
dS )ÚConvertSourcer   r;   Úversionzpy2.py3ÚpyverÚnoneÚabiÚanyÚplatformr   r   ©r   c                 C  s   | j › d| j› d�S )Nr<   ú
.dist-info)r;   rC   ©Úselfr+   r+   r,   Údist_info_diri   s    zConvertSource.dist_info_dirúIterator[tuple[str, bytes]]c                 C  s   d S ©Nr+   rK   r+   r+   r,   Úgenerate_contentsm   s    zConvertSource.generate_contentsN)Ú__name__Ú
__module__Ú__qualname__Ú__annotations__rD   rF   rH   ÚpropertyrM   r   rP   r+   r+   r+   r,   rB   a   s   
rB   )Ú	metaclassc                   @  s(   e Zd Zddœdd„Zddœdd„Zd	S )
ÚEggFileSourcer   ©Úpathc                 C  s’   t  |j¡ }s td|j› �ƒ‚|| _t| d¡ƒ| _| d¡| _| d¡ }r†| dd¡| _	| d¡ }r†| j	 dd	¡| _
t|ƒ| _tƒ | _d S )
NzInvalid egg file name: r;   ÚverrD   Ú.Ú ÚarchÚpyÚcp)Úegg_filename_reÚmatchr;   Ú
ValueErrorrY   rA   ÚgrouprC   r@   rD   rF   rH   r   r   )rL   rY   ra   rD   r]   r+   r+   r,   Ú__init__s   s    
zEggFileSource.__init__rN   rI   c              	   c  sÂ   t | jdƒ�¬}t| ¡ ƒD ]˜}| d¡r*q| d¡r¢|dkrZ| |¡ d¡}t|| j	ƒ q|dkr€| |¡ d¡}t
|| j	ƒ q|dkr| j› d�| |¡fV  q|| |¡fV  qW 5 Q R X d S )	NÚrú/z	EGG-INFO/zEGG-INFO/requires.txtúutf-8zEGG-INFO/PKG-INFOzEGG-INFO/entry_points.txtú/entry_points.txt)r   rY   ÚsortedÚnamelistr#   r"   ÚreadÚdecoder-   r   r:   rM   )rL   Úzip_fileÚfilenamer   r.   r+   r+   r,   rP   ƒ   s"    


þzEggFileSource.generate_contentsN)rQ   rR   rS   rd   rP   r+   r+   r+   r,   rW   r   s   rW   c                   @  s   e Zd Zddœdd„ZdS )ÚEggDirectorySourcerN   rI   c           
      c  sð   t  | j¡D ]Þ\}}}t|ƒD ]Ê}t||ƒ}|jjdkrÎ|jdkrZ| d¡}t|| j	ƒ q|jdkr¬| d¡}t
|| j	ƒ | j	 d¡ }r”t|ƒ| _| j	 d¡ }	rÌ|	| _q|jdkr| j› d�| ¡ fV  qt| | j¡ƒ| ¡ fV  qqd S )	NzEGG-INFOúrequires.txtrg   úPKG-INFOÚNameÚVersionúentry_points.txtrh   )ÚosÚwalkrY   ri   r   Úparentr;   Ú	read_textr-   r   r:   ÚgetrA   rC   rM   Ú
read_bytesr   Úrelative_to)
rL   Údirpathr=   Ú	filenamesrn   rY   r   r.   r;   rC   r+   r+   r,   rP       s(    







þz$EggDirectorySource.generate_contentsN)rQ   rR   rS   rP   r+   r+   r+   r,   ro   Ÿ   s   ro   c                   @  s,   e Zd ZdZddœdd„Zddœdd	„Zd
S )ÚWininstFileSourcea×  
    Handles distributions created with ``bdist_wininst``.

    The egginfo filename has the format::

        name-ver(-pyver)(-arch).egg-info

    The installer filename has the format::

        name-ver.arch(-pyver).exe

    Some things to note:

    1. The installer filename is not definitive. An installer can be renamed
       and work perfectly well as an installer. So more reliable data should
       be used whenever possible.
    2. The egg-info data should be preferred for the name and version, because
       these come straight from the distutils metadata, and are mandatory.
    3. The pyver from the egg-info data should be ignored, as it is
       constructed from the version of Python used to build the installer,
       which is irrelevant - the installer filename is correct here (even to
       the point that when it's not there, any version is implied).
    4. The architecture must be taken from the installer filename, as it is
       not included in the egg-info data.
    5. Architecture-neutral installers still have an architecture because the
       installer format itself (being executable) is architecture-specific. We
       should therefore ignore the architecture if the content is pure-python.
    r   rX   c           	   	   C  s  || _ tƒ | _t |j¡ }rJt| d¡ƒ| _| d¡ }rJ| 	dd¡| _
d }}t| j ƒ�°}| ¡ D ] }| dd¡\}}|sÊt |¡ }rÊd}t| d	¡ƒ| _| d
¡| _| d¡ }rø| 	dd¡| _
n.|søt |¡ }rød}| d¡| _| d¡| _|rf|rf �qqfW 5 Q R X d S )NrH   rD   r[   r\   Frf   r   Tr;   rZ   rF   )rY   r   r   Ú
wininst_reÚsearchr;   rA   rc   rH   r@   rD   r   rj   ÚsplitÚegg_info_rera   rC   Úpyd_rerF   )	rL   rY   ra   rD   Zegg_info_foundZ	pyd_foundrm   rn   Úprefixr+   r+   r,   rd   Ú   s,    zWininstFileSource.__init__rN   rI   c           
   	   c  s"  | j › d| j› d�}| j › d| j› d�}t| jdƒ�ä}t| ¡ ƒD ]Ð}| d¡rRqB| dd¡\}}t 	|¡rê| 
dd¡d }|dkr¢| |¡ d	¡}t|| jƒ qB|d
krÈ| |¡ d	¡}	t|	| jƒ qB|dkrB|› d�| |¡fV  qBn|dk�r|› d|› �}|| |¡fV  qBW 5 Q R X d S )Nr<   rJ   z.datare   rf   r   r   rp   rg   rq   rt   rh   ZSCRIPTSz	/scripts/)r;   rC   r   rY   ri   rj   r#   r�   r‚   r€   Úrsplitrk   rl   r-   r   r:   )
rL   rM   Údata_dirrm   rn   r„   Ztarget_filenameÚbasenamer   r.   r+   r+   r,   rP   ø   s.    

þ
z#WininstFileSource.generate_contentsN)rQ   rR   rS   Ú__doc__rd   rP   r+   r+   r+   r,   r~   ¼   s   r~   z	list[str]Úbool)ÚfilesÚdest_dirÚverboser   c                 C  s¦  | D �]š}t |ƒD �]Š}t|ƒ}|jdkrF| ¡ r<t|ƒ}qNt|ƒ}nt|ƒ}|rft|› d�ddd� t|ƒ|j› d|j	› d|j
› d|j› d|j› d�
 }t|dƒ�è}| ¡ D ]\}	}
| |	|
¡ q®| |j› d	�|jjtd
� d¡¡ tƒ }| dd¡ | dt¡ | dt|jdkƒ ¡ ¡ t|j
› d|j› d|j› �ƒ}t|dd„ d�D ]}| dt|ƒ¡ �qN| |j› d�|jtd
� d¡¡ W 5 Q R X |rtdƒ qqd S )Nz.eggz...Tr\   )ÚflushÚendr<   z.whlÚwz	/METADATA)Úpolicyrg   zWheel-Versionz1.0Ú	GeneratorzRoot-Is-PurelibrG   c                 S  s   | j S rO   )Úinterpreter)Útagr+   r+   r,   Ú<lambda>A  ó    zconvert.<locals>.<lambda>)r)   ÚTagz/WHEELÚOK)r
   r   ÚsuffixÚis_dirro   rW   r~   Úprintr;   rC   rD   rF   rH   r   rP   ÚwritestrrM   r   Ú	as_stringÚserialization_policyÚencoder   r%   Ú	GENERATORr   r4   r   ri   )rŠ   r‹   rŒ   ÚpatÚarchiverY   ÚsourceÚ	dest_pathÚ	wheelfileZname_or_zinfoÚcontentsZwheel_messageÚtagsr“   r+   r+   r,   Úconvert  sP    



*ÿ
ÿþ ÿ
ÿþr§   )2Ú
__future__r   Úos.pathru   r>   Úabcr   r   Úcollectionsr   Úcollections.abcr   Úemail.messager   Úemail.parserr   Úemail.policyr	   Úglobr
   Úpathlibr   Útextwrapr   Úzipfiler   r\   r   r   r   Zvendored.packaging.tagsr   r¤   r   ÚcompileÚVERBOSEr`   r‚   r   rƒ   r�   rŸ   r-   r:   rA   rB   rW   ro   r~   r§   r+   r+   r+   r,   Ú<module>   sT   úûÿ
ý
-^