Current File : //lib/python3.9/site-packages/pip/_vendor/packaging/__pycache__/specifiers.cpython-39.pyc
a

[��f�x�@s�ddlZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZm
Z
mZmZmZddlmZddlmZmZmZeeefZeeeefZeded�ZeeegefZGdd	�d	e�ZGd
d�dejd�Z Gd
d�de �Z!Gdd�de!�Z"edeegefedeegefd�dd�Z#Gdd�de!�Z$e�%d�Z&ee
ed�dd�Z'eed�dd�Z(e
ee
eee
ee
efd�dd�Z)Gd d!�d!e �Z*dS)"�N)�Callable�Dict�Iterable�Iterator�List�Optional�Pattern�Set�Tuple�TypeVar�Union�)�canonicalize_version)�
LegacyVersion�Version�parse�VersionTypeVar)�boundc@seZdZdZdS)�InvalidSpecifierzH
    An invalid specifier was found, users should refer to PEP 440.
    N)�__name__�
__module__�__qualname__�__doc__�rr�D/usr/lib/python3.9/site-packages/pip/_vendor/packaging/specifiers.pyr!src@s�eZdZejed�dd��Zejed�dd��Zeje	e
d�dd��Zeje	e
d�d	d
��Zej
ee
d�dd��Zeje
d
d�dd��Zejdeee
e
d�dd��Zejdeeee
eed�dd��Zd
S)�
BaseSpecifier��returncCsdS)z�
        Returns the str representation of this Specifier like object. This
        should be representative of the Specifier itself.
        Nr��selfrrr�__str__(szBaseSpecifier.__str__cCsdS)zF
        Returns a hash value for this Specifier like object.
        Nrrrrr�__hash__/szBaseSpecifier.__hash__��otherrcCsdS)zq
        Returns a boolean representing whether or not the two Specifier like
        objects are equal.
        Nr�rr#rrr�__eq__5szBaseSpecifier.__eq__cCsdS)zu
        Returns a boolean representing whether or not the two Specifier like
        objects are not equal.
        Nrr$rrr�__ne__<szBaseSpecifier.__ne__cCsdS)zg
        Returns whether or not pre-releases as a whole are allowed by this
        specifier.
        Nrrrrr�prereleasesCszBaseSpecifier.prereleasesN��valuercCsdS)zd
        Sets whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr�rr)rrrr'Js��itemr'rcCsdS)zR
        Determines if the given item is contained within this specifier.
        Nr�rr,r'rrr�containsQszBaseSpecifier.contains��iterabler'rcCsdS)z�
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr)rr0r'rrr�filterWszBaseSpecifier.filter)N)N)rrr�abc�abstractmethod�strr �intr!�object�boolr%r&�abstractpropertyrr'�setterr.rrr1rrrrr's(��r)�	metaclassc@sbeZdZUiZeeefed<eeed<d-eee	dd�dd�Z
ed�d	d
�Zed�dd�Ze
eeefd�d
d��Zed�dd�Zee	d�dd�Zee	d�dd�Zeed�dd�Zeed�dd�Ze
ed�dd��Ze
ed�dd��Ze
ee	d�d d!��Zeje	dd"�d#d!��Zee	d$�d%d&�Zd.eee	e	d'�d(d)�Zd/e e!ee	e e!d*�d+d,�Z"dS)0�_IndividualSpecifier�
_operators�_regex�N��specr'rcCsH|j�|�}|s td|�d���|�d���|�d���f|_||_dS)NzInvalid specifier: '�'�operator�version)r=�searchr�group�strip�_spec�_prereleases)rr@r'�matchrrr�__init__fs�z_IndividualSpecifier.__init__rcCs0|jdurd|j��nd}d�|jjt|�|�S)N�, prereleases=r>z<{}({!r}{})>)rHr'�format�	__class__rr4�rZprerrr�__repr__ss
��z_IndividualSpecifier.__repr__cCsdj|j�S)Nz{}{})rLrGrrrrr |sz_IndividualSpecifier.__str__cCs|jdt|jd�fS)Nrr
)rGrrrrr�_canonical_specsz$_IndividualSpecifier._canonical_speccCs
t|j�S�N)�hashrPrrrrr!�sz_IndividualSpecifier.__hash__r"cCsRt|t�r6z|�t|��}WqFty2tYS0nt||j�sFtS|j|jkSrQ)�
isinstancer4rMr�NotImplementedrPr$rrrr%�s
z_IndividualSpecifier.__eq__cCsRt|t�r6z|�t|��}WqFty2tYS0nt||j�sFtS|j|jkSrQ)rSr4rMrrTrGr$rrrr&�s
z_IndividualSpecifier.__ne__)�oprcCst|d|j|���}|S)NZ	_compare_)�getattrr<)rrU�operator_callablerrr�
_get_operator�s�z"_IndividualSpecifier._get_operator�rCrcCst|ttf�st|�}|SrQ)rSrrr�rrCrrr�_coerce_version�sz$_IndividualSpecifier._coerce_versioncCs
|jdS)Nr�rGrrrrrB�sz_IndividualSpecifier.operatorcCs
|jdS)Nr
r\rrrrrC�sz_IndividualSpecifier.versioncCs|jSrQ�rHrrrrr'�sz _IndividualSpecifier.prereleasesr(cCs
||_dSrQr]r*rrrr'�s�r,rcCs
|�|�SrQ�r.�rr,rrr�__contains__�sz!_IndividualSpecifier.__contains__r+cCs>|dur|j}|�|�}|jr&|s&dS|�|j�}|||j�S�NF)r'r[�
is_prereleaserXrBrC)rr,r'Znormalized_itemrWrrrr.�s

