a
    sh                     @  sv   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ ddlmZ G d	d
 d
ZdS )z`Represents a wheel file and provides access to the various parts of the
name that have meaning.
    )annotationsN)IterableTag)BuildTagparse_wheel_filename)InvalidWheelFilename)
deprecatedc                   @  s   e Zd ZdZedejZdddddZe	dd	d
dZ
dd	ddZdddddZddddddZdddddZdS )WheelzA wheel filez^(?P<namever>(?P<name>[^\s-]+?)-(?P<ver>[^\s-]*?))
        ((-(?P<build>\d[^-]*?))?-(?P<pyver>[^\s-]+?)-(?P<abi>[^\s-]+?)-(?P<plat>[^\s-]+?)
        \.whl|\.dist-info)$strNone)filenamereturnc              
     s  || _ |  d | _z(t|}|\| _}| _| _t|| _W n ty } z| j	|}|sjt
|jd d td|d|jd  ddddd |d	d
d| _|dd
d| _|dd}|dd |ddt fdd|D | _W Y d }~n
d }~0 0 d S )Nr   zWheel filename zU is not correctly normalised. Future versions of pip will raise the following error:
z

zvto rename the wheel to use a correctly normalised name (this may require updating the version in the project metadata)z25.3i2  )reasonreplacementgone_inissuename_-verpyver.abiplatc                 3  s0   | ](} D ]}D ]}t |||d V  qq
qdS ))interpreterr   platformNr   ).0pyr   r   abisplats V/var/www/html/assistant/venv/lib/python3.9/site-packages/pip/_internal/models/wheel.py	<genexpr>F   s   z!Wheel.__init__.<locals>.<genexpr>)r   
_build_tagr   r   	file_tagsr   version_PackagingInvalidWheelFilenamelegacy_wheel_file_rematchr   argsr	   groupreplacesplit	frozenset)selfr   
wheel_info_versionelegacy_wheel_info
pyversionsr"   r   r#   __init__   s6    zWheel.__init__r   )r   c                 C  sx   | j d ur| j S | j| j}|d us.J d|d}td|}|d usTJ d| }t|d |d f| _ | j S )Nz!guaranteed by filename validationbuildz^(\d+)(.*)$r      )r%   r)   r*   r   r,   regroupsint)r0   r4   	build_tagr*   build_tag_groupsr"   r"   r#   r<   M   s    

zWheel.build_tagz	list[str]c                 C  s   t dd | jD S )z4Return the wheel's tags as a sorted list of strings.c                 s  s   | ]}t |V  qd S N)r   r   tagr"   r"   r#   r$   _       z0Wheel.get_formatted_file_tags.<locals>.<genexpr>)sortedr&   r0   r"   r"   r#   get_formatted_file_tags]   s    zWheel.get_formatted_file_tagsz	list[Tag]r;   )tagsr   c                   s:   zt  fddt|D W S  ty4   t Y n0 dS )a  Return the lowest index that one of the wheel's file_tag combinations
        achieves in the given list of supported tags.

        For example, if there are 8 supported tags and one of the file tags
        is first in the list, then return 0.

        :param tags: the PEP 425 tags to check the wheel against, in order
            with most preferred first.

        :raises ValueError: If none of the wheel's file tags match one of
            the supported tags.
        c                 3  s    | ]\}}| j v r|V  qd S r>   )r&   )r   itrC   r"   r#   r$   o   rA   z*Wheel.support_index_min.<locals>.<genexpr>N)next	enumerateStopIteration
ValueErrorr0   rE   r"   rC   r#   support_index_mina   s    zWheel.support_index_minzdict[Tag, int])rE   tag_to_priorityr   c                   s   t  fdd| jD S )a  Return the priority of the most preferred tag that one of the wheel's file
        tag combinations achieves in the given list of supported tags using the given
        tag_to_priority mapping, where lower priorities are more-preferred.

        This is used in place of support_index_min in some cases in order to avoid
        an expensive linear scan of a large list of tags.

        :param tags: the PEP 425 tags to check the wheel against.
        :param tag_to_priority: a mapping from tag to priority of that tag, where
            lower is more preferred.

        :raises ValueError: If none of the wheel's file tags match one of
            the supported tags.
        c                 3  s   | ]}| v r | V  qd S r>   r"   r?   rN   r"   r#   r$      s   z0Wheel.find_most_preferred_tag.<locals>.<genexpr>)minr&   )r0   rE   rN   r"   rO   r#   find_most_preferred_tags   s    zWheel.find_most_preferred_tagzIterable[Tag]boolc                 C  s   | j | S )zReturn whether the wheel is compatible with one of the given tags.

        :param tags: the PEP 425 tags to check the wheel against.
        )r&   
isdisjointrL   r"   r"   r#   	supported   s    zWheel.supportedN)__name__
__module____qualname____doc__r9   compileVERBOSEr)   r6   propertyr<   rD   rM   rQ   rT   r"   r"   r"   r#   r
      s   /r
   )rX   
__future__r   r9   collections.abcr   Zpip._vendor.packaging.tagsr   pip._vendor.packaging.utilsr   r   r   r(   pip._internal.exceptionspip._internal.utils.deprecationr	   r
   r"   r"   r"   r#   <module>   s   