U �Qabym�@s�ddlmZmZmZddlZddlZddlZddlZddlm Z m Z ddl m Z m Z mZGdd�de�ZGdd �d e eje��ZGd d �d e�ZGd d �d e�Zdd�ZGdd�de�Ze�d�Zdd�Zdd�ZGdd�de�ZdS)�)�absolute_import�division�print_functionN�)� string_types�with_metaclass)�Version� LegacyVersion�parsec@seZdZdZdS)�InvalidSpecifierzH An invalid specifier was found, users should refer to PEP 440. N)�__name__� __module__� __qualname__�__doc__�rr�N/usr/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/specifiers.pyr sr c@s�eZdZejdd��Zejdd��Zejdd��Zejdd��Zej d d ��Z e j d d ��Z ejdd d��Z ejddd��Z d S)� BaseSpecifiercCsdS)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__cCsdS)zq Returns a boolean representing whether or not the two Specifier like objects are equal. Nr�r�otherrrr�__eq__$szBaseSpecifier.__eq__cCsdS)zu Returns a boolean representing whether or not the two Specifier like objects are not equal. Nrrrrr�__ne__+szBaseSpecifier.__ne__cCsdS)zg Returns whether or not pre-releases as a whole are allowed by this specifier. Nrrrrr� prereleases2szBaseSpecifier.prereleasescCsdS)zd Sets whether or not pre-releases as a whole are allowed by this specifier. Nr�r�valuerrrr9sNcCsdS)zR Determines if the given item is contained within this specifier. Nr�r�itemrrrr�contains@szBaseSpecifier.containscCsdS)z� Takes an iterable of items and filters them so that only items which are contained within this specifier are allowed in it. Nr)r�iterablerrrr�filterFszBaseSpecifier.filter)N)N)r r r�abc�abstractmethodrrrr�abstractpropertyr�setterr r"rrrrrs        rc@s�eZdZiZd dd�Zdd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z e dd��Z e dd��Ze dd��Zejdd��Zdd�Zd!dd�Zd"dd�ZdS)#�_IndividualSpecifier�NcCsF|j�|�}|std�|���|�d���|�d���f|_||_dS)NzInvalid specifier: '{0}'�operator�version)�_regex�searchr �format�group�strip�_spec� _prereleases)r�specr�matchrrr�__init__Rs   �z_IndividualSpecifier.__init__cCs0|jdk rd�|j�nd}d�|jjt|�|�S)N�, prereleases={0!r}r(z<{0}({1!r}{2})>)r1r-r� __class__r �str�rZprerrr�__repr___s���z_IndividualSpecifier.__repr__cCs dj|j�S)Nz{0}{1})r-r0rrrrrlsz_IndividualSpecifier.__str__cCs t|j�S�N)�hashr0rrrrrosz_IndividualSpecifier.__hash__cCsPt|t�r4z|�|�}WqDtk r0tYSXnt||j�sDtS|j|jkSr:�� isinstancerr6r �NotImplementedr0rrrrrrs   z_IndividualSpecifier.__eq__cCsPt|t�r4z|�|�}WqDtk r0tYSXnt||j�sDtS|j|jkSr:r<rrrrr}s   z_IndividualSpecifier.__ne__cCst|d�|j|��S)Nz _compare_{0})�getattrr-� _operators)r�oprrr� _get_operator�sz"_IndividualSpecifier._get_operatorcCst|ttf�st|�}|Sr:)r=r rr �rr*rrr�_coerce_version�sz$_IndividualSpecifier._coerce_versioncCs |jdS)Nr�r0rrrrr)�sz_IndividualSpecifier.operatorcCs |jdS)NrrErrrrr*�sz_IndividualSpecifier.versioncCs|jSr:�r1rrrrr�sz _IndividualSpecifier.prereleasescCs ||_dSr:rFrrrrr�scCs |�|�Sr:�r �rrrrr� __contains__�sz!_IndividualSpecifier.__contains__cCs:|dkr|j}|�|�}|jr&|s&dS|�|j�||j�S�NF)rrD� is_prereleaserBr)r*rrrrr �s   z_IndividualSpecifier.containsccs�d}g}d|dk r|ndi}|D]B}|�|�}|j|f|�r |jrX|sX|jsX|�|�q d}|Vq |s||r||D] }|VqpdS)NFrT)rDr rKr�append)rr!rZyielded�found_prereleases�kwr*�parsed_versionrrrr"�s" �� z_IndividualSpecifier.filter)r(N)N)N)r r rr@r4r9rrrrrBrD�propertyr)r*rr&rIr r"rrrrr'Ns(         r'c@sveZdZdZe�dedejejB�Zdddddd d �Z d d �Z d d�Z dd�Z dd�Z dd�Zdd�Zdd�ZdS)�LegacySpecifiera� (?P(==|!=|<=|>=|<|>)) \s* (?P [^,;\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)�==�!=�<=�>=�<�>cCst|t�stt|��}|Sr:)r=r r7rCrrrrD�s  zLegacySpecifier._coerce_versioncCs||�|�kSr:�rD�r� prospectiver2rrr�_compare_equal�szLegacySpecifier._compare_equalcCs||�|�kSr:r`rarrr�_compare_not_equal�sz"LegacySpecifier._compare_not_equalcCs||�|�kSr:r`rarrr�_compare_less_than_equal�sz(LegacySpecifier._compare_less_than_equalcCs||�|�kSr:r`rarrr�_compare_greater_than_equalsz+LegacySpecifier._compare_greater_than_equalcCs||�|�kSr:r`rarrr�_compare_less_thansz"LegacySpecifier._compare_less_thancCs||�|�kSr:r`rarrr�_compare_greater_thansz%LegacySpecifier._compare_greater_thanN)r r r� _regex_str�re�compile�VERBOSE� IGNORECASEr+r@rDrcrdrerfrgrhrrrrrQ�s(� �� rQcst����fdd��}|S)Ncst|t�sdS�|||�SrJ)r=rra��fnrr�wrapped s z)_require_version_compare..wrapped)� functools�wraps)rorprrnr�_require_version_compare srsc @s�eZdZdZe�dedejejB�Zdddddd d d d �Z e d d��Z e dd��Z e dd��Z e dd��Ze dd��Ze dd��Ze dd��Zdd�Zedd��Zejdd��Zd S)!� Specifiera (?P(~=|==|!=|<=|>=|<|>|===)) (?P (?: # 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. (?�s �z/Specifier._compare_compatible..������.*r]rZ)�join�list� itertools� takewhile�_version_splitrB)rrbr2�prefixrrr�_compare_compatible�s ���� �zSpecifier._compare_compatiblecCsp|�d�rPt|j�}t|dd��}tt|��}|dt|��}t||�\}}nt|�}|jsht|j�}||kS)Nr}�����)�endswithrZpublicr�r7�len� _pad_version�localrarrrrc�s    zSpecifier._compare_equalcCs|�||� Sr:)rcrarrrrd�szSpecifier._compare_not_equalcCs |t|�kSr:�rrarrrre�sz"Specifier._compare_less_than_equalcCs |t|�kSr:r�rarrrrf�sz%Specifier._compare_greater_than_equalcCs<t|�}||ksdS|js8|jr8t|j�t|j�kr8dSdS�NFT)rrK� base_versionrarrrrg�s zSpecifier._compare_less_thancCs^t|�}||ksdS|js8|jr8t|j�t|j�kr8dS|jdk rZt|j�t|j�krZdSdSr�)rZis_postreleaser�r�rarrrrh�s  zSpecifier._compare_greater_thancCst|���t|���kSr:)r7�lowerrarrr�_compare_arbitraryszSpecifier._compare_arbitrarycCsR|jdk r|jS|j\}}|dkrN|dkr@|�d�r@|dd�}t|�jrNdSdS)N)rZr]r\rurvrZr}r�TF)r1r0r�r rK)rr)r*rrrrs    zSpecifier.prereleasescCs ||_dSr:rFrrrrrsN)r r rrirjrkrlrmr+r@rsr�rcrdrerfrgrhr�rPrr&rrrrrtsD�_ ��   "      rtz^([0-9]+)((?:a|b|c|rc)[0-9]+)$cCs@g}|�d�D],}t�|�}|r0|�|���q|�|�q|S)Nrw)�split� _prefix_regexr,�extend�groupsrL)r*�resultrr3rrrr�'s  r�c Cs�gg}}|�tt�dd�|���|�tt�dd�|���|�|t|d�d��|�|t|d�d��|�ddgtdt|d�t|d���|�ddgtdt|d�t|d���ttj|��ttj|��fS)NcSs|��Sr:��isdigitryrrrr{6�z_pad_version..cSs|��Sr:r�ryrrrr{7r�rr�0)rLrr�r�r��insert�max�chain)�left�rightZ left_splitZ right_splitrrrr�2s  "�"�  �r�c@s�eZdZddd�Zdd�Zdd�Zd d �Zd d �Zd d�Zdd�Z dd�Z dd�Z e dd��Z e jdd��Z dd�Zddd�Zd dd�ZdS)!� SpecifierSetr(Nc Csndd�|�d�D�}t�}|D]:}z|�t|��Wqtk rV|�t|��YqXqt|�|_||_dS)NcSsg|]}|��r|���qSr)r/��.0�srrr� Rsz)SpecifierSet.__init__..�,) r��set�addrtr rQ� frozenset�_specsr1)rZ specifiersrZparsed� specifierrrrr4Os zSpecifierSet.__init__cCs*|jdk rd�|j�nd}d�t|�|�S)Nr5r(z)r1r-rr7r8rrrr9ds ��zSpecifierSet.__repr__cCsd�tdd�|jD���S)Nr�css|]}t|�VqdSr:)r7r�rrr� nsz'SpecifierSet.__str__..)r~�sortedr�rrrrrmszSpecifierSet.__str__cCs t|j�Sr:)r;r�rrrrrpszSpecifierSet.__hash__cCs�t|t�rt|�}nt|t�s"tSt�}t|j|jB�|_|jdkrX|jdk rX|j|_n<|jdk rv|jdkrv|j|_n|j|jkr�|j|_ntd��|S)NzFCannot combine SpecifierSets with True and False prerelease overrides.)r=rr�r>r�r�r1� ValueError)rrr�rrr�__and__ss        �zSpecifierSet.__and__cCsFt|t�rt|�}n&t|t�r,tt|��}nt|t�s:tS|j|jkSr:�r=rr�r'r7r>r�rrrrr�s    zSpecifierSet.__eq__cCsFt|t�rt|�}n&t|t�r,tt|��}nt|t�s:tS|j|jkSr:r�rrrrr�s    zSpecifierSet.__ne__cCs t|j�Sr:)r�r�rrrr�__len__�szSpecifierSet.__len__cCs t|j�Sr:)�iterr�rrrr�__iter__�szSpecifierSet.__iter__cCs.|jdk r|jS|jsdStdd�|jD��S)Ncss|] }|jVqdSr:�rr�rrrr��sz+SpecifierSet.prereleases..)r1r��anyrrrrr�s  zSpecifierSet.prereleasescCs ||_dSr:rFrrrrr�scCs |�|�Sr:rGrHrrrrI�szSpecifierSet.__contains__csLt�ttf�st����dkr$|j��s2�jr2dSt��fdd�|jD��S)NFc3s|]}|j��d�VqdS)r�NrGr��rrrrr��s�z(SpecifierSet.contains..)r=r rr rrK�allr�rrr�rr �s �zSpecifierSet.containscCs�|dkr|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�|dkr�|S|SdS)Nr�) rr�r"�boolr=r rr rKrL)rr!rr2ZfilteredrMrrOrrrr"�s*      zSpecifierSet.filter)r(N)N)N)r r rr4r9rrr�rrr�r�rPrr&rIr r"rrrrr�Ms        r�)Z __future__rrrr#rqr�rjZ_compatrrr*rr r r�r �ABCMeta�objectrr'rQrsrtrkr�r�r�r�rrrr�s&9 4