
    Ri]                       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	          Zeeegef         Zd(dZd)dZd)dZ G d de          Z G d dej                  Z G d de          Z ej        d          Z d*dZ!d+dZ"d,d!Z#d-d%Z$ G d& d'e          Z%dS ).z
.. 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                t    t          | t                    s"	 t          |           } n# t          $ r Y d S w xY w| S N)
isinstancer   r   r   s    g/Users/shanyulin/my-agent/.venv/lib/python3.11/site-packages/setuptools/_vendor/packaging/specifiers.py_coerce_versionr      sO    gw'' 	g&&GG 	 	 	44	Ns   ' 
55r   c                .    |                      d           S )N)local__replace__r   s    r   _public_versionr   #   s    T***    c                4    |                      d d d d           S )N)prepostdevr   r   r   s    r   _base_versionr$   '   s    4dDIIIr   c                      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&   +   s           r   r&   c                  2   e Zd ZdZdZedd            Zej        dd            Z	ej        dd            Z
ej        dd            Zeej        dd                        Zej        dd            Zej        dd d            Zej        	 dd!d            ZdS )"BaseSpecifierr+   )_strr   strc                     t          |           S )z Internal property for match_argsr/   selfs    r   r.   zBaseSpecifier._str;   s     4yyr   c                    dS )z
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr+   r2   s    r   __str__zBaseSpecifier.__str__@         r   intc                    dS )zF
        Returns a hash value for this Specifier-like object.
        Nr+   r2   s    r   __hash__zBaseSpecifier.__hash__G   r6   r   otherobjectboolc                    dS )z
        Returns a boolean representing whether or not the two Specifier-like
        objects are equal.

        :param other: The other object to check against.
        Nr+   r3   r:   s     r   __eq__zBaseSpecifier.__eq__M   r6   r   bool | Nonec                    dS )zWhether 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+   r2   s    r   prereleaseszBaseSpecifier.prereleasesV   r6   r   valueNonec                    dS )zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr+   r3   rC   s     r   rB   zBaseSpecifier.prereleases_   r6   r   NitemrB   c                    dS )zR
        Determines if the given item is contained within this specifier.
        Nr+   r3   rG   rB   s      r   containszBaseSpecifier.containsf   r6   r   iterableIterable[UnparsedVersionVar]Iterator[UnparsedVersionVar]c                    dS )z
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr+   )r3   rK   rB   s      r   filterzBaseSpecifier.filterl   r6   r   r   r/   r   r7   r:   r;   r   r<   r   r@   )rC   r<   r   rD   r   )rG   r/   rB   r@   r   r<   rK   rL   rB   r@   r   rM   )r'   r(   r)   	__slots____match_args__propertyr.   abcabstractmethodr5   r9   r?   rB   setterrJ   rO   r+   r   r   r-   r-   7   sO       IN   X 	    	   
 	        X     	    
 	QU      r   r-   )	metaclassc            	         e Zd ZU dZdZdZdZ ej        dez   ez   dz   ej	        ej
        z            Zdddd	d
