o
    Éó·i]Ÿ  ã                   @  s$  d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	m
Z
mZmZ ddlmZ ddlmZmZ eeef Zeded	�Zeeegef Zd/dd„Zd0dd„Zd0dd„ZG dd„ deƒZG dd„ dejd�ZG dd„ deƒZe d¡Z d1dd „Z!d2d"d#„Z"d3d&d'„Z#d4d+d,„Z$G d-d.„ d.eƒZ%dS )5zŠ
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
é    )ÚannotationsN)ÚCallableÚFinalÚIterableÚIteratorÚTypeVarÚUnioné   )Úcanonicalize_version)ÚInvalidVersionÚVersionÚUnparsedVersionVar)ÚboundÚversionÚUnparsedVersionÚreturnúVersion | Nonec                 C  s2   t | tƒszt| ƒ} W | S  ty   Y d S w | S ©N)Ú
isinstancer   r   ©r   © r   úZC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\packaging/specifiers.pyÚ_coerce_version   s   

þÿr   r   c                 C  s   | j d d�S )N)Úlocal©Z__replace__r   r   r   r   Ú_public_version#   s   r   c                 C  s   | j d d d d d�S )N)ÚpreÚpostÚdevr   r   r   r   r   r   Ú_base_version'   s   r   c                   @  s   e Zd ZdZdS )ÚInvalidSpecifiera  
    Raised when attempting to create a :class:`Specifier` with a specifier
    string that is invalid.

    >>> Specifier("lolwat")
    Traceback (most recent call last):
        ...
    packaging.specifiers.InvalidSpecifier: Invalid specifier: 'lolwat'
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r    +   s    r    c                   @  sœ   e Zd ZdZdZed!dd„ƒZejd!dd„ƒZ	ejd"d
d„ƒZ
ejd#dd„ƒZeejd$dd„ƒƒZejd%dd„ƒZejd&d'dd„ƒZej	d&d(dd „ƒZdS ))ÚBaseSpecifierr   )Ú_strr   Ústrc                 C  s   t | ƒS )z Internal property for match_argsN©r'   ©Úselfr   r   r   r&   ;   s   zBaseSpecifier._strc                 C  ó   dS )zŽ
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr   r)   r   r   r   Ú__str__@   ó    zBaseSpecifier.__str__Úintc                 C  r+   )zF
        Returns a hash value for this Specifier-like object.
        Nr   r)   r   r   r   Ú__hash__G   r-   zBaseSpecifier.__hash__ÚotherÚobjectÚboolc                 C  r+   )z«
        Returns a boolean representing whether or not the two Specifier-like
        objects are equal.

        :param other: The other object to check against.
        Nr   ©r*   r0   r   r   r   Ú__eq__M   r-   zBaseSpecifier.__eq__úbool | Nonec                 C  r+   )zîWhether or not pre-releases as a whole are allowed.

        This can be set to either ``True`` or ``False`` to explicitly enable or disable
        prereleases or it can be set to ``None`` (the default) to use default semantics.
        Nr   r)   r   r   r   ÚprereleasesV   r-   zBaseSpecifier.prereleasesÚvalueÚNonec                 C  r+   )zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr   ©r*   r7   r   r   r   r6   _   r-   NÚitemr6   c                 C  r+   )zR
        Determines if the given item is contained within this specifier.
        Nr   ©r*   r:   r6   r   r   r   Úcontainsf   r-   zBaseSpecifier.containsÚiterableúIterable[UnparsedVersionVar]úIterator[UnparsedVersionVar]c                 C  r+   )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*   r=   r6   r   r   r   Úfilterl   r-   zBaseSpecifier.filter©r   r'   ©r   r.   ©r0   r1   r   r2   ©r   r5   )r7   r2   r   r8   r   )r:   r'   r6   r5   r   r2   ©r=   r>   r6   r5   r   r?   )r!   r"   r#   Ú	__slots__Ú__match_args__Úpropertyr&   ÚabcÚabstractmethodr,   r/   r4   r6   Úsetterr<   r@   r   r   r   r   r%   7   s*    ÿr%   )Ú	metaclassc                	   @  sj  e Zd ZU dZdZdZdZe de e d ej	ej
