
    S$gb              	          d 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
mZmZ ddlmZ ddlmZ eeef         Z ede          Zeeegef         Zd	ed
efdZ G d de          Z G d dej                  Z G d de          Z ej        d          Zd	ed
ee         fdZdee         d
efdZded
efdZ dee         dee         d
e
ee         ee         f         fdZ! G d de          Z"dS )z
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
    N)CallableIterableIteratorListOptionalTupleTypeVarUnion   )canonicalize_version)VersionUnparsedVersionVar)boundversionreturnc                 N    t          | t                    st          |           } | S N)
isinstancer   )r   s    c/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/wheel/vendored/packaging/specifiers.py_coerce_versionr      s&    gw'' #'""N    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            	          e Zd Zej        defd            Zej        defd            Zej        de	de
fd            Zeej        dee
         fd                        Zej        de
ddfd	            Zej        dd
edee
         de
fd            Zej        	 ddee         dee
         dee         fd            ZdS )BaseSpecifierr   c                     dS )z
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr   selfs    r   __str__zBaseSpecifier.__str__+         r   c                     dS )zF
        Returns a hash value for this Specifier-like object.
        Nr   r"   s    r   __hash__zBaseSpecifier.__hash__2   r%   r   otherc                     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   r#   r(   s     r   __eq__zBaseSpecifier.__eq__8   r%   r   c                     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   r"   s    r   prereleaseszBaseSpecifier.prereleasesA   r%   r   valueNc                     dS )zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr   r#   r.   s     r   r-   zBaseSpecifier.prereleasesJ   r%   r   itemr-   c                     dS )zR
        Determines if the given item is contained within this specifier.
        Nr   )r#   r1   r-   s      r   containszBaseSpecifier.containsQ   r%   r   iterablec                     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   )r#   r4   r-   s      r   filterzBaseSpecifier.filterW   r%   r   r   )r   r   r   abcabstractmethodstrr$   intr'   objectboolr+   propertyr   r-   setterr3   r   r   r   r6   r   r   r   r    r    *   s            	#    
 	F t     Xd^     X  $     	 S x~     
 	TX  !34CKD>	$	%     r   r    )	metaclassc            	          e Z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d1dedee         ddfdZedefd            Zej        deddfd            Zedefd            Zedefd            ZdefdZdefdZedeeef         fd            ZdefdZdedefdZd edefd!Zd"ededefd#Z d"ededefd$Z!d"ededefd%Z"d"ededefd&Z#d"ededefd'Z$d"ed(edefd)Z%d"ed(edefd*Z&d"ededefd+Z'd,e(eef         defd-Z)	 d2d,e*dee         defd.Z+	 d2d/e,e-         dee         de.e-         fd0Z/dS )3	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).
    z8
        (?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*z\s*$
compatibleequal	not_equalless_than_equalgreater_than_equal	less_thangreater_than	arbitrary)~===z!=<=>=<>=== Nspecr-   r   c                    | j                             |          }|st          d| d          |                    d                                          |                    d                                          f| _        || _        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searchr   groupstrip_spec_prereleases)r#   rR   r-   matchs       r   __init__zSpecifier.__init__   s     ""4(( 	C"#A$#A#A#ABBB KK
##))++KK	""((**'

 (r   c                     | j         | j         S | j        \  }}|dv r;|dk    r|                    d          r
|d d         }t          |          j        rdS dS )N)rK   rM   rL   rJ   rP   rK   .*TF)r[   rZ   endswithr   is_prerelease)r#   rU   r   s      r   r-   zSpecifier.prereleases   s|     ($$
 !J'666 4G$4$4T$:$:!#2#, w- tur   r.   c                     || _         d S r   r[   r0   s     r   r-   zSpecifier.prereleases      !r   c                     | j         d         S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   rZ   r"   s    r   rU   zSpecifier.operator       z!}r   c                     | j         d         S )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r   rg   r"   s    r   r   zSpecifier.version  rh   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   rN   ()>)r[   r-   	__class__r   r9   r#   pres     r   __repr__zSpecifier.__repr__$  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{}{})formatrZ   r"   s    r   r$   zSpecifier.__str__6  s     v}dj))r   c                 v    t          | j        d         | j        d         dk              }| j        d         |fS )Nr   r   rJ   strip_trailing_zero)r   rZ   )r#   canonical_versions     r   _canonical_speczSpecifier._canonical_spec@  sB    0JqM!%A$!6
 
 
 z!}///r   c                 *    t          | j                  S r   )hashrx   r"   s    r   r'   zSpecifier.__hash__H  s    D()))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   r9   rn   r   NotImplementedrx   r*   s     r   r+   zSpecifier.__eq__K  s    & eS!! 	"&s5zz22# & & &%%%%&E4>22 	"!!#u'<<<s   ": AAopc                 B    t          | d| j        |                    }|S )N	_compare_)getattr