ddddZded<   dEdFdZdGdZdHdZedId            Zej        dJd!            ZedKd"            ZedKd#            ZdKd$ZdKd%ZedLd'            ZdMd)ZdNd-ZdOd0ZdPd2ZdPd3ZdPd4ZdPd5ZdPd6Z dQd8Z!dQd9Z"dRd;Z#dSd>Z$dTdUd@Z%	 dTdVdDZ&dS )W	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/   rB   r@   r   rD   c                $   | 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stripr_   r^   r`   )r3   rr   rB   matchs       r   __init__zSpecifier.__init__   s     %%d++ 	C"#A#A#ABBB KK
##))++KK	""((**'

 ( :>r   r   r   c                    | j         | j         d         |k    r| j         d         S t          |          }|dS ||f| _         |S )zDOne element cache, as only one spec Version is needed per Specifier.Nr   r
   )r`   r   )r3   r   version_specifiers      r   _get_spec_versionzSpecifier._get_spec_version  sX    )d.@.Cw.N.N%a((+G44$4%'89  r   r   c                8    |                      |          }|J |S )zGet 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 ===).
        )r}   )r3   r   spec_versions      r   _require_spec_versionzSpecifier._require_spec_version  s)     --g66'''r   c                    | j         | j         S | j        \  }}|dk    r?|dk    r|                    d          rdS |                     |          }|d S |j        rdS dS )Nrk   rj   .*FT)r^   r_   endswithr}   is_prerelease)r3   rt   version_strr   s       r   rB   zSpecifier.prereleases%  s     ($$ !%
+t 4K$8$8$>$>u ,,[99Gt $ tur   rC   c                    || _         d S r   r^   rF   s     r   rB   zSpecifier.prereleasesB      !r   c                    | j         d         S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   r_   r2   s    r   rt   zSpecifier.operatorF       z!}r   c                    | j         d         S )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r
   r   r2   s    r   r   zSpecifier.versionO  r   r   c                l    | j         
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=rq   rm   ()>)r^   rB   	__class__r'   r/   r3   r!   s     r   __repr__zSpecifier.__repr__X  sT      , 2T-111 	 B4>*AASYYA#AAAAr   c                      dj         | j         S )zA 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{}{})formatr_   r2   s    r   r5   zSpecifier.__str__j  s     v}dj))r   tuple[str, str]c                    | j         \  }}|dk    s|                    d          r||fS |                     |          }t          ||dk              }||fS )Nro   r   ri   strip_trailing_zero)r_   r   r   r   )r3   rt   r   r   canonical_versions        r   _canonical_speczSpecifier._canonical_spect  sw     J'u 0 0 6 6W$$11'::0x4/?
 
 
 ***r   r7   c                *    t          | j                  S r   )hashr   r2   s    r   r9   zSpecifier.__hash__  s    D()))r   r:   r;   r<   c                    t          |t                    r;	 |                     t          |                    }n3# t          $ r
 t          cY S w xY 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
        )r   r/   r   r&   NotImplementedr   r>   s     r   r?   zSpecifier.__eq__  s    & eS!! 	"&s5zz22# & & &%%%%&E4>22 	"!!#u'<<<s   ": AAopCallableOperatorc                B    t          | d| j        |                    }|S )N	_compare_)getattrrp   )r3   r   operator_callables      r   _get_operatorzSpecifier._get_operator  s/    .53dob133/
 /
 ! r   prospectivec           
        t          t          t          j        t          t          |                              d d                   }|dz  } |                     d          ||          o |                     d          ||          S )Nr   rl   rj   )_version_joinlist	itertools	takewhile_is_not_suffix_version_splitr   )r3   r   rr   prefixs       r   _compare_compatiblezSpecifier._compare_compatible  s     $^^D5I5IJJKKCRCP
 

 	$'t!!$''T:: 
?Wt?Q?QRV?W?W@
 @
 	
r   c                   |                     d          rt          t          |          d          }t          |d d         d          }t          |          }t          |          }t	          ||          \  }}|d t          |                   }	|	|k    S |                     |          }
|
j        st          |          }||
k    S )Nr   Fr   )r   r   r   r   _pad_versionlenr   r   )r3   r   rr   normalized_prospectivenormalized_spec
split_specsplit_prospectivepadded_prospective_shortened_prospectiver   s              r   _compare_equalzSpecifier._compare_equal  s    == $	/%9,,%& & &" 349RWXXXO (88J
 !//E F F %11BJ$O$O!
 %77HZ7H$I!(J66  55d;;L
  % ;-k::,..r   c                0    |                      ||           S r   )r   r3   r   rr   s      r   _compare_not_equalzSpecifier._compare_not_equal  s    &&{D9999r   c                N    t          |          |                     |          k    S r   r   r   r   s      r   _compare_less_than_equalz"Specifier._compare_less_than_equal  %     {++t/I/I$/O/OOOr   c                N    t          |          |                     |          k    S r   r   r   s      r   _compare_greater_than_equalz%Specifier._compare_greater_than_equal  r   r   spec_strc                    |                      |          }||k     sdS |j        s)|j        r"t          |          t          |          k    rdS dS NFT)r   r   r$   r3   r   r   rr   s       r   _compare_less_thanzSpecifier._compare_less_than  sj     ))(33
 T!!5 "	)	 k**mD.A.AAA5
 tr   c                    |                      |          }||k    sdS |j        s)|j        r"t          |          t          |          k    rdS |j        "t          |          t          |          k    rdS dS r   )r   is_postreleaser$   r   r   s       r   _compare_greater_thanzSpecifier._compare_greater_than  s     ))(33
 T!!5 #	*	 k**mD.A.AAA5 (].
 .
4  .! .! 5
 tr   Version | strc                    t          |                                          t          |                                          k    S r   )r/   lowerr   s      r   _compare_arbitraryzSpecifier._compare_arbitrary0  s1    ;%%''3t99??+<+<<<r   rG   str | Versionc                ,    |                      |          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
        rJ   r3   rG   s     r   __contains__zSpecifier.__contains__3      & }}T"""r   r   c                f    t          t          |                     |g|                              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
        rB   )r<   r   rO   rI   s      r   rJ   zSpecifier.containsH  s,    2 DdVEEFFGGGr   rK   rL   rM   c              #    K   g }d}||n| j         }|                     | j                  }|D ]}t          |          }|+| j        dk    r|                     || j                  r|V  > ||| j                  r0|j        r|rd}|V  _|| j        dur|                    |           |s|| j        dur|E d{V  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']
        FNro   T)	rB   r   rt   r   r   r   r   r^   append)	r3   rK   rB   prereleases_versionsfound_non_prereleasesinclude_prereleasesr   r   parsed_versions	            r   rO   zSpecifier.filterc  sP     0  " % '2KK8H 	
 !..t}==   	9 	9G,W55N%=E))d.E.ET\/ /) "MMM"">4<@@ 9%3 97J 9,0)!MMMM (T->e-K-K(//888
 &	,#!..++++++++++	, 	,##..r   rq   N)rr   r/   rB   r@   r   rD   )r   r/   r   r   )r   r/   r   r   rS   rC   r@   r   rD   rP   )r   r   rQ   rR   )r   r/   r   r   )r   r   rr   r/   r   r<   )r   r   r   r/   r   r<   )r   r   rr   r/   r   r<   )rG   r   r   r<   r   )rG   r   rB   r@   r   r<   rT   )'r'   r(   r)   r*   rU   _operator_regex_str_version_regex_strrecompileVERBOSE
IGNORECASEru   rp   __annotations__rz   r}   r   rW   rB   rZ   rt   r   r   r5   r   r9   r?   r   r   r   r   r   r   r   r   r   r   rJ   rO   r+   r   r   r]   r]   v   s          ;I\| RZ$$'99FB

R]" F "	 	J 	 	 	 	> > > > >8
! 
! 
! 
!       X8 " " " "    X    XB B B B$* * * * + + + X+* * * *= = = =:! ! ! !
 
 
 
(&/ &/ &/ &/P: : : :P P P PP P P P   6       D= = = =# # # #*H H H H H8 RV<, <, <, <, <, <, <,r   r]   z([0-9]+)((?:a|b|c|rc)[0-9]+)r/   	list[str]c                L   g }|                      d          \  }}}|                    |pd           |                    d          D ][}t                              |          }|r(|                    |                                           F|                    |           \|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.)
rpartitionr   split_prefix_regexrv   extendgroups)r   resultepochr   restrG   ry   s          r   r   r     s     F'',,NE1d
MM%,3

3    ''-- 	 MM%,,..))))MM$Mr   
componentsc                >    | ^}}| dd                     |           S )zJoin 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   )join)r   r   r   s      r   r   r     s+     LED&&chhtnn&&&r   segmentr<   c                <     t           fddD                        S )Nc              3  B   K   | ]}                     |          V  d S r   )
startswith).0r   r   s     r   	<genexpr>z!_is_not_suffix.<locals>.<genexpr>  sB        '-6""     r   )r#   abrcr"   )any)r   s   `r   r   r     s@        1P      r   leftrighttuple[list[str], list[str]]c                   g g }}|                     t          t          j        d |                                |                     t          t          j        d |                               |                     | t	          |d                   d                     |                     |t	          |d                   d                     |                    ddgt          dt	          |d                   t	          |d                   z
            z             |                    ddgt          dt	          |d                   t	          |d                   z
            z             t          t          j                            |                    t          t          j                            |                    fS )Nc                *    |                                  S r   isdigitxs    r   <lambda>z_pad_version.<locals>.<lambda>  s     r   c                *    |                                  S r   r	  r  s    r   r  z_pad_version.<locals>.<lambda>  s    !))++ r   r   r
   r   )	r   r   r   r   r   insertmaxchainfrom_iterable)r  r  