z_IndividualSpecifier.containsr/ccs�d}g}d|dur|ndi}|D]F}|�|�}|j|fi|��r |jr\|s\|js\|�|�q d}|Vq |s�|r�|D]
}|VqtdS)NFr'T)r[r.rcr'�append)rr0r'�yielded�found_prereleases�kwrC�parsed_versionrrrr1�s"
��z_IndividualSpecifier.filter)r>N)N)N)#rrrr<rr4�__annotations__rrr7rJrOr �propertyr
rPr5r!r6r%r&�CallableOperatorrX�UnparsedVersion�
ParsedVersionr[rBrCr'r9rar.rrr1rrrrr;as>

	����r;cs�eZdZdZe�dedejejB�Zdddddd	d
�Z	d e
eedd
��fdd�
Z
eed�dd�Zee
ed�dd�Zee
ed�dd�Zee
ed�dd�Zee
ed�dd�Zee
ed�dd�Zee
ed�dd�Z�ZS)!�LegacySpecifiera�
        (?P<operator>(==|!=|<=|>=|<|>))
        \s*
        (?P<version>
            [^,;\s)]* # Since this is a "legacy" specifier, and the version
                      # string can be just about anything, we match everything
                      # except for whitespace, a semi-colon for marker support,
                      # a closing paren since versions can be enclosed in
                      # them, and a comma since it's a version separator.
        )
        �^\s*�\s*$�equal�	not_equal�less_than_equal�greater_than_equal�	less_than�greater_than)�==�!=�<=�>=�<�>r>Nr?cst��||�t�dt�dS)NzZCreating a LegacyVersion has been deprecated and will be removed in the next major release)�superrJ�warnings�warn�DeprecationWarning)rr@r'�rMrrrJs