_operators)r#   r}   operator_callables      r   _get_operatorzSpecifier._get_operatorh  s/    .53dob133/
 /
 ! r   prospectivec           
         t          t          t          j        t          t          |                              d d                   }|dz  } |                     d          ||          o |                     d          ||          S )Nr_   rM   rK   )_version_joinlist	itertools	takewhile_is_not_suffix_version_splitr   )r#   r   rR   prefixs       r   _compare_compatiblezSpecifier._compare_compatiblen  s     $^^D5I5IJJKKCRCP
 

 	$'t!!$''T:: 
?Wt?Q?QRV?W?W@
 @
 	
r   c                    |                     d          r}t          |j        d          }t          |d d         d          }t          |          }t          |          }t	          ||          \  }}|d t          |                   }	|	|k    S t          |          }
|
j        st          |j                  }||
k    S )Nr_   Fru   r`   )ra   r   publicr   _pad_versionlenr   local)r#   r   rR   normalized_prospectivenormalized_spec
split_specsplit_prospectivepadded_prospective_shortened_prospectivespec_versions              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 #4==L
  % :%k&899,..r   c                 0    |                      ||           S r   )r   r#   r   rR   s      r   _compare_not_equalzSpecifier._compare_not_equal  s    &&{D9999r   c                 L    t          |j                  t          |          k    S r   r   r   r   s      r   _compare_less_than_equalz"Specifier._compare_less_than_equal        {)**gdmm;;r   c                 L    t          |j                  t          |          k    S r   r   r   s      r   _compare_greater_than_equalz%Specifier._compare_greater_than_equal  r   r   spec_strc                     t          |          }||k     sdS |j        s3|j        r,t          |j                  t          |j                  k    rdS dS NFT)r   rb   base_versionr#   r   r   rR   s       r   _compare_less_thanzSpecifier._compare_less_than  sg     x  
 T!!5 ! 	k&? 	{/00GD<M4N4NNNu
 tr   c                    t          |          }||k    sdS |j        s3|j        r,t          |j                  t          |j                  k    rdS |j        ,t          |j                  t          |j                  k    rdS dS r   )r   is_postreleaser   r   r   s       r   _compare_greater_thanzSpecifier._compare_greater_than  s     x  
 T!!5 " 	{'A 	{/00GD<M4N4NNNu ({/00GD<M4N4NNNu
 tr   c                     t          |                                          t          |                                          k    S r   )r9   lowerr   s      r   _compare_arbitraryzSpecifier._compare_arbitrary  s1    ;%%''3t99??+<+<<<r   r1   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")
        False
        >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
        True
        r3   r#   r1   s     r   __contains__zSpecifier.__contains__      & }}T"""r   c                     || j         }t          |          }|j        r|sdS |                     | j                  } ||| j                  S )al  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 uses :attr:`prereleases` to determine
            whether or not prereleases are allowed.

        >>> 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")
        False
        >>> Specifier(">=1.2.3", prereleases=True).contains("1.3.0a1")
        True
        >>> Specifier(">=1.2.3").contains("1.3.0a1", prereleases=True)
        True
        NF)r-   r   rb   r   rU   r   )r#   r1   r-   normalized_itemr   s        r   r3   zSpecifier.contains  sg    8 *K *$//
 ( 	 	5 /3.@.@.O.O  $,???r   r4   c              #      K   d}g }d||ndi}|D ]K}t          |          } | j        |fi |r,|j        r|s| j        s|                    |           Ed}|V  L|s|r|D ]
}|V  dS dS dS )aO  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 be intelligently decide whether to allow
            prereleases or not (based on the :attr:`prereleases` attribute, and
            whether the only versions matching are prereleases).

        This method is smarter than just ``filter(Specifier().contains, [...])``
        because it implements the rule from :pep:`440` that a prerelease item
        SHOULD be accepted if no other versions match the given specifier.

        >>> 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']
        Fr-   NT)r   r3   rb   r-   append)r#   r4   r-   yieldedfound_prereleaseskwr   parsed_versions           r   r6   zSpecifier.filter5  s      < K,C[[N   	" 	"G,W55Nt}^22r22 " "/ ""#'#3" &,,W5555 #G!MMM
  	, 	,  	 	 	 	 r   rQ   Nr   )0r   r   r   r   _operator_regex_str_version_regex_strrecompileVERBOSE
IGNORECASErV   r   r9   r   r<   r]   r=   r-   r>   rU   r   rq   r$   r   rx   r:   r'   r;   r+   CallableOperatorr   r   r   r   r   r   r   r   r   r   r
   r   UnparsedVersionr3   r   r   r   r6   r   r   r   rA   rA   a   s/        \| RZ%%(::WD

R]" F "	 	J( (S (HTN (d ( ( ( (4 T    X. " "$ " " " " #    X     XB# B B B B$* * * * * 0sCx 0 0 0 X0*# * * * *=F =t = = = =:! !(8 ! ! ! !
w 
c 
d 
 
 
 
(&/' &/ &/ &/ &/ &/ &/P:g :S :T : : : :<G <3 <4 < < < <<w <c <d < < < <g      0 C D    <=g =S =T = = = =#sG|!4 # # # # #, DH,@ ,@#,@2:4.,@	,@ ,@ ,@ ,@^ UY; ; !34;CKD>;	$	%; ; ; ; ; ;r   rA   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$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_regexrW   extendgroups)r   resultepochr   restr1   r\   s          r   r   r   v  s     F'',,NE1d
MM%,3

3    $$T** 	 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   segmentc                 <     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   )devabrcpost)any)r   s   `r   r   r     s@        1P      r   leftrightc                    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dedee         ddfdZedee         fd            Z	e	j
        d	eddfd
            Z	defdZdefdZdefdZded ef         dd fdZdedefdZdefdZdee         fdZdedefdZ	 	 ddedee         dee         defdZ	 ddee         dee         dee         fdZdS )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.
    rQ   N