B ¡Zdddd	d
ddddœZded< d\d]dd„Zd^dd„Zd_d d!„Zed`d"d#„ƒZejdad%d#„ƒZedbd&d'„ƒZedbd(d)„ƒZdbd*d+„Zdbd,d-„Zedcd/d0„ƒZddd2d3„Zded7d8„Zdfd;d<„Zdgd>d?„Zdgd@dA„ZdgdBdC„ZdgdDdE„ZdgdFdG„Z dhdIdJ„Z!dhdKdL„Z"didNdO„Z#djdRdS„Z$dkdldUdV„Z%	dkdmdZd[„Z&dS )nÚ	Specifiera?  This class abstracts handling of version specifiers.

    .. tip::

        It is generally not required to instantiate this manually. You should instead
        prefer to work with :class:`SpecifierSet` instead, which can parse
        comma-separated version specifiers (which is what package metadata contains).
    )Ú_prereleasesÚ_specÚ_spec_versionz8
        (?P<operator>(~=|==|!=|<=|>=|<|>|===))
        aÈ  
        (?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;)]*  # The arbitrary version can be just about anything,
                          # we match everything except for whitespace, a
                          # semi-colon for marker support, and a closing paren
                          # since versions can be enclosed in them.
            )
            |
            (?:
                # 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

                # You cannot use a wild card and a pre-release, post-release, a dev or
                # local version together so group them with a | and make them optional.
                (?:
                    \.\*  # Wild card syntax of .*
                    |
                    (?:                                  # pre release
                        [-_\.]?
                        (alpha|beta|preview|pre|a|b|c|rc)
                        [-_\.]?
                        [0-9]*
                    )?
                    (?:                                  # post release
                        (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                    )?
                    (?:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
                )?
            )
            |
            (?:
                # 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
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [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
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        z\s*Ú
compatibleÚequalÚ	not_equalÚless_than_equalÚgreater_than_equalÚ	less_thanÚgreater_thanÚ	arbitrary)ú~=ú==ú!=z<=ú>=ú<ú>ú===r   Ú
_operatorsÚ NÚspecr'   r6   r5   r   r8   c                 C  sL   | j  |¡}|std|›�ƒ‚| d¡ ¡ | d¡ ¡ f| _|| _d| _dS )að  Initialize a Specifier instance.

        :param spec:
            The string representation of a specifier which will be parsed and
            normalized before use.
        :param prereleases:
            This tells the specifier if it should accept prerelease versions if
            applicable or not. The default of ``None`` will autodetect it from the
            given specifiers.
        :raises InvalidSpecifier:
            If the given specifier is invalid (i.e. bad syntax).
        zInvalid specifier: Úoperatorr   N)Ú_regexÚ	fullmatchr    ÚgroupÚstriprO   rN   rP   )r*   rb   r6   Úmatchr   r   r   Ú__init__ó   s   þ
zSpecifier.__init__r   r   c                 C  sD   | j dur| j d |kr| j d S t|ƒ}|du rdS ||f| _ |S )zDOne element cache, as only one spec Version is needed per Specifier.Nr   r	   )rP   r   )r*   r   Zversion_specifierr   r   r   Ú_get_spec_version  s   

zSpecifier._get_spec_versionr   c                 C  s   |   |¡}|dusJ ‚|S )zÕGet spec version, asserting it's valid (not for === operator).

        This method should only be called for operators where version
        strings are guaranteed to be valid PEP 440 versions (not ===).
        N)rj   )r*   r   Úspec_versionr   r   r   Ú_require_spec_version  s   
zSpecifier._require_spec_versionc                 C  s\   | j d ur| j S | j\}}|dkr,|dkr| d¡rdS |  |¡}|d u r'd S |jr,dS dS )Nr[   rZ   ú.*FT)rN   rO   Úendswithrj   Úis_prerelease)r*   rc   Úversion_strr   r   r   r   r6   %  s   


zSpecifier.prereleasesr7   c                 C  ó
   || _ d S r   ©rN   r9   r   r   r   r6   B  ó   
c                 C  ó
   | j d S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   N©rO   r)   r   r   r   rc   F  ó   
zSpecifier.operatorc                 C  rt   )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r	   Nru   r)   r   r   r   r   O  rv   zSpecifier.versionc                 C  s8   | j durd| j›�nd}d| jj› dt| ƒ›|› d�S )aT  A representation of the Specifier that shows all internal state.

        >>> Specifier('>=1.0.0')
        <Specifier('>=1.0.0')>
        >>> Specifier('>=1.0.0', prereleases=False)
        <Specifier('>=1.0.0', prereleases=False)>
        >>> Specifier('>=1.0.0', prereleases=True)
        <Specifier('>=1.0.0', prereleases=True)>
        Nú, prereleases=ra   r]   ú(ú)>)rN   r6   Ú	__class__r!   r'   ©r*   r   r   r   r   Ú__repr__X  s
   ÿýzSpecifier.__repr__c                 C  s   dj | jŽ S )zÐA string representation of the Specifier that can be round-tripped.

        >>> str(Specifier('>=1.0.0'))
        '>=1.0.0'
        >>> str(Specifier('>=1.0.0', prereleases=False))
        '>=1.0.0'
        z{}{}N)ÚformatrO   r)   r   r   r   r,   j  s   zSpecifier.__str__útuple[str, str]c                 C  sF   | j \}}|dks| d¡r||fS |  |¡}t||dkd�}||fS )Nr_   rm   rY   ©Zstrip_trailing_zero)rO   rn   rl   r
   )r*   rc   r   rk   Zcanonical_versionr   r   r   Ú_canonical_spect  s   

ÿzSpecifier._canonical_specr.   c                 C  ó
   t | jƒS r   )Úhashr€   r)   r   r   r   r/   ‚  ó   
zSpecifier.__hash__r0   r1   r2   c                 C  sP   t |tƒrz	|  t|ƒ¡}W n ty   t Y S w t || jƒs"tS | j|jkS )a>  Whether or not the two Specifier-like objects are equal.

        :param other: The other object to check against.

        The value of :attr:`prereleases` is ignored.

        >>> Specifier("==1.2.3") == Specifier("== 1.2.3.0")
        True
        >>> (Specifier("==1.2.3", prereleases=False) ==
        ...  Specifier("==1.2.3", prereleases=True))
        True
        >>> Specifier("==1.2.3") == "==1.2.3"
        True
        >>> Specifier("==1.2.3") == Specifier("==1.2.4")
        False
        >>> Specifier("==1.2.3") == Specifier("~=1.2.3")
        False
        N)r   r'   rz   r    ÚNotImplementedr€   r3   r   r   r   r4   …  s   
ÿzSpecifier.__eq__ÚopÚCallableOperatorc                 C  s   t | d| j| › �ƒ}|S )NÚ	_compare_)Úgetattrr`   )r*   r…   Úoperator_callabler   r   r   Ú_get_operator¢  s   ÿzSpecifier._get_operatorÚprospectivec                 C  sH   t tt tt|ƒ¡ƒd d… ƒ}|d7 }|  d¡||ƒo#|  d¡||ƒS )Néÿÿÿÿrm   r\   rZ   )Ú_version_joinÚlistÚ	itertoolsÚ	takewhileÚ_is_not_suffixÚ_version_splitrŠ   )r*   r‹   rb   Úprefixr   r   r   Ú_compare_compatible¨  s   	ÿÿzSpecifier._compare_compatiblec                 C  s„   |  d¡r2tt|ƒdd�}t|d d… dd�}t|ƒ}t|ƒ}t||ƒ\}}|d t|ƒ… }	|	|kS |  |¡}
|
js>t|ƒ}||
kS )Nrm   Fr   éþÿÿÿ)rn   r
   r   r’   Ú_pad_versionÚlenrl   r   )r*   r‹   rb   Znormalized_prospectiveZnormalized_specÚ