�zLegacySpecifier.__init__rYcCst|t�stt|��}|SrQ)rSrr4rZrrrr[s
zLegacySpecifier._coerce_version��prospectiver@rcCs||�|�kSrQ�r[�rr�r@rrr�_compare_equalszLegacySpecifier._compare_equalcCs||�|�kSrQr�r�rrr�_compare_not_equalsz"LegacySpecifier._compare_not_equalcCs||�|�kSrQr�r�rrr�_compare_less_than_equal"sz(LegacySpecifier._compare_less_than_equalcCs||�|�kSrQr�r�rrr�_compare_greater_than_equal%sz+LegacySpecifier._compare_greater_than_equalcCs||�|�kSrQr�r�rrr�_compare_less_than*sz"LegacySpecifier._compare_less_thancCs||�|�kSrQr�r�rrr�_compare_greater_than-sz%LegacySpecifier._compare_greater_than)r>N)rrr�
_regex_str�re�compile�VERBOSE�
IGNORECASEr=r<r4rr7rJrlrr[r�r�r�r�r�r��
__classcell__rrr�rrn�s&�		�rn�	Specifier)�fnrcs&t���dtttd��fdd��}|S)Nr�)rr�r@rcst|t�sdS�|||�Srb)rSrr��r�rr�wrapped4s
z)_require_version_compare.<locals>.wrapped)�	functools�wrapsrmr4r7)r�r�rr�r�_require_version_compare1sr�c	@seZdZdZe�dedejejB�Zdddddd	d
dd�Z	e
eee
d
�dd��Ze
eee
d
�dd��Ze
eee
d
�dd��Ze
eee
d
�dd��Ze
eee
d
�dd��Ze
eee
d�dd��Ze
eee
d�dd��Zeee
d
�dd�Zee
d�d d!��Zeje
d"d#�d$d!��Zd"S)%r�a
        (?P<operator>(~=|==|!=|<=|>=|<|>|===))
        (?P<version>
            (?:
                # The identity operators allow for an escape hatch that will
                # do an exact string match of the version you wish to install.
                # This will not be parsed by PEP 440 and we cannot determine
                # any semantic meaning from it. This operator is discouraged
                # but included entirely as an escape hatch.
                (?<====)  # Only match for the identity operator
                \s*
                [^\s]*    # We just match everything, except for whitespace
                          # since we are only testing for strict identity.
            )
            |
            (?:
                # The (non)equality operators allow for wild card and local
                # versions to be specified so we have to define these two
                # operators separately to enable that.
                (?<===|!=)            # Only match for equals and not equals

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?

                # You cannot use a wild card and a dev or local version
                # together so group them with a | and make them optional.
                (?:
                    (?:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
                    |
                    \.\*  # Wild card syntax of .*
                )?
            )
            |
            (?:
                # The compatible operator requires at least two digits in the
                # release segment.
                (?<=~=)               # Only match for the compatible operator

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)+   # release  (We have a + instead of a *)
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
            |
            (?:
                # All other operators only allow a sub set of what the
                # (non)equality operators do. Specifically they do not allow
                # local versions to be specified nor do they allow the prefix
                # matching wild cards.
                (?<!==|!=|~=)         # We have special cases for these
                                      # operators so we want to make sure they
                                      # don't match here.

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        rorpZ
compatiblerqrrrsrtrurvZ	arbitrary)�~=rwrxryrzr{r|�===r�cCsJd�tt�tt|���dd��}|d7}|�d�||�oH|�d�||�S)N�.����.*rzrw)�join�list�	itertools�	takewhile�_is_not_suffix�_version_splitrX)rr�r@�prefixrrr�_compare_compatible�s��zSpecifier._compare_compatiblec	Csz|�d�rVt|j�}t|dd��}tt|��}|dt|��}t||�\}}||kSt|�}|jsnt|j�}||kSdS)Nr����)�endswithr�publicr�r4�len�_pad_version�local)	rr�r@Z
split_specZsplit_prospectiveZshortened_prospectiveZpadded_specZpadded_prospectiveZspec_versionrrrr��s

�
zSpecifier._compare_equalcCs|�||�SrQ)r�r�rrrr��szSpecifier._compare_not_equalcCst|j�t|�kSrQ�rr�r�rrrr��sz"Specifier._compare_less_than_equalcCst|j�t|�kSrQr�r�rrrr��sz%Specifier._compare_greater_than_equal)r��spec_strrcCs<t|�}||ksdS|js8|jr8t|j�t|j�kr8dSdS�NFT)rrc�base_version�rr�r�r@rrrr��szSpecifier._compare_less_thancCs^t|�}||ksdS|js8|jr8t|j�t|j�kr8dS|jdurZt|j�t|j�krZdSdSr�)rZis_postreleaser�r�r�rrrr�s
zSpecifier._compare_greater_thancCst|���t|���kSrQ)r4�lowerr�rrr�_compare_arbitrary7szSpecifier._compare_arbitraryrcCsR|jdur|jS|j\}}|dvrN|dkr@|�d�r@|dd�}t|�jrNdSdS)N)rwrzryr�r�rwr�r�TF)rHrGr�rrc)rrBrCrrrr':s