left_splitright_splits       r   r   r     s    "J d9./D/DdKKLLMMMtI/0E0EuMMNNOOO d3z!}--//0111uSQ00223444 a#QKN(;(;c*Q->P>P(P!Q!QQRRRq3%#aZ]););c+a.>Q>Q)Q"R"RRSSS 	Y_**:6677Y_**;7788 r   c                      e Zd ZdZdZ	 	 d&d'dZed(d            Zej        d)d            Zd*dZ	d*dZ
d+dZd,dZd-dZd+dZd.dZd/dZ	 	 d0d1d!Z	 d2d3d%ZdS )4SpecifierSetzThis 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.
    )r^   _specsrq   N
specifiersstr | Iterable[Specifier]rB   r@   r   rD   c                    t          |t                    rGd |                    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                ^    g | ]*}|                                 |                                 +S r+   )rx   r   ss     r   
<listcomp>z)SpecifierSet.__init__.<locals>.<listcomp>  s-    VVVaAGGIIV		VVVr   ,N)r   r/   r   	frozensetmapr]   r  r^   )r3   r  rB   split_specifierss       r   rz   zSpecifierSet.__init__  sz    , j#&& 
	0  WV:3C3CC3H3HVVV $C	3C$D$DEEDKK $J//DK (r   c                t    | j         | j         S | j        sd S t          d | j        D                       rdS d S )Nc              3  $   K   | ]}|j         V  d S r   r   r  s     r   r   z+SpecifierSet.prereleases.<locals>.<genexpr>  s$      22q}222222r   T)r^   r  r  r2   s    r   rB   zSpecifierSet.prereleases  sT     ($$
 { 	4 22dk22222 	4tr   rC   c                    || _         d S r   r   rF   s     r   rB   zSpecifierSet.prereleases$  r   r   r/   c                R    | j         
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)>
        Nr   rq   z<SpecifierSet(r   )r^   rB   r/   r   s     r   r   zSpecifierSet.__repr__(  sF      , 2T-111 	 5D		4S4444r   c                d    d                     t          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              3  4   K   | ]}t          |          V  d S r   r1   r  s     r   r   z'SpecifierSet.__str__.<locals>.<genexpr>H  s(      ;;!s1vv;;;;;;r   )r   sortedr  r2   s    r   r5   zSpecifierSet.__str__=  s/     xx;;t{;;;;;<<<r   r7   c                *    t          | j                  S r   )r   r  r2   s    r   r9   zSpecifierSet.__hash__J  s    DK   r   r:   SpecifierSet | strc                   t          |t                    rt          |          }nt          |t                    st          S t                      }t	          | j        |j        z            |_        | j        |j        |j        |_        n:| j        |j        | j        |j        k    r| j        |_        nt          d          |S )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  r^   