split_specÚsplit_prospectiveÚpadded_prospectiveÚ_Úshortened_prospectiverk   r   r   r   Ú_compare_equal¼  s   
ÿ
zSpecifier._compare_equalc                 C  s   |   ||¡ S r   )r�   ©r*   r‹   rb   r   r   r   Ú_compare_not_equalä  s   zSpecifier._compare_not_equalc                 C  s   t |ƒ|  |¡kS r   ©r   rl   rž   r   r   r   Ú_compare_less_than_equalç  ó   z"Specifier._compare_less_than_equalc                 C  s   t |ƒ|  |¡kS r   r    rž   r   r   r   Ú_compare_greater_than_equalí  r¢   z%Specifier._compare_greater_than_equalÚspec_strc                 C  s:   |   |¡}||k sdS |js|jrt|ƒt|ƒkrdS dS ©NFT)rl   ro   r   ©r*   r‹   r¤   rb   r   r   r   Ú_compare_less_thanó  s   
ÿþýzSpecifier._compare_less_thanc                 C  sX   |   |¡}||ksdS |js|jrt|ƒt|ƒkrdS |jd ur*t|ƒt|ƒkr*dS dS r¥   )rl   Úis_postreleaser   r   r¦   r   r   r   Ú_compare_greater_than  s"   
ÿþýÿþzSpecifier._compare_greater_thanúVersion | strc                 C  s   t |ƒ ¡ t |ƒ ¡ kS r   )r'   Úlowerrž   r   r   r   Ú_compare_arbitrary0  s   zSpecifier._compare_arbitraryr:   ústr | Versionc                 C  ó
   |   |¡S )a:  Return whether or not the item is contained in this specifier.

        :param item: The item to check for.

        This is used for the ``in`` operator and behaves the same as
        :meth:`contains` with no ``prereleases`` argument passed.

        >>> "1.2.3" in Specifier(">=1.2.3")
        True
        >>> Version("1.2.3") in Specifier(">=1.2.3")
        True
        >>> "1.0.0" in Specifier(">=1.2.3")
        False
        >>> "1.3.0a1" in Specifier(">=1.2.3")
        True
        >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
        True
        N©r<   ©r*   r:   r   r   r   Ú__contains__3  ó   
