o
    c                     @   sJ   d Z ddlZddlmZmZ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.
    N)DictIterableList)Tag)InvalidWheelFilenamec                   @   s   e Zd ZdZedejZdeddfddZ	de
e fdd	Zd
e
e defddZd
e
e deeef defddZd
ee def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)$filenamereturnNc                    s    j |}|st| d| _|ddd _|ddd _|d _|d	d _
|d		d _|d
	d _ fdd j
D  _dS )zX
        :raises InvalidWheelFilename: when the filename is invalid for a wheel
        z is not a valid wheel filename.name_-verbuildpyver.abiplatc                    s0   h | ]} j D ]} jD ]}t|||qqqS  )abisplatsr   ).0xyzselfr   G/opt/certbot/lib/python3.10/site-packages/pip/_internal/models/wheel.py	<setcomp>(   s    
z!Wheel.__init__.<locals>.<setcomp>N)wheel_file_rematchr   r   groupreplacer
   version	build_tagsplit
pyversionsr   r   	file_tags)r   r   
wheel_infor   r   r   __init__   s   
zWheel.__init__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)strr   tagr   r   r   	<genexpr>.   s    z0Wheel.get_formatted_file_tags.<locals>.<genexpr>)sortedr&   r   r   r   r   get_formatted_file_tags,   s   zWheel.get_formatted_file_tagstagsc                    s2   zt  fddt|D W S  ty   t w )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tr   r   r   r-   >   s     z*Wheel.support_index_min.<locals>.<genexpr>)next	enumerateStopIteration
ValueErrorr   r0   r   r   r   support_index_min0   s
   zWheel.support_index_mintag_to_priorityc                    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+   r9   r   r   r-   S   s    
z0Wheel.find_most_preferred_tag.<locals>.<genexpr>)minr&   )r   r0   r9   r   r:   r   find_most_preferred_tagB   s   zWheel.find_most_preferred_tagc                 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&   
isdisjointr7   r   r   r   	supportedW   s   zWheel.supported)__name__
__module____qualname____doc__recompileVERBOSEr   r*   r(   r   r/   r   intr8   r   r<   r   boolr>   r   r   r   r   r      s"    

r   )rB   rC   typingr   r   r   pip._vendor.packaging.tagsr   pip._internal.exceptionsr   r   r   r   r   r   <module>   s    