o
    Ee&                  	   @   sB  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mZ ddlmZ ddlmZ eeef ZededZeeegef Zd	ed
efd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d	ed
ee fddZded
efddZ dee dee d
eee ee f fddZ!G d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SetTupleTypeVarUnion   )canonicalize_version)VersionUnparsedVersionVar)boundversionreturnc                 C   s   t | ts	t| } | S N)
isinstancer   )r    r   h/var/www/bmteknikk.ddns.net/venv/lib/python3.10/site-packages/setuptools/_vendor/packaging/specifiers.py_coerce_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ejdefddZejdefddZejde	de
fddZeejdee
 fd	d
Zejde
ddfdd
Zejddedee
 de
fddZej	ddee dee
 dee fddZdS )BaseSpecifierr   c                 C      dS )z
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr   selfr   r   r   __str__5       zBaseSpecifier.__str__c                 C   r   )zF
        Returns a hash value for this Specifier-like object.
        Nr   r   r   r   r   __hash__<   r!   zBaseSpecifier.__hash__otherc                 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   r#   r   r   r   __eq__B   r!   zBaseSpecifier.__eq__c                 C   r   )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   r   r   r   prereleasesK   r!   zBaseSpecifier.prereleasesvalueNc                 C   r   )zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr   r   r'   r   r   r   r&   T   r!   itemr&   c                 C   r   )zR
        Determines if the given item is contained within this specifier.
        Nr   )r   r)   r&   r   r   r   contains[   r!   zBaseSpecifier.containsiterablec                 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+   r&   r   r   r   filtera   r!   zBaseSpecifier.filterr   )r   r   r   abcabstractmethodstrr    intr"   objectboolr%   propertyr   r&   setterr*   r   r   r   r,   r   r   r   r   r   4   s.    r   )	metaclassc                	   @   s.  e Z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dFdedee ddfddZedefddZejdeddfddZedefddZedefddZdefddZdefd d!Zedeeef fd"d#Zdefd$d%Zd&edefd'd(Zd)edefd*d+Zd,ededefd-d.Z d,ededefd/d0Z!d,ededefd1d2Z"d,ededefd3d4Z#d,ededefd5d6Z$d,ed7edefd8d9Z%d,ed7edefd:d;Z&d,ededefd<d=Z'd>e(eef defd?d@Z)	dGd>e*dee defdAdBZ+	dGdCe,e- dee de.e- fdDdEZ/dS )H	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                 C   sH   | 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   rG   r&   matchr   r   r   __init__   s   
zSpecifier.__init__c                 C   sR   | j d ur| j S | j\}}|dv r'|dkr |dr |d d }t|jr'dS dS )N)r@   rB   rA   r?   rE   r@   .*TF)rO   rN   endswithr   is_prerelease)r   rI   r   r   r   r   r&      s   


zSpecifier.prereleasesr'   c                 C   
   || _ d S r   rO   r(   r   r   r   r&        
c                 C   
   | j d S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   rN   r   r   r   r   rI        
zSpecifier.operatorc                 C   rY   )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r   rZ   r   r   r   r   r   %  r[   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=rF   rC   ()>)rO   r&   	__class__r   r/   r   prer   r   r   __repr__.  s
   
zSpecifier.__repr__c                 C   s   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{}{})formatrN   r   r   r   r   r    @  s   zSpecifier.__str__c                 C   s*   t | jd | jd dkd}| jd |fS )Nr   r   r?   strip_trailing_zero)r   rN   )r   canonical_versionr   r   r   _canonical_specJ  s
   zSpecifier._canonical_specc                 C   
   t | jS r   )hashrg   r   r   r   r   r"   R     
zSpecifier.__hash__r#   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
        )r   r/   r_   r   NotImplementedrg   r$   r   r   r   r%   U  s   
zSpecifier.__eq__opc                 C   s   t | d| j|  }|S )N	_compare_)getattr
_operators)r   rl   operator_callabler   r   r   _get_operatorr  s   zSpecifier._get_operatorprospectivec                 C   sJ   d tttt|d d }|d7 }| d||o$| d||S )N.rR   rB   r@   )joinlist	itertools	takewhile_is_not_suffix_version_splitrq   )r   rr   rG   prefixr   r   r   _compare_compatiblex  s   
zSpecifier._compare_compatiblec                 C   s   | dr1t|jdd}t|d d dd}t|}t|}t||\}}|d t| }	|	|kS t|}
|
js=t|j}||
kS )NrR   Frd   rS   )rT   r   publicrz   _pad_versionlenr   local)r   rr   rG   normalized_prospectivenormalized_spec
split_specsplit_prospectivepadded_prospective_shortened_prospectivespec_versionr   r   r   _compare_equal  s   

zSpecifier._compare_equalc                 C   s   |  || S r   )r   r   rr   rG   r   r   r   _compare_not_equal  s   zSpecifier._compare_not_equalc                 C   s   t |jt |kS r   r   r}   r   r   r   r   _compare_less_than_equal     z"Specifier._compare_less_than_equalc                 C   s   t |jt |kS r   r   r   r   r   r   _compare_greater_than_equal  r   z%Specifier._compare_greater_than_equalspec_strc                 C   s<   t |}||k s
dS |js|jrt |jt |jkrdS dS NFT)r   rU   base_versionr   rr   r   rG   r   r   r   _compare_less_than  s   zSpecifier._compare_less_thanc                 C   s^   t |}||ks
dS |js|jrt |jt |jkrdS |jd ur-t |jt |jkr-dS dS r   )r   is_postreleaser   r   r   r   r   r   _compare_greater_than  s   
zSpecifier._compare_greater_thanc                 C   s   t | t | kS r   )r/   lowerr   r   r   r   _compare_arbitrary  s   zSpecifier._compare_arbitraryr)   c                 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
        r*   r   r)   r   r   r   __contains__     