zSpecifier.__contains__r   c                 C  s   t t| j|g|d�ƒƒS )as  Return whether or not the item is contained in this specifier.

        :param item:
            The item to check for, which can be a version string or a
            :class:`Version` instance.
        :param prereleases:
            Whether or not to match prereleases with this Specifier. If set to
            ``None`` (the default), it will follow the recommendation from
            :pep:`440` and match prereleases, as there are no other versions.

        >>> Specifier(">=1.2.3").contains("1.2.3")
        True
        >>> Specifier(">=1.2.3").contains(Version("1.2.3"))
        True
        >>> Specifier(">=1.2.3").contains("1.0.0")
        False
        >>> Specifier(">=1.2.3").contains("1.3.0a1")
        True
        >>> Specifier(">=1.2.3", prereleases=False).contains("1.3.0a1")
        False
        >>> Specifier(">=1.2.3").contains("1.3.0a1")
        True
        ©r6   N)r2   rŽ   r@   r;   r   r   r   r<   H  s   zSpecifier.containsr=   r>   r?   c           	      c  sÐ   � g }d}|dur|n| j }|  | j¡}|D ]9}t|ƒ}|du r0| jdkr/|  || j¡r/|V  q||| jƒrO|jr;|rAd}|V  q|du rO| jdurO| |¡ q|sb|du rd| jdurf|E dH  dS dS dS dS )a  Filter items in the given iterable, that match the specifier.

        :param iterable:
            An iterable that can contain version strings and :class:`Version` instances.
            The items in the iterable will be filtered according to the specifier.
        :param prereleases:
            Whether or not to allow prereleases in the returned iterator. If set to
            ``None`` (the default), it will follow the recommendation from :pep:`440`
            and match prereleases if there are no other versions.

        >>> list(Specifier(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
        ['1.3']
        >>> list(Specifier(">=1.2.3").filter(["1.2", "1.2.3", "1.3", Version("1.4")]))
        ['1.2.3', '1.3', <Version('1.4')>]
        >>> list(Specifier(">=1.2.3").filter(["1.2", "1.5a1"]))
        ['1.5a1']
        >>> list(Specifier(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
        ['1.3', '1.5a1']
        >>> list(Specifier(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
        ['1.3', '1.5a1']
        FNr_   T)	r6   rŠ   rc   r   r¬   r   ro   rN   Úappend)	r*   r=   r6   Zprereleases_versionsZfound_non_prereleasesZinclude_prereleasesr‰   r   Úparsed_versionr   r   r   r@   c  s:   €ÿÿ€

€ÿþýûzSpecifier.filter©ra   N)rb   r'   r6   r5   r   r8   )r   r'   r   r   )r   r'   r   r   rD   ©r7   r5   r   r8   rA   )r   r~   rB   rC   )r…   r'   r   r†   )r‹   r   rb   r'   r   r2   )r‹   r   r¤   r'   r   r2   )r‹   rª   rb   r'   r   r2   )r:   r­   r   r2   r   )r:   r   r6   r5   r   r2   rE   )'r!   r"   r#   r$   rF   Z_operator_regex_strZ_version_regex_strÚreÚcompileÚVERBOSEÚ
IGNORECASErd   r`   Ú__annotations__ri   rj   rl   rH   r6   rK   rc   r   r|   r,   r€   r/   r4   rŠ   r”   r�   rŸ   r¡   r£   r§   r©   r¬   r±   r<   r@   r   r   r   r   rM   v   s`   
 	^