ValueError)r3   r:   	specifiers      r   __and__zSpecifierSet.__and__M  s     eS!! 	" ''EEE<00 	"!! NN	$T[5<%?@@	$);)G%*%7I"")e.@.H%"444%)%6I""X   r   r;   r<   c                    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
        )r   r/   r]   r  r   r  r>   s     r   r?   zSpecifierSet.__eq__l  sW    & ec9-.. 	" U,,EEE<00 	"!!{el**r   c                *    t          | j                  S )z7Returns the number of specifiers in this specifier set.)r   r  r2   s    r   __len__zSpecifierSet.__len__  s    4;r   Iterator[Specifier]c                *    t          | j                  S )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')>]
        )iterr  r2   s    r   __iter__zSpecifierSet.__iter__  s     DK   r   rG   r   c                ,    |                      |          S )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
        r   r   s     r   r   zSpecifierSet.__contains__  r   r   	installedc                    t          |          }||r	|j        rd}||n|}t          t          |                     |g|                              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   r   r<   r   rO   )r3   rG   rB   r8  r   
check_items         r   rJ   zSpecifierSet.contains  s_    @ "$''91FK$_TT'
Dj\{KKLLMMMr   rK   rL   rM   c                  	 || j         | j         }| j        r7| j        D ]}|                    ||dn|          }|t          |          S n%|du rt          |          S |du r	fd|D             S g }g }d}|D ]r}t	          |          }|+|                    |           |                    |           >|j        r|                    |           [|                    |           d}st          |r|n|          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  L   K   | ]}t          |          xj        |V  d S r   )r   r   )r   rG   r   s     r   r   z&SpecifierSet.filter.<locals>.<genexpr>  sN        #24#8#88A"0 B AAAA r   )rB   r  rO   r5  r   r   r   )
r3   rK   rB   rr   filtered_itemsfound_prereleasesfound_final_releaserG   r   r   s
            @r   rO   zSpecifierSet.filter  s   N 4#3#?*K
 ; 	   ;;+2E$$; '   & H~~% ' d""H~~%e##    (    4668# 	+ 	+D,T22N %%%d+++!((....- +!((....%%d+++&*##&9PNN?PQQQr   r   )r  r  rB   r@   r   rD   rS   r   rP   rQ   )r:   r+  r   r  rR   )r   r3  )rG   r   r   r<   )NN)rG   r   rB   r@   r8  r@   r   r<   r   rT   )r'   r(   r)   r*   rU   rz   rW   rB   rZ   r   r5   r9   r/  r?   r2  r6  r   rJ   rO   r+   r   r   r  r    s         +I 13#'$( $( $( $( $(L    X& " " " "5 5 5 5*= = = =! ! ! !   >+ + + +4       ! ! ! !# # # #0 $(!%	&N &N &N &N &NR RV[R [R [R [R [R [R [Rr   r  )r   r   r   r   )r   r   r   r   )r   r/   r   r   )r   r   r   r/   )r   r/   r   r<   )r  r   r  r   r   r  )&r*   
__future__r   rX   r   r   typingr   r   r   r   r   r	   utilsr   r   r   r   r/   r   r   r<   r   r   r   r$   r-  r&   ABCMetar-   r]   r   r   r   r   r   r   r  r+   r   r   <module>rD     sN    # " " " " " 



     				 F F F F F F F F F F F F F F F F ' ' ' ' ' ' , , , , , , , ,%W1III WcND01    + + + +J J J J	 	 	 	 	z 	 	 	< < < < <ck < < < <~i, i, i, i, i, i, i, i,X 
:;;   ,' ' ' '      *KR KR KR KR KR= KR KR KR KR KRr   