o
    LK&hZ1                     @  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)d8d d!Z*d9d#d$Z+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/d0 d0e-Z0d;d6d7Z1dS )<    )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 requiresstrmetadatar   returnNonec                 C  sz   d }t t}|  D ]!}| }|sq
|dr$|dr$|dd }q
|| | q
t|D ]
\}}||| q0d S )N[]   )	r   list
splitlinesstrip
startswithendswithappendr   
add_header)r   r   extrarequirementslinekeyvalue r+   W/var/www/html/venv/lib/python3.10/site-packages/setuptools/_vendor/wheel/cli/convert.pyconvert_requires0   s   r-   pkginfoc              
   C  s   t  | }| D ]R\}}| }|dkrq
|dkr:| }d|d  td|dd  df}|| q
|dkrH|	dd|  q
|d	krV|	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   parsed_messager)   r*   	key_lowerdescription_linesr+   r+   r,   convert_pkg_infoB   s(   
r<   namec                 C  s   t dd|  ddS )Nz[-_.]+-_)resubr4   replace)r=   r+   r+   r,   	normalize]   s   rC   c                   @  sf   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Ze	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=   rE   selfr+   r+   r,   dist_info_diri   s   zConvertSource.dist_info_dirIterator[tuple[str, bytes]]c                 C  s   d S Nr+   rL   r+   r+   r,   generate_contentsm   s   zConvertSource.generate_contentsN)r   r   r   rO   )__name__
__module____qualname____annotations__rF   rH   rJ   propertyrN   r   rQ   r+   r+   r+   r,   rD   a   s   
 rD   )	metaclassc                   @  s    e Zd Zd
ddZdddZd	S )EggFileSourcepathr   c                 C  s   t |j }std|j || _t|d| _|d| _|d }rC|dd| _	|d }rC| j	dd	| _
t|| _t | _d S )
NzInvalid egg file name: r=   verrF   . archpycp)egg_filename_rematchr=   
ValueErrorrZ   rC   grouprE   rB   rF   rH   rJ   r   r   )rM   rZ   rb   rF   r^   r+   r+   r,   __init__s   s   
zEggFileSource.__init__r   rO   c                 c  s    t | jd\}t| D ]L}|drq|drR|dkr.||d}t|| j	 n#|dkrA||d}t
|| j	 n|dkrQ| j d||fV  q|||fV  qW d    d S 1 sfw   Y  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   rZ   sortednamelistr#   r"   readdecoder-   r   r<   rN   )rM   zip_filefilenamer   r.   r+   r+   r,   rQ      s(   


"zEggFileSource.generate_contentsNrZ   r   rR   )rS   rT   rU   re   rQ   r+   r+   r+   r,   rY   r   s    
rY   c                   @  s   e Zd ZdddZdS )EggDirectorySourcer   rO   c           
      c  s    t | jD ]o\}}}t|D ]e}t||}|jjdkrh|jdkr.|d}t|| j	 n9|jdkrW|d}t
|| j	 | j	d }rKt|| _| j	d }	rV|	| _n|jdkrg| j d| fV  qt|| j| fV  qqd S )	NzEGG-INFOrequires.txtrh   PKG-INFONameVersionentry_points.txtri   )oswalkrZ   rj   r   parentr=   	read_textr-   r   r<   getrC   rE   rN   
read_bytesr   relative_to)
rM   dirpathr?   	filenamesro   rZ   r   r.   r=   rE   r+   r+   r,   rQ      s0   







z$EggDirectorySource.generate_contentsNrR   )rS   rT   rU   rQ   r+   r+   r+   r,   rq      s    rq   c                   @  s$   e Zd ZdZdddZ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.
    rZ   r   c           	      C  s:  || _ t | _t|j }r%t|d| _|d }r%|	dd| _
d }}t| j e}| D ]O}|dd\}}|set| }red}t|d	| _|d
| _|d }rd|	dd| _
n|s|t| }r|d}|d| _|d| _|r|r n	q3W d    d S W d    d S 1 sw   Y  d S )NrJ   rF   r\   r]   Frg   r   Tr=   r[   rH   )rZ   r   r   
wininst_researchr=   rC   rd   rJ   rB   rF   r   rk   splitegg_info_rerb   rE   pyd_rerH   )	rM   rZ   rb   rF   egg_info_found	pyd_foundrn   ro   prefixr+   r+   r,   re      s8   "zWininstFileSource.__init__r   rO   c           
      c  s6   | j  d| j d}| j  d| j d}t| jdv}t| D ]f}|dr*q"|dd\}}t	|ru|
ddd }|dkrR||d	}t|| j n"|d
kre||d	}	t|	| j n|dkrt| d||fV  q"|dkr| d| }|||fV  q"W d    d S 1 sw   Y  d S )Nr>   rK   z.datarf   rg   r   r   rr   rh   rs   rv   ri   SCRIPTSz	/scripts/)r=   rE   r   rZ   rj   rk   r#   r   r   r   rsplitrl   rm   r-   r   r<   )
rM   rN   data_dirrn   ro   r   target_filenamebasenamer   r.   r+   r+   r,   rQ      s4   

"z#WininstFileSource.generate_contentsNrp   rR   )rS   rT   rU   __doc__re   rQ   r+   r+   r+   r,   r      s    
r   files	list[str]dest_dirverboseboolc                 C  s  | D ]}t |D ]}t|}|jdkr!| rt|}n	t|}nt|}|r1t| dddd t||j d|j	 d|j
 d|j d|j d
 }t|dx}| D ]
\}	}
||	|
 qU||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| q||j d|jtd
d W d    n1 sw   Y  |rtd qqd S )Nz.eggz...Tr]   )flushendr>   z.whlwz	/METADATA)policyrh   zWheel-Versionz1.0	GeneratorzRoot-Is-PurelibrI   c                 S  s   | j S rP   )interpreter)tagr+   r+   r,   <lambda>A  s    zconvert.<locals>.<lambda>)r)   Tagz/WHEELOK)r
   r   suffixis_dirrq   rY   r   printr=   rE   rF   rH   rJ   r   rQ   writestrrN   r   	as_stringserialization_policyencoder   r%   	GENERATORr   r4   r   rj   )r   r   r   patarchiverZ   source	dest_path	wheelfilename_or_zinfocontentswheel_messagetagsr   r+   r+   r,   convert  sZ   


 

r   )r   r   r   r   r   r   )r.   r   r   r   )r=   r   r   r   )r   r   r   r   r   r   r   r   )2
__future__r   os.pathrw   r@   abcr   r   collectionsr   collections.abcr   email.messager   email.parserr   email.policyr	   globr
   pathlibr   textwrapr   zipfiler   r]   r   r   r   vendored.packaging.tagsr   r   r   compileVERBOSEra   r   r   r   r   r   r-   r<   rC   rD   rY   rq   r   r   r+   r+   r+   r,   <module>   sV    




-^