þø











(




"
ÿrM   z([0-9]+)((?:a|b|c|rc)[0-9]+)r'   ú	list[str]c                 C  s^   g }|   d¡\}}}| |pd¡ | d¡D ]}t |¡}|r'| | ¡ ¡ q| |¡ q|S )a  Split version into components.

    The split components are intended for version comparison. The logic does
    not attempt to retain the original version string, so joining the
    components back with :func:`_version_join` may not produce the original
    version string.
    ú!Ú0Ú.N)Ú
rpartitionr´   ÚsplitÚ_prefix_regexre   ÚextendÚgroups)r   ÚresultÚepochr›   Úrestr:   rh   r   r   r   r’   ¥  s   
r’   Ú
componentsc                 C  s   | ^}}|› dd  |¡› �S )zñJoin split version components into a version string.

    This function assumes the input came from :func:`_version_split`, where the
    first component must be the epoch (either empty or numeric), and all other
    components numeric.
    r¾   rÀ   N)Újoin)rÉ   rÇ   rÈ   r   r   r   r�   »  s   r�   Úsegmentr2   c                   s   t ‡ fdd„dD ƒƒ S )Nc                 3  s   � | ]}ˆ   |¡V  qd S r   )Ú
startswith)Ú.0r“   ©rË   r   r   Ú	<genexpr>Ç  s   € 