zSpecifier.__contains__c                 C   s<   |du r| 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   rU   rq   rI   r   )r   r)   r&   normalized_itemrp   r   r   r   r*     s   
zSpecifier.containsr+   c                 c   s    d}g }d|dur|ndi}|D ]"}t |}| j|fi |r3|jr.|s.| js.|| qd}|V  q|s@|rB|D ]	}|V  q: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   r*   rU   r&   append)r   r+   r&   yieldedfound_prereleaseskwr   parsed_versionr   r   r   r,   E  s*   zSpecifier.filterrF   Nr   )0r   r   r   r   _operator_regex_str_version_regex_strrecompileVERBOSE
IGNORECASErJ   ro   r/   r   r2   rQ   r3   r&   r4   rI   r   rb   r    r   rg   r0   r"   r1   r%   CallableOperatorrq   r   r|   r   r   r   r   r   r   r   r
   r   UnparsedVersionr*   r   r   r   r,   r   r   r   r   r6   k   st    	^

)
/r6   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$c                 C   s@   g }|  dD ]}t|}|r||  q|| q|S )Nrs   )split_prefix_regexrK   extendgroupsr   )r   resultr)   rP   r   r   r   rz     s   
rz   segmentc                    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>)devabrcpost)anyr   r   r   r   ry     s   
ry   leftrightc              
   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   0)r   rv   rw   rx   r   insertmaxchain)r   r   
left_splitright_splitr   r   r   r~     s   
,,r~   c                	   @   s2  e Zd ZdZ	d%dedee ddfddZedee fd	d
Z	e	j
deddfdd
Z	defddZdefddZdefddZded ef dd fddZdedefddZdefddZdee fddZdedefddZ		d&dedee dee defd d!Z	d'd"ee dee dee fd#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.
    rF   N
specifiersr&   r   c                 C   sF   dd | dD }t }|D ]	}|t| q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                 S   s   g | ]
}|  r|  qS r   )rM   r   sr   r   r   
<listcomp>  s    z)SpecifierSet.__init__.<locals>.<listcomp>,N)r   setaddr6   	frozenset_specsrO   )r   r   r&   split_specifiersparsed	specifierr   r   r   rQ     s   

zSpecifierSet.__init__c                 C   s.   | j d ur| j S | jsd S tdd | jD S )Nc                 s   s    | ]}|j V  qd S r   r&   r   r   r   r   r     s    z+SpecifierSet.prereleases.<locals>.<genexpr>)rO   r   r   r   r   r   r   r&     s
   
zSpecifierSet.prereleasesr'   c                 C   rV   r   rW   r(   r   r   r   r&     rX   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)>
        Nr\   rF   z<SpecifierSet(r^   )rO   r&   r/   r`   r   r   r   rb     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     s    z'SpecifierSet.__str__.<locals>.<genexpr>)ru   sortedr   r   r   r   r   r      s   zSpecifierSet.__str__c                 C   rh   r   )ri   r   r   r   r   r   r"   
  rj   zSpecifierSet.__hash__r#   c                 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r=|jdu r=| j|_|S | j|jkrI| 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   rk   r   r   rO   
ValueError)r   r#   r   r   r   r   __and__  s$   



	zSpecifierSet.__and__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
        )r   r/   r6   r   rk   r   r$   r   r   r   r%   -  s
   
zSpecifierSet.__eq__c                 C   rh   )z7Returns the number of specifiers in this specifier set.)r   r   r   r   r   r   __len__G  rX   zSpecifierSet.__len__c                 C   rh   )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   r   r   r   __iter__K  s   
zSpecifierSet.__iter__r)   c                 C   r   )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   r   r   r   r   U  r   zSpecifierSet.__contains__	installedc                    s\   t  ts	t  du r| js jrdS |r! jr!t j t fd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   s    | ]
}|j  d V  qdS )r   Nr   r   r)   r&   r   r   r     s    z(SpecifierSet.contains.<locals>.<genexpr>)r   r   r&   rU   r   allr   )r   r)   r&   r   r   r   r   r*   j  s   



zSpecifierSet.containsr+   c                 C   s   |du r| j }| jr| jD ]}|j|t|d}qt|S g }g }|D ]}t|}|jr6|s6|s5|| q#|| q#|sH|rH|du rHt|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   r,   r2   r   r   rU   r   )r   r+   r&   rG   filteredr   r)   r   r   r   r   r,     s$   ,


zSpecifierSet.filterr   )NNr   )r   r   r   r   r/   r   r2   rQ   r3   r&   r4   rb   r    r0   r"   r
   r   r1   r%   r   r   r6   r   r   r   r*   r   r   r,   r   r   r   r   r     sR    
# 

:r   )#r   r-   rw   r   typingr   r   r   r   r   r   r   r	   r
   utilsr   r   r   r/   r   r   r2   r   r   r   r   ABCMetar   r6   r   r   rz   ry   r~   r   r   r   r   r   <module>   s.   ,7    
.