specifiersr-   r   c                     d |                     d          D             }t          t          t          |                    | _        || _        dS )aN  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.
        :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   )rY   r   ss     r   
<listcomp>z)SpecifierSet.__init__.<locals>.<listcomp>  s-    RRR!		RAGGIIRRRr   ,N)r   	frozensetmaprA   _specsr[   )r#   r   r-   split_specifierss       r   r]   zSpecifierSet.__init__  sS    ( SRz/?/?/D/DRRR  I/? @ @AA (r   c                 l    | j         | j         S | j        sd S t          d | j        D                       S )Nc              3   $   K   | ]}|j         V  d S r   r-   r   s     r   r   z+SpecifierSet.prereleases.<locals>.<genexpr>  s$      66Q1=666666r   )r[   r   r   r"   s    r   r-   zSpecifierSet.prereleases  sH     ($$
 { 	4 66$+666666r   r.   c                     || _         d S r   rd   r0   s     r   r-   zSpecifierSet.prereleases  re   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)>
        Nrk   rQ   z<SpecifierSet(rm   )r[   r-   r9   ro   s     r   rq   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   )r9   r   s     r   r   z'SpecifierSet.__str__.<locals>.<genexpr>  s(      ;;!s1vv;;;;;;r   )r   sortedr   r"   s    r   r$   zSpecifierSet.__str__   s/     xx;;t{;;;;;<<<r   c                 *    t          | j                  S r   )rz   r   r"   s    r   r'   zSpecifierSet.__hash__  s    DK   r   r(   c                    t          |t                    rt          |          }nt          |t                    st          S t                      }t	          | j        |j        z            |_        | j        |j        |j        |_        nG| j        |j        | j        |_        n,| 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   r9   r   r|   r   r   r[   
ValueError)r#   r(   	specifiers      r   __and__zSpecifierSet.__and__  s     eS!! 	" ''EEE<00 	"!! NN	$T[5<%?@@	$);)G%*%7I""*u/A/I%)%6I""%"444%)%6I""  
 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   r9   rA   r   r|   r   r*   s     r   r+   zSpecifierSet.__eq__0  sW    & ec9-.. 	" U,,EEE<00 	"!!{el**r   c                 *    t          | j                  S )z7Returns the number of specifiers in this specifier set.)r   r   r"   s    r   __len__zSpecifierSet.__len__J  s    4;r   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   r"   s    r   __iter__zSpecifierSet.__iter__N  s     DK   r   r1   c                 ,    |                      |          S )ar  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")
        False
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
        True
        r   r   s     r   r   zSpecifierSet.__contains__X  r   r   	installedc                     t          t                    st                    | j        s	j        rdS |rj        rt          j                  t          fd| j        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 uses :attr:`prereleases` to determine
            whether or not prereleases are allowed.

        >>> 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")
        False
        >>> SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True).contains("1.3.0a1")
        True
        >>> SpecifierSet(">=1.0.0,!=1.0.1").contains("1.3.0a1", prereleases=True)
        True
        NFc              3   F   K   | ]}|                                V  dS )r  Nr   )r   r   r1   r-   s     r   r   z(SpecifierSet.contains.<locals>.<genexpr>  s3      RR1::d:<<RRRRRRr   )r   r   r-   rb   r   allr   )r#   r1   r-   r  s    `` r   r3   zSpecifierSet.containsm  s    < $(( 	!4==D
 *K  	t1 	5 	.+ 	.4,--D RRRRRdkRRRRRRr   r4   c                    || j         }| j        r=| j        D ]&}|                    |t          |                    }'t	          |          S g }g }|D ]G}t          |          }|j        r|s|s|                    |           2|                    |           H|s|r|t	          |          S t	          |          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 be intelligently decide whether to allow
            prereleases or not (based on the :attr:`prereleases` attribute, and
            whether the only versions matching are prereleases).

        This method is smarter than just ``filter(SpecifierSet(...).contains, [...])``
        because it implements the rule from :pep:`440` that a prerelease item
        SHOULD be accepted if no other versions match the given specifier.

        >>> 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"]))
        []
        >>> 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']
        Nr  )r-   r   r6   r<   r  r   rb   r   )r#   r4   r-   rR   filteredr   r1   r   s           r   r6   zSpecifierSet.filter  s    X *K
 ; 	" P P;;xT+=N=N;OO>>!
 24H:<  	* 	*!0!6!6 "/ * *# 7)00666OOD))))  / 1 /k6I-...>>!r   r   )NNr   )r   r   r   r   r9   r   r<   r]   r=   r-   r>   rq   r$   r:   r'   r
   r  r;   r+   r  r   rA   r  r   r   r3   r   r   r6   r   r   r   r   r     s_         CG( ((19$(	( ( ( (: 7Xd^ 7 7 7 X7  " "$ " " " "5# 5 5 5 5*= = = = =!# ! ! ! !U>3#67 N    @+F +t + + + +4         !(9- ! ! ! !# #T # # # #0 '+$(	7S 7S7S d^7S D>	7S
 
7S 7S 7S 7St UYM" M" !34M"CKD>M"	$	%M" M" M" M" M" M"r   r   )#r   r7   r   r   typingr   r   r   r   r   r   r	   r
   utilsr   r   r   r9   r   r   r<   r   r   r
  r   ABCMetar    rA   r   r   r   r   r   r   r   r   r   r   <module>r     s{    


     				 V V V V V V V V V V V V V V V V V V V V ' ' ' ' ' '      %W1III WcND01 _     	 	 	 	 	z 	 	 	4 4 4 4 4ck 4 4 4 4nO O O O O O O Od 
<==C DI    ,'d3i 'C ' ' ' 'C D    tCy c uT#YS	=Q7R    *A" A" A" A" A"= A" A" A" A" A"r   