ÿz!_is_not_suffix.<locals>.<genexpr>)r   ÚaÚbÚrcr   )ÚanyrÎ   r   rÎ   r   r‘   Æ  s   
ÿr‘   ÚleftÚrightútuple[list[str], list[str]]c              
   C  sê   g g }}|  tt dd„ | ¡ƒ¡ |  tt dd„ |¡ƒ¡ |  | t|d ƒd … ¡ |  |t|d ƒd … ¡ | ddgtdt|d ƒt|d ƒ ƒ ¡ | ddgtdt|d ƒt|d ƒ ƒ ¡ ttj |¡ƒttj |¡ƒfS )Nc                 S  ó   |   ¡ S r   ©Úisdigit©Úxr   r   r   Ú<lambda>Ð  ó    z_pad_version.<locals>.<lambda>c                 S  r×   r   rØ   rÚ   r   r   r   rÜ   Ñ  rÝ   r   r	   r¿   )	r´   rŽ   r�   r�   r—   ÚinsertÚmaxÚchainÚfrom_iterable)rÔ   rÕ   Ú
left_splitÚright_splitr   r   r   r–   Ì  s   
,,þr–   c                   @  s°   e Zd ZdZdZ		d2d3dd„Zed4dd„ƒZejd5dd„ƒZd6dd„Z	d6dd„Z
d7dd„Zd8dd„Zd9dd „Zd7d!d"„Zd:d$d%„Zd;d(d)„Z		d<d=d+d,„Z	d>d?d0d1„ZdS )@ÚSpecifierSetzÌThis class abstracts handling of a set of version specifiers.

    It can be passed a single specifier (``>=3.0``), a comma-separated list of
    specifiers (``>=3.0,!=3.1``), or no specifier at all.
    )rN   Ú_specsra   NÚ
specifiersústr | Iterable[Specifier]r6   r5   r   r8   c                 C  sD   t |tƒrdd„ | d¡D ƒ}ttt|ƒƒ| _nt|ƒ| _|| _dS )a´  Initialize a SpecifierSet instance.

        :param specifiers:
            The string representation of a specifier or a comma-separated list of
            specifiers which will be parsed and normalized before use.
            May also be an iterable of ``Specifier`` instances, which will be used
            as is.
        :param prereleases:
            This tells the SpecifierSet if it should accept prerelease versions if
            applicable or not. The default of ``None`` will autodetect it from the
            given specifiers.

        :raises InvalidSpecifier:
            If the given ``specifiers`` are not parseable than this exception will be
            raised.
        c                 S  s   g | ]
}|  ¡ r|  ¡ ‘qS r   )rg   ©rÍ   Úsr   r   r   Ú
<listcomp>  s    z)SpecifierSet.__init__.<locals>.<listcomp>ú,N)r   r'   rÂ   Ú	frozensetÚmaprM   rå   rN   )r*   ræ   r6   Úsplit_specifiersr   r   r   ri   ê  s
   