zSpecifier.prereleasesNr(cCs
||_dSrQr]r*rrrr'Ss)rrrr�r�r�r�r�r=r<r�rmr4r7r�r�r�r�r�r�r�rr�rjr'r9rrrrr�=s@]�'�	z^([0-9]+)((?:a|b|c|rc)[0-9]+)$rYcCs@g}|�d�D],}t�|�}|r0|�|���q|�|�q|S)Nr�)�split�
_prefix_regexrD�extend�groupsrd)rC�resultr,rIrrrr�[s
r�)�segmentrcst�fdd�dD��S)Nc3s|]}��|�VqdSrQ)�
startswith)�.0r��r�rr�	<genexpr>gsz!_is_not_suffix.<locals>.<genexpr>)�dev�a�b�rcZpost)�anyr�rr�rr�fs�r�)�left�rightrc
Cs�gg}}|�tt�dd�|���|�tt�dd�|���|�|t|d�d��|�|t|d�d��|�ddgtdt|d�t|d���|�ddgtdt|d�t|d���ttj|��ttj|��fS)NcSs|��SrQ��isdigit��xrrr�<lambda>p�z_pad_version.<locals>.<lambda>cSs|��SrQr�r�rrrr�qr�rr
�0)rdr�r�r�r��insert�max�chain)r�r�Z
left_splitZright_splitrrrr�ls
,,r�c@seZdZd%eeedd�dd�Zed�dd�Zed�d	d
�Ze	d�dd�Z
edefdd
�dd�Ze
ed
�dd�Ze
ed
�dd�Ze	d�dd�Zeed�dd�Zeeed�dd��Zejedd�dd��Zeed�dd�Zd&eeeed�d d!�Zd'eeeeeed"�d#d$�ZdS)(�SpecifierSetr>N)�
specifiersr'rc	Csldd�|�d�D�}t�}|D]8}z|�t|��WqtyT|�t|��Yq0qt|�|_||_dS)NcSsg|]}|��r|���qSr)rF�r��srrr�
<listcomp>�r�z)SpecifierSet.__init__.<locals>.<listcomp>�,)	r��set�addr�rrn�	frozenset�_specsrH)rr�r'Zsplit_specifiers�parsed�	specifierrrrrJs
zSpecifierSet.__init__rcCs*|jdurd|j��nd}d�t|�|�S)NrKr>z<SpecifierSet({!r}{})>)rHr'rLr4rNrrrrO�s
��zSpecifierSet.__repr__cCsd�tdd�|jD���S)Nr�css|]}t|�VqdSrQ)r4r�rrrr��r�z'SpecifierSet.__str__.<locals>.<genexpr>)r��sortedr�rrrrr �szSpecifierSet.__str__cCs
t|j�SrQ)rRr�rrrrr!�szSpecifierSet.__hash__r"cCs�t|t�rt|�}nt|t�s"tSt�}t|j|jB�|_|jdurX|jdurX|j|_n<|jdurv|jdurv|j|_n|j|jkr�|j|_ntd��|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)rSr4r�rTr�r�rH�
ValueError)rr#r�rrr�__and__�s 





�zSpecifierSet.__and__cCs6t|ttf�rtt|��}nt|t�s*tS|j|jkSrQ�rSr4r;r�rTr�r$rrrr%�s

zSpecifierSet.__eq__cCs6t|ttf�rtt|��}nt|t�s*tS|j|jkSrQr�r$rrrr&�s

zSpecifierSet.__ne__cCs
t|j�SrQ)r�r�rrrr�__len__�szSpecifierSet.__len__cCs
t|j�SrQ)�iterr�rrrr�__iter__�szSpecifierSet.__iter__cCs.|jdur|jS|jsdStdd�|jD��S)Ncss|]}|jVqdSrQ�r'r�rrrr��r�z+SpecifierSet.prereleases.<locals>.<genexpr>)rHr�r�rrrrr'�s

zSpecifierSet.prereleasesr(cCs
||_dSrQr]r*rrrr'�sr^cCs
|�|�SrQr_r`rrrra�szSpecifierSet.__contains__r+csLt�ttf�st����dur$|j��s2�jr2dSt��fdd�|jD��S)NFc3s|]}|j��d�VqdS)r�Nr_r��r,r'rrr�r�z(SpecifierSet.contains.<locals>.<genexpr>)rSrrrr'rc�allr�r-rr�rr.�s
zSpecifierSet.containsr/cCs�|dur|j}|jr6|jD]}|j|t|�d�}q|Sg}g}|D]P}t|ttf�s^t|�}n|}t|t�rnqB|jr�|s�|s�|�	|�qB|�	|�qB|s�|r�|dur�|S|SdS)Nr�)
r'r�r1r7rSrrrrcrd)rr0r'r@Zfilteredrfr,rhrrrr1	s*



zSpecifierSet.filter)r>N)N)N)rrrr4rr7rJrOr r5r!rr�r6r%r&r�rr;r�rjr'r9rlrar.rrr1rrrrr�~s8��	����r�)+r2r�r�r�r~�typingrrrrrrrr	r
rrZutilsrrCrrrrmr4rlrr7rkr�r�ABCMetarr;rnr�r�r�r�r�r�r�r�rrrr�<module>s64:=�
*