zSpecifierSet.__init__c                 C  s6   | j d ur| j S | jsd S tdd„ | jD ƒƒrdS d S )Nc                 s  s   � | ]}|j V  qd S r   r³   rè   r   r   r   rÏ     s   € z+SpecifierSet.prereleases.<locals>.<genexpr>T)rN   rå   rÓ   r)   r   r   r   r6     s   
zSpecifierSet.prereleasesr7   c                 C  rq   r   rr   r9   r   r   r   r6   $  rs   r'   c                 C  s.   | j durd| j›�nd}dt| ƒ›|› d�S )a  A representation of the specifier set that shows all internal state.

        Note that the ordering of the individual specifiers within the set may not
        match the input string.

        >>> SpecifierSet('>=1.0.0,!=2.0.0')
        <SpecifierSet('!=2.0.0,>=1.0.0')>
        >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=False)
        <SpecifierSet('!=2.0.0,>=1.0.0', prereleases=False)>
        >>> SpecifierSet('>=1.0.0,!=2.0.0', prereleases=True)
        <SpecifierSet('!=2.0.0,>=1.0.0', prereleases=True)>
        Nrw   ra   z<SpecifierSet(ry   )rN   r6   r'   r{   r   r   r   r|   (  s
   ÿýzSpecifierSet.__repr__c                 C  s   d  tdd„ | jD ƒƒ¡S )an  A string representation of the specifier set that can be round-tripped.

        Note that the ordering of the individual specifiers within the set may not
        match the input string.

        >>> str(SpecifierSet(">=1.0.0,!=1.0.1"))
        '!=1.0.1,>=1.0.0'
        >>> str(SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False))
        '!=1.0.1,>=1.0.0'
        rë   c                 s  s   � | ]}t |ƒV  qd S r   r(   rè   r   r   r   rÏ   H  s   € z'SpecifierSet.__str__.<locals>.<genexpr>N)rÊ   Úsortedrå   r)   r   r   r   r,   =  s   zSpecifierSet.__str__r.   c                 C  r�   r   )r‚   rå   r)   r   r   r   r/   J  rƒ   zSpecifierSet.__hash__r0   úSpecifierSet | strc                 C  sŽ   t |tƒr
t|ƒ}nt |tƒstS tƒ }t| j|jB ƒ|_| jdu r-|jdur-|j|_|S | jdur7|jdu s=| j|jkrC| j|_|S tdƒ‚)a‚  Return a SpecifierSet which is a combination of the two sets.

        :param other: The other object to combine with.

        >>> SpecifierSet(">=1.0.0,!=1.0.1") & '<=2.0.0,!=2.0.1'
        <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
        >>> SpecifierSet(">=1.0.0,!=1.0.1") & SpecifierSet('<=2.0.0,!=2.0.1')
        <SpecifierSet('!=1.0.1,!=2.0.1,<=2.0.0,>=1.0.0')>
        NzFCannot combine SpecifierSets with True and False prerelease overrides.)r   r'   rä   r„   rì   rå   rN   Ú
ValueError)r*   r0   Ú	specifierr   r   r   Ú__and__M  s(   




øÿÿ
þüÿzSpecifierSet.__and__r1   r2   c                 C  s6   t |ttfƒrtt|ƒƒ}nt |tƒstS | j|jkS )a¡  Whether or not the two SpecifierSet-like objects are equal.

        :param other: The other object to check against.

        The value of :attr:`prereleases` is ignored.

        >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> (SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False) ==
        ...  SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True))
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1") == ">=1.0.0,!=1.0.1"
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1") == SpecifierSet(">=1.0.0,!=1.0.2")
        False
        N)r   r'   rM   rä   r„   rå   r3   r   r   r   r4   l  s
   
zSpecifierSet.__eq__c                 C  r�   )z7Returns the number of specifiers in this specifier set.N)r—   rå   r)   r   r   r   Ú__len__†  rs   zSpecifierSet.__len__úIterator[Specifier]c                 C  r�   )zð
        Returns an iterator over all the underlying :class:`Specifier` instances
        in this specifier set.

        >>> sorted(SpecifierSet(">=1.0.0,!=1.0.1"), key=str)
        [<Specifier('!=1.0.1')>, <Specifier('>=1.0.0')>]
        N)Úiterrå   r)   r   r   r   Ú__iter__Š  s   
zSpecifierSet.__iter__r:   r   c                 C  r®   )aq  Return whether or not the item is contained in this specifier.

        :param item: The item to check for.

        This is used for the ``in`` operator and behaves the same as
        :meth:`contains` with no ``prereleases`` argument passed.

        >>> "1.2.3" in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> Version("1.2.3") in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> "1.0.1" in SpecifierSet(">=1.0.0,!=1.0.1")
        False
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
        True
        Nr¯   r°   r   r   r   r±   ”  r²   zSpecifierSet.__contains__Ú	installedc                 C  sF   t |ƒ}|dur|r|jrd}|du r|n|}tt| j|g|d�ƒƒS )a‡  Return whether or not the item is contained in this SpecifierSet.

        :param item:
            The item to check for, which can be a version string or a
            :class:`Version` instance.
        :param prereleases:
            Whether or not to match prereleases with this SpecifierSet. If set to
            ``None`` (the default), it will follow the recommendation from :pep:`440`
            and match prereleases, as there are no other versions.
        :param installed:
            Whether or not the item is installed. If set to ``True``, it will
            accept prerelease versions even if the specifier does not allow them.

        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.2.3")
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains(Version("1.2.3"))
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.0.1")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1")
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=False).contains("1.3.0a1")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
        True
        NTr³   )r   ro   r2   rŽ   r@   )r*   r:   r6   rø   r   Z
check_itemr   r   r   r<   ©  s
    zSpecifierSet.containsr=   r>   r?   c           	        sî   |du r| j dur| j }| jr+| jD ]}|j||du rdn|d�}q|dur*t|ƒS n|du r3t|ƒS |du r@‡ fdd„|D ƒS g }g }d}|D ]%}t|ƒ}|du r]| |¡ | |¡ qH|jrf| |¡ qH| |¡ d}qHt|rt|ƒS |ƒS )aö  Filter items in the given iterable, that match the specifiers in this set.

        :param iterable:
            An iterable that can contain version strings and :class:`Version` instances.
            The items in the iterable will be filtered according to the specifier.
        :param prereleases:
            Whether or not to allow prereleases in the returned iterator. If set to
            ``None`` (the default), it will follow the recommendation from :pep:`440`
            and match prereleases if there are no other versions.

        >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", "1.5a1"]))
        ['1.3']
        >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.3", Version("1.4")]))
        ['1.3', <Version('1.4')>]
        >>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.5a1"]))
        ['1.5a1']
        >>> list(SpecifierSet(">=1.2.3").filter(["1.3", "1.5a1"], prereleases=True))
        ['1.3', '1.5a1']
        >>> list(SpecifierSet(">=1.2.3", prereleases=True).filter(["1.3", "1.5a1"]))
        ['1.3', '1.5a1']

        An "empty" SpecifierSet will filter items based on the presence of prerelease
        versions in the set.

        >>> list(SpecifierSet("").filter(["1.3", "1.5a1"]))
        ['1.3']
        >>> list(SpecifierSet("").filter(["1.5a1"]))
        ['1.5a1']
        >>> list(SpecifierSet("", prereleases=True).filter(["1.3", "1.5a1"]))
        ['1.3', '1.5a1']
        >>> list(SpecifierSet("").filter(["1.3", "1.5a1"], prereleases=True))
        ['1.3', '1.5a1']
        NTr³   Fc                 3  s*   � | ]}t |ƒ ‰ d u sˆ js|V  qd S r   )r   ro   )rÍ   r:   r   r   r   rÏ     s   € ýü
ÿz&SpecifierSet.filter.<locals>.<genexpr>)r6   rå   r@   rö   r   r´   ro   )	r*   r=   r6   rb   Zfiltered_itemsÚfound_prereleasesZfound_final_releaser:   rµ   r   r   r   r@   Ñ  s:   '
ÿý
þ	

zSpecifierSet.filterr¶   )ræ   rç   r6   r5   r   r8   rD   r·   rA   rB   )r0   rð   r   rä   rC   )r   rõ   )r:   r   r   r2   )NN)r:   r   r6   r5   rø   r5   r   r2   r   rE   )r!   r"   r#   r$   rF   ri   rH   r6   rK   r|   r,   r/   ró   r4   rô   r÷   r±   r<   r@   r   r   r   r   rä   á  s.    ý&








ü)ÿrä   )r   r   r   r   )r   r   r   r   )r   r'   r   r½   )rÉ   r½   r   r'   )rË   r'   r   r2   )rÔ   r½   rÕ   r½   r   rÖ   )&r$   Ú
__future__r   rI   r�   r¸   Útypingr   r   r   r   r   r   Úutilsr
   r   r   r   r'   r   r   r2   r†   r   r   r   rñ   r    ÚABCMetar%   rM   r¹   rÃ   r’   r�   r‘   r–   rä   r   r   r   r   Ú<module>   s6    

	
?    
0



