o
    g¹«j>Î  ã                   @  s´  U 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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ruddlZdd	lmZmZmZ ejd
krcddlm Z  nddl!m Z  ddl"m#Z# ddlm$Z$ g d¢Z%d<dd„Z&d=dd„Z'd>dd„Z(e
dƒZ)eee*f Z+e
de+d�Z,ej-ej.ej/ej0dœZ1d e2d!< d?d'd(„Z3G d)d*„ d*e4ƒZ5G d+d,„ d,ej6d-�Z7G d.d#„ d#e7ƒZ8d@d5d6„Z9G d7d8„ d8e7ƒZ:dAd:d;„Z;dS )BzŠ
.. testsetup::

    from packaging.specifiers import Specifier, SpecifierSet, InvalidSpecifier
    from packaging.version import Version
é    )ÚannotationsN)ÚTYPE_CHECKINGÚAnyÚCallableÚFinalÚTypeVarÚUnioné   )	Ú
FULL_RANGEÚbounds_for_specÚcoerce_versionÚfilter_by_rangesÚintersect_specifier_boundsÚmatches_bounds_onlyÚranges_are_prerelease_onlyÚresolve_prereleasesÚtrim_release)Úcanonicalize_version)ÚVersion)ÚIterableÚIteratorÚSequence)é   é
   )Ú	TypeGuard)Úranges)ÚInterval)ÚBaseSpecifierÚInvalidSpecifierÚ	SpecifierÚSpecifierSetÚreturnú	list[str]c                   C  s   t S ©N)Ú__all__© r%   r%   úT/var/www/html/laksyashrimp/venv/lib/python3.10/site-packages/packaging/specifiers.pyÚ__dir__<   s   r'   ÚspecÚobjectúTypeGuard[tuple[str, str]]c                C  s2   t | tƒot| ƒdkot | d tƒot | d tƒS )Né   r   r	   )Ú
isinstanceÚtupleÚlenÚstr)r(   r%   r%   r&   Ú_validate_spec@   s   

ÿþür0   ÚpreúTypeGuard[bool | None]c                C  s   | d u pt | tƒS r#   )r,   Úbool)r1   r%   r%   r&   Ú_validate_preI   s   r4   ÚTÚUnparsedVersionVar)Úbound)ú>=ú<=ú==ú!=z-dict[str, Callable[[Version, Version], bool]]Ú_DIRECT_COMPARE_OPSÚ	specifierr   Úparsedr   úbool | Nonec                 C  s–   | j \}}| d¡s|jdurdS t |¡}|dur"|||  |¡ƒS |dv rI|  |¡}|j|jks;t|jƒt|jƒkrG|dkrC||k S ||kS dS dS )a!  Match ``parsed`` against ``specifier`` without building a range.

    Handles ``>=``, ``<=``, ``==``, ``!=``, ``<``, ``>`` when the spec is
    not a wildcard and ``parsed`` has no local. Returns ``None`` when the
    range path must be used. Pre-release policy is left to the caller.
    ú.*N)ú<ú>rA   )	Ú_specÚendswithÚlocalr<   ÚgetÚ_require_spec_versionÚepochr   Úrelease)r=   r>   Úop_strÚver_strÚdirect_compareÚspec_vr%   r%   r&   Ú_fast_match]   s   


ÿrN   c                   @  s   e Zd ZdZdS )r   a  
    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   z   s    r   c                   @  sÎ   e Zd ZdZdZdZed,dd„ƒZej	d,dd	„ƒZ
ej	d-dd„ƒZej	d.dd„ƒZeej	d/dd„ƒƒZejd0dd„ƒZej	d1d2dd„ƒZej		d3d4d"d#„ƒZej		d3d5d'd#„ƒZej			d6d7d+d#„ƒZdS )8r   zO
    Abstract base class for :class:`Specifier` and :class:`SpecifierSet`.
    r%   )Ú_strr!   r/   c                 C  s   t | ƒS )z Internal property for match_args©r/   ©Úselfr%   r%   r&   rS   Ž   s   zBaseSpecifier._strc                 C  ó   dS )zŽ
        Returns the str representation of this Specifier-like object. This
        should be representative of the Specifier itself.
        Nr%   rU   r%   r%   r&   Ú__str__“   ó    zBaseSpecifier.__str__Úintc                 C  rW   )zF
        Returns a hash value for this Specifier-like object.
        Nr%   rU   r%   r%   r&   Ú__hash__š   rY   zBaseSpecifier.__hash__Úotherr)   r3   c                 C  rW   )z«
        Returns a boolean representing whether or not the two Specifier-like
        objects are equal.

        :param other: The other object to check against.
        Nr%   ©rV   r\   r%   r%   r&   Ú__eq__    rY   zBaseSpecifier.__eq__r?   c                 C  rW   )zîWhether or not pre-releases as a whole are allowed.

        This can be set to either ``True`` or ``False`` to explicitly enable or disable
        prereleases or it can be set to ``None`` (the default) to use default semantics.
        Nr%   rU   r%   r%   r&   Úprereleases©   rY   zBaseSpecifier.prereleasesÚvalueÚNonec                 C  rW   )zQSetter for :attr:`prereleases`.

        :param value: The value to set.
        Nr%   ©rV   r`   r%   r%   r&   r_   ²   rY   NÚitemr_   c                 C  rW   )zR
        Determines if the given item is contained within this specifier.
        Nr%   )rV   rc   r_   r%   r%   r&   Úcontains¹   rY   zBaseSpecifier.contains.ÚiterableúIterable[UnparsedVersionVar]ÚkeyúIterator[UnparsedVersionVar]c                 C  ó   d S r#   r%   ©rV   re   r_   rg   r%   r%   r&   Úfilter¿   ó   zBaseSpecifier.filterúIterable[T]úCallable[[T], UnparsedVersion]úIterator[T]c                 C  ri   r#   r%   rj   r%   r%   r&   rk   Ç   rl   úIterable[Any]ú'Callable[[Any], UnparsedVersion] | NoneúIterator[Any]c                 C  rW   )z•
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr%   rj   r%   r%   r&   rk   Ï   rY   ©r!   r/   ©r!   rZ   ©r\   r)   r!   r3   ©r!   r?   )r`   r3   r!   ra   r#   )rc   r/   r_   r?   r!   r3   ©N.©re   rf   r_   r?   rg   ra   r!   rh   ©re   rm   r_   r?   rg   rn   r!   ro   ©NN©re   rp   r_   r?   rg   rq   r!   rr   )rO   rP   rQ   rR   Ú	__slots__Ú__match_args__ÚpropertyrS   ÚabcÚabstractmethodrX   r[   r^   r_   Úsetterrd   ÚtypingÚoverloadrk   r%   r%   r%   r&   r   †   s>    üüür   )Ú	metaclassc                	   @  sT  e Zd ZU dZdZdZe de d ejej	B ¡Z
ddddd	d
dddœZded< dWdXdd„ZdYdd„ZdZdd „Zd[d"d#„Zed\d$d%„ƒZejd]d'd%„ƒZd^d)d*„Zd_d-d.„Zed`d/d0„ƒZed`d1d2„ƒZd`d3d4„Zd`d5d6„Zedad8d9„ƒZdbd;d<„Zdcd?d@„ZdddCdD„ZdedfdFdG„Zej 		HdgdhdMdN„ƒZ!ej 		HdgdidRdN„ƒZ!		djdkdVdN„Z!dS )lr   aí  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).

    Instances are safe to serialize with :mod:`pickle`. They use a stable
    format so the same pickle can be loaded in future packaging releases.

    .. versionchanged:: 26.2

        Added a stable pickle format. Pickles created with packaging 26.2+ can
        be unpickled with future releases.  Backward compatibility with pickles
        from packaging < 26.2 is supported but may be removed in a future
        release.
    )Ú_prereleasesÚ_rangesrC   Ú_spec_versiona  
        (?:
            (?:
                # 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 .*
                    |
                    (?a:                                  # pre release
                        [-_\.]?
                        (alpha|beta|preview|pre|a|b|c|rc)
                        [-_\.]?
                        [0-9]*
                    )?
                    (?a:                                  # post release
                        (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                    )?
                    (?a:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?a:\+[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.
                (?:<=|>=|<|>)

                \s*
                v?
                (?:[0-9]+!)?          # epoch
                [0-9]+(?:\.[0-9]+)*   # release
                (?a:                   # pre release
                    [-_\.]?
                    (alpha|beta|preview|pre|a|b|c|rc)
                    [-_\.]?
                    [0-9]*
                )?
                (?a:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?a:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        z\s*Ú
compatibleÚequalÚ	not_equalÚless_than_equalÚgreater_than_equalÚ	less_thanÚgreater_thanÚ	arbitrary)ú~=r:   r;   r9   r8   rA   rB   ú===r   Ú
_operatorsÚ Nr(   r/   r_   r?   r!   ra   c                 C  s´   | j  |¡std|›�ƒ‚| ¡ }| d¡r&|dd… |dd…  ¡ }}n$| d¡r;|dd… |dd…  ¡ }}n|dd… |dd…  ¡ }}||f| _|| _d| _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: r‘   Nr   )r�   r:   r;   r9   r8   r+   r	   )	Ú_regexÚ	fullmatchr   ÚstripÚ
startswithrC   r…   r‡   r†   )rV   r(   r_   ÚoperatorÚversionr%   r%   r&   Ú__init__c  s   
 
 

zSpecifier.__init__r™   úVersion | Nonec                 C  sD   | j dur| j d |kr| j d S t|ƒ}|du rdS ||f| _ |S )zDOne element cache, as only one spec Version is needed per Specifier.Nr   r	   )r‡   r   )rV   r™   Úversion_specifierr%   r%   r&   Ú_get_spec_version†  s   

zSpecifier._get_spec_versionr   c                 C  s   |   |¡}|dusJ ‚|S )zÕGet spec version, asserting it's valid (not for === operator).

        This method should only be called for operators where version
        strings are guaranteed to be valid PEP 440 versions (not ===).
        N)r�   )rV   r™   Úspec_versionr%   r%   r&   rG   ’  s   
zSpecifier._require_spec_versionúSequence[Interval]c                 C  sP   | j dur| j S | j}| j}|dkrt}n|  | d¡¡}t|||ƒ}|| _ |S )zØConvert this specifier to sorted, non-overlapping version ranges.

        Each standard operator maps to one or two ranges.  ``===`` is
        modeled as full range (actual check done separately).  Cached.
        Nr‘   r@   )r†   r˜   r™   r
   rG   Úremovesuffixr   )rV   ÚoprK   Úresultr™   r%   r%   r&   Ú
_to_rangesœ  s   
zSpecifier._to_rangesc                 C  sX   | j d ur| j S | j\}}|dkrdS |dkr| d¡rdS |  |¡}|d u r)d S |jS )Nr;   Fr:   r@   )r…   rC   rD   r�   Úis_prerelease)rV   r˜   Úversion_strr™   r%   r%   r&   r_   ±  s   


zSpecifier.prereleasesr`   c                 C  s
   || _ d S r#   )r…   rb   r%   r%   r&   r_   Í  ó   
ú#tuple[tuple[str, str], bool | None]c                 C  ó   | j | jfS r#   )rC   r…   rU   r%   r%   r&   Ú__getstate__Ñ  ó   zSpecifier.__getstate__Ústater)   c                 C  sð   d | _ d | _t|tƒrQt|ƒdkr%|\}}t|ƒr%t|ƒr%|| _|| _d S t|ƒdkrQt|d t	ƒrQ|\}}| 
d¡}| 
dd¡}t|ƒrQt|ƒrQ|| _|| _d S t|t	ƒrq| 
d¡}| 
dd¡}t|ƒrqt|ƒrq|| _|| _d S td|›�ƒ‚)Nr+   r	   rC   r…   ÚinvalidzCannot restore Specifier from )r‡   r†   r,   r-   r.   r0   r4   rC   r…   ÚdictrF   Ú	TypeError)rV   r«   r(   r_   Ú_Ú	slot_dictr%   r%   r&   Ú__setstate__×  s2   



zSpecifier.__setstate__c                 C  ó
   | j d S )z`The operator of this specifier.

        >>> Specifier("==1.2.3").operator
        '=='
        r   ©rC   rU   r%   r%   r&   r˜   ø  ó   
zSpecifier.operatorc                 C  r²   )zaThe version of this specifier.

        >>> Specifier("==1.2.3").version
        '1.2.3'
        r	   r³   rU   r%   r%   r&   r™     r´   zSpecifier.versionc                 C  ó8   | 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=r“   rA   ú(ú)>©r…   r_   Ú	__class__rO   r/   ©rV   r1   r%   r%   r&   Ú__repr__
  s
   
ÿýzSpecifier.__repr__c                 C  s   dj | jŽ S )zÐA string representation of the Specifier that can be round-tripped.

        >>> str(Specifier('>=1.0.0'))
        '>=1.0.0'
        >>> str(Specifier('>=1.0.0', prereleases=False))
        '>=1.0.0'
        z{}{})ÚformatrC   rU   r%   r%   r&   rX     s   zSpecifier.__str__útuple[str, str]c                 C  sF   | j \}}|dks| d¡r||fS |  |¡}t||dkd�}||fS )Nr‘   r@   r�   )Ústrip_trailing_zero)rC   rD   rG   r   )rV   r˜   r™   rž   Úcanonical_versionr%   r%   r&   Ú_canonical_spec&  s   

ÿzSpecifier._canonical_specrZ   c                 C  ó
   t | jƒS r#   )ÚhashrÁ   rU   r%   r%   r&   r[   4  s   
zSpecifier.__hash__r\   r3   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   ÚNotImplementedrÁ   r]   r%   r%   r&   r^   7  s   
ÿzSpecifier.__eq__rc   ústr | Versionc                 C  ó
   |   |¡S )a:  Return whether or not the item is contained in this specifier.

        :param item: The item to check for.

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

        >>> "1.2.3" in Specifier(">=1.2.3")
        True
        >>> Version("1.2.3") in Specifier(">=1.2.3")
        True
        >>> "1.0.0" in Specifier(">=1.2.3")
        False
        >>> "1.3.0a1" in Specifier(">=1.2.3")
        True
        >>> "1.3.0a1" in Specifier(">=1.2.3", prereleases=True)
        True
        ©rd   ©rV   rc   r%   r%   r&   Ú__contains__T  ó   
zSpecifier.__contains__ÚUnparsedVersionc                 C  s†   | j d dkrtt| j|g|d�ƒƒS t|ƒ}|du rdS |du r(t| j| jƒ}|du r1|jr1dS t	| |ƒ}|dur<|S t
|  ¡ |ƒS )a'  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:`~packaging.version.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

        .. versionchanged:: 26.0

            With ``prereleases=None``, a prerelease now matches. A single
            version has no alternatives, so the :pep:`440` rule to accept
            prereleases when nothing else satisfies the specifier applies.
            Earlier versions rejected it. An unparsable version now returns
            ``False`` instead of raising :exc:`~packaging.version.InvalidVersion`.
        r   r‘   ©r_   NF)rC   r3   Úlistrk   r   r   r…   r_   r¤   rN   r   r£   )rV   rc   r_   r>   Úmatchr%   r%   r&   rd   i  s   "
zSpecifier.contains.re   rf   rg   rh   c                 C  ri   r#   r%   rj   r%   r%   r&   rk   ¡  rl   zSpecifier.filterrm   rn   ro   c                 C  ri   r#   r%   rj   r%   r%   r&   rk   ©  rl   rp   rq   rr   c                   s\   |du rt | j| jƒ}| jdkr%| j ¡ ‰‡ ‡fdd„|D ƒ}t|ˆ |ƒS t|  ¡ |ˆ |ƒS )aþ  Filter items in the given iterable, that match the specifier.

        :param iterable:
            An iterable that can contain version strings and
            :class:`~packaging.version.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.
        :param key:
            A callable that takes a single argument (an item from the iterable) and
            returns a version string or :class:`~packaging.version.Version`
            instance to be used for filtering.

        >>> 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']
        >>> list(Specifier(">=1.2.3").filter(
        ... [{"ver": "1.2"}, {"ver": "1.3"}],
        ... key=lambda x: x["ver"]))
        [{'ver': '1.3'}]

        .. versionchanged:: 26.1

            Added the ``key`` parameter.
        Nr‘   c                 3  s4   � | ]}t ˆ d u r|nˆ |ƒƒ ¡ ˆkr|V  qd S r#   )r/   Úlower©Ú.0rc   ©rg   Ú
spec_lowerr%   r&   Ú	<genexpr>Þ  s   €  þýz#Specifier.filter.<locals>.<genexpr>)	r   r…   r_   r˜   r™   rÏ   Ú_apply_prereleases_filterr   r£   )rV   re   r_   rg   Úmatchesr%   rÒ   r&   rk   ±  s   (

þ©r“   N)r(   r/   r_   r?   r!   ra   )r™   r/   r!   r›   )r™   r/   r!   r   ©r!   rŸ   rv   ©r`   r?   r!   ra   )r!   r§   ©r«   r)   r!   ra   rs   )r!   r¾   rt   ru   )rc   rÅ   r!   r3   r#   )rc   rË   r_   r?   r!   r3   rw   rx   ry   rz   r{   )"rO   rP   rQ   rR   r|   Ú_specifier_regex_strÚreÚcompileÚVERBOSEÚ
IGNORECASEr”   r’   Ú__annotations__rš   r�   rG   r£   r~   r_   r�   r©   r±   r˜   r™   r¼   rX   rÁ   r[   r^   rÉ   rd   r‚   rƒ   rk   r%   r%   r%   r&   r   Ü   sb   
 \ÿø
#




!





8üü
ürÖ   rp   rg   rq   r_   rr   c                   s2   |du r	t | ˆ ƒS |rt| ƒS ‡ ‡fdd„| D ƒS )zÓApply ``prereleases=`` handling to an already-matched iterable.

    ``None`` means PEP 440 default (buffer pre-releases until a final
    appears); ``True`` yields everything; ``False`` drops pre-releases.
    Nc                 3  s:   � | ]}t ˆ d u r|nˆ |ƒƒ ‰d u sˆjs|V  qd S r#   )r   r¤   rÐ   ©rg   r>   r%   r&   rÔ   ö  s   €  ÿþýz,_apply_prereleases_filter.<locals>.<genexpr>)Ú_pep440_filter_prereleasesÚiter)rÖ   rg   r_   r%   rá   r&   rÕ   è  s   

þrÕ   c                   @  sL  e Zd ZdZdZ		dWdXdd„ZdYdd„ZedZdd„ƒZej	d[dd„ƒZd\dd„Z
d]dd„Zd^dd„Zd^dd„Zd_d!d"„Zd`d%d&„Zdad(d)„Zd_d*d+„Zdbd-d.„Zdcd0d1„Zddd2d3„Zddd4d5„Zded7d8„Zdfd9d:„Zdgd;d<„Zdgd=d>„Zdgd?d@„ZdhdCdD„Z		didjdFdG„Zej		HdkdldMdN„ƒZej		HdkdmdRdN„ƒZ		didndVdN„ZdS )or    a…  This class abstracts handling of a set of version specifiers.

    It can be passed a single specifier (``>=3.0``), a comma-separated list of
    specifiers (``>=3.0,!=3.1``), or no specifier at all.

    Instances are safe to serialize with :mod:`pickle`. They use a stable
    format so the same pickle can be loaded in future packaging
    releases.

    .. versionchanged:: 26.2

        Added a stable pickle format. Pickles created with
        packaging 26.2+ can be unpickled with future releases.
        Backward compatibility with pickles from
        packaging < 26.2 is supported but may be removed in a future
        release.
    )Ú_canonicalizedÚ_has_arbitraryÚ_is_unsatisfiabler…   r†   Ú_specsr“   NÚ
specifiersústr | Iterable[Specifier]r_   r?   r!   ra   c                 C  s€   t |tƒrdd„ | d¡D ƒ}ttt|ƒƒ| _d|v | _nt|ƒ| _tdd„ | jD ƒƒ| _t	| jƒdk| _
d| _d| _|| _dS )	a´  Initialize a SpecifierSet instance.

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

        :raises InvalidSpecifier:
            If the given ``specifiers`` are not parseable than this exception will be
            raised.
        c                 S  s   g | ]
}|  ¡ r|  ¡ ‘qS r%   )r–   ©rÑ   Úsr%   r%   r&   Ú
<listcomp>3  s    z)SpecifierSet.__init__.<locals>.<listcomp>ú,r‘   c                 s  ó   � | ]	}d t |ƒv V  qdS ©r‘   NrT   rê   r%   r%   r&   rÔ   <  ó   € z(SpecifierSet.__init__.<locals>.<genexpr>r	   N)r,   r/   Úsplitr-   Úmapr   rç   rå   Úanyr.   rä   ræ   r†   r…   )rV   rè   r_   Úsplit_specifiersr%   r%   r&   rš     s   


zSpecifierSet.__init__útuple[Specifier, ...]c                 C  s,   | j stt t| jtd�¡ƒ| _d| _ | jS )zBDeduplicate, sort, and cache specs for order-sensitive operations.©rg   T)rä   r-   r­   ÚfromkeysÚsortedrç   r/   rU   r%   r%   r&   Ú_canonical_specsF  s   zSpecifierSet._canonical_specsc                 C  s6   | j d ur| j S | jsd S tdd„ | jD ƒƒrdS d S )Nc                 s  s   � | ]}|j V  qd S r#   rÌ   rê   r%   r%   r&   rÔ   \  s   € z+SpecifierSet.prereleases.<locals>.<genexpr>T)r…   rç   ró   rU   r%   r%   r&   r_   M  s   
zSpecifierSet.prereleasesr`   c                 C  s   || _ d | _d S r#   )r…   ræ   rb   r%   r%   r&   r_   a  s   
ú)tuple[tuple[Specifier, ...], bool | None]c                 C  r¨   r#   )rç   r…   rU   r%   r%   r&   r©   f  rª   zSpecifierSet.__getstate__r«   r)   c                 C  sÎ  d | _ d | _t|tƒr–t|ƒdkr@|\}}t|tƒr@tdd„ |D ƒƒr@t|ƒr@|| _|| _t|ƒdk| _	t
dd„ |D ƒƒ| _d S t|ƒdkr–t|d tƒr–|\}}| dd¡}| d¡}t|tƒritt|td	�ƒ}t|tƒr–td
d„ |D ƒƒr–t|ƒr–|| _|| _t| jƒdk| _	t
dd„ | jD ƒƒ| _d S t|tƒrà| dd¡}| d¡}t|tƒr³tt|td	�ƒ}t|tƒràtdd„ |D ƒƒràt|ƒrà|| _|| _t| jƒdk| _	t
dd„ | jD ƒƒ| _d S td|›�ƒ‚)Nr+   c                 s  ó   � | ]}t |tƒV  qd S r#   ©r,   r   rê   r%   r%   r&   rÔ   w  ó   € z,SpecifierSet.__setstate__.<locals>.<genexpr>r	   c                 s  rî   rï   rT   rê   r%   r%   r&   rÔ   }  rð   rç   r%   r…   rö   c                 s  rû   r#   rü   rê   r%   r%   r&   rÔ   ‰  rý   c                 s  rî   rï   rT   rê   r%   r%   r&   rÔ   �  rð   c                 s  rû   r#   rü   rê   r%   r%   r&   rÔ   š  rý   c                 s  rî   rï   rT   rê   r%   r%   r&   rÔ      rð   z!Cannot restore SpecifierSet from )r†   ræ   r,   r-   r.   Úallr4   rç   r…   rä   ró   rå   r­   rF   Ú	frozensetrø   r/   r®   )rV   r«   Úspecsr_   r¯   r°   r%   r%   r&   r±   l  sd   
ÿþý

ÿþý


ÿþýzSpecifierSet.__setstate__r/   c                 C  rµ   )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¶   r“   rA   r·   r¸   r¹   r»   r%   r%   r&   r¼   ¥  s
   
ÿýzSpecifierSet.__repr__c                 C  s   d  dd„ |  ¡ 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#   rT   rê   r%   r%   r&   rÔ   Å  ó   € z'SpecifierSet.__str__.<locals>.<genexpr>)Újoinrù   rU   r%   r%   r&   rX   º  s   zSpecifierSet.__str__rZ   c                 C  s   t |  ¡ ƒS r#   )rÃ   rù   rU   r%   r%   r&   r[   Ç  s   zSpecifierSet.__hash__r\   úSpecifierSet | strc                 C  s”   t |tƒr
t|ƒ}nt |tƒstS tƒ }| j|j |_t|jƒdk|_| jp(|j|_| jdu s5| j|jkr;|j|_|S |jdu rF| 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')>
        r	   NzFCannot combine SpecifierSets with True and False prerelease overrides.)
r,   r/   r    rÄ   rç   r.   rä   rå   r…   Ú
ValueError)rV   r\   r=   r%   r%   r&   Ú__and__Ê  s"   




ùüÿzSpecifierSet.__and__r3   c                 C  s:   t |ttfƒrtt|ƒƒ}nt |tƒstS |  ¡ | ¡ 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]   r%   r%   r&   r^   ê  s
   
zSpecifierSet.__eq__c                 C  rÂ   )z7Returns the number of specifiers in this specifier set.)r.   rç   rU   r%   r%   r&   Ú__len__  r¦   zSpecifierSet.__len__úIterator[Specifier]c                 C  rÂ   )zð
        Returns an iterator over all the underlying :class:`Specifier` instances
        in this specifier set.

        >>> sorted(SpecifierSet(">=1.0.0,!=1.0.1"), key=str)
        [<Specifier('!=1.0.1')>, <Specifier('>=1.0.0')>]
        )rã   rç   rU   r%   r%   r&   Ú__iter__  s   
zSpecifierSet.__iter__rŸ   c                 C  s,   | j dur| j S tdd„ | jD ƒƒ| _ | j S )z¨Intersect all specifiers into a single sequence of version ranges.

        Empty when unsatisfiable. Callers must ensure ``self._specs``
        is non-empty.
        Nc                 s  s   � | ]}|  ¡ V  qd S r#   )r£   rê   r%   r%   r&   rÔ     r  z+SpecifierSet._get_ranges.<locals>.<genexpr>)r†   r   rç   rU   r%   r%   r&   Ú_get_ranges  s   
zSpecifierSet._get_rangesc                 C  s\   | j }|dur	|S | jsd| _ dS |  ¡  }|s|  ¡ }|s)| jdu r)t|  ¡ ƒ}|| _ |S )aÆ  Check whether this specifier set can never be satisfied.

        Returns True if no version can satisfy all specifiers simultaneously.

        >>> SpecifierSet(">=2.0,<1.0").is_unsatisfiable()
        True
        >>> SpecifierSet(">=1.0,<2.0").is_unsatisfiable()
        False
        >>> SpecifierSet("").is_unsatisfiable()
        False
        >>> SpecifierSet("==1.0,!=1.0").is_unsatisfiable()
        True

        .. versionadded:: 26.1
        NF)ræ   rç   r	  Ú_check_arbitrary_unsatisfiabler_   r   )rV   Úcachedr¢   r%   r%   r&   Úis_unsatisfiable  s   
zSpecifierSet.is_unsatisfiablec                   s®   dd„ | j D ƒ}|sdS |d j ¡ ‰t‡fdd„|dd… D ƒƒr$d	S t|d jƒ‰ | jdu r9ˆ dur9ˆ jr9d	S d
d„ | j D ƒ}|sEdS ˆ du rKd	S t‡ fdd„|D ƒƒ S )a  Check === (arbitrary equality) specs for unsatisfiability.

        === uses case-insensitive string comparison, so the only candidate
        that can match ``===V`` is the literal string V.  This method
        checks whether that candidate is excluded by other specifiers.
        c                 S  s   g | ]	}|j d kr|‘qS ©r‘   ©r˜   rê   r%   r%   r&   rì   H  ó    z?SpecifierSet._check_arbitrary_unsatisfiable.<locals>.<listcomp>Fr   c                 3  s   � | ]
}|j  ¡ ˆ kV  qd S r#   )r™   rÏ   rê   )Úfirstr%   r&   rÔ   N  s   € z>SpecifierSet._check_arbitrary_unsatisfiable.<locals>.<genexpr>r	   NTc                 S  s   g | ]	}|j d kr|‘qS r  r  rê   r%   r%   r&   rì   ^  r  c                 3  s   � | ]}|  ˆ ¡V  qd S r#   rÇ   rê   )Ú	candidater%   r&   rÔ   f  rý   )rç   r™   rÏ   ró   r   r_   r¤   rþ   )rV   r�   Ústandardr%   )r  r  r&   r
  A  s$   
ÿz+SpecifierSet._check_arbitrary_unsatisfiableúranges.VersionRangec                 C  s   ddl m} | | ¡S )ac  Return the :class:`~packaging.ranges.VersionRange` this set accepts.

        An empty set yields the full range; an unsatisfiable set yields the
        empty range. ``===`` specifiers contribute literal-string admission.

        >>> SpecifierSet(">=1.0,<2.0").to_range()
        <VersionRange '[1.0, 2.0.dev0)'>

        .. versionadded:: 26.3
        r	   )ÚVersionRange)r   r  Ú_from_specifier_set)rV   r  r%   r%   r&   Úto_rangeh  s   
zSpecifierSet.to_rangec                 C  s*   t |tƒs	tdƒ‚| js|jrtdƒ‚d S )Nzexpected a SpecifierSetz+set relations do not support === specifiers)r,   r    r®   rå   r  r]   r%   r%   r&   Ú_check_relation_operandw  s
   
ÿz$SpecifierSet._check_relation_operandc                 C  ó   |   |¡ |  ¡  | ¡ ¡S )a=  Return whether every version matching this set also matches other.

        :raises ValueError:
            If either set uses ``===`` specifiers, or the two sets were
            given different ``prereleases`` arguments (unset on one side
            counts as different).
        :raises TypeError:
            If other is not a :class:`SpecifierSet`.

        >>> SpecifierSet(">=3.12,<3.13").is_subset(SpecifierSet(">=3.12"))
        True
        >>> SpecifierSet(">=3.12").is_subset(SpecifierSet(">=3.12,<3.13"))
        False

        .. versionadded:: 26.3
        )r  r  Ú	is_subsetr]   r%   r%   r&   r  }  ó   
zSpecifierSet.is_subsetc                 C  r  )aæ  Return whether every version matching other also matches this set.

        :raises ValueError:
            If either set uses ``===`` specifiers, or the two sets were
            given different ``prereleases`` arguments (unset on one side
            counts as different).
        :raises TypeError:
            If other is not a :class:`SpecifierSet`.

        >>> SpecifierSet(">=3.12").is_superset(SpecifierSet(">=3.12,<3.13"))
        True

        .. versionadded:: 26.3
        )r  r  Úis_supersetr]   r%   r%   r&   r  ‘  s   
zSpecifierSet.is_supersetc                 C  r  )a.  Return whether this set and other share no matching versions.

        :raises ValueError:
            If either set uses ``===`` specifiers, or the two sets were
            given different ``prereleases`` arguments (unset on one side
            counts as different).
        :raises TypeError:
            If other is not a :class:`SpecifierSet`.

        >>> SpecifierSet("<3.12").is_disjoint(SpecifierSet(">=3.12"))
        True
        >>> SpecifierSet("<3.12").is_disjoint(SpecifierSet(">=3.11"))
        False

        .. versionadded:: 26.3
        )r  r  Úis_disjointr]   r%   r%   r&   r  £  r  zSpecifierSet.is_disjointrc   rË   c                 C  rÆ   )aq  Return whether or not the item is contained in this specifier.

        :param item: The item to check for.

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

        >>> "1.2.3" in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> Version("1.2.3") in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> "1.0.1" in SpecifierSet(">=1.0.0,!=1.0.1")
        False
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1")
        True
        >>> "1.3.0a1" in SpecifierSet(">=1.0.0,!=1.0.1", prereleases=True)
        True
        rÇ   rÈ   r%   r%   r&   rÉ   ·  rÊ   zSpecifierSet.__contains__Ú	installedc           	      C  sð   t |ƒ}|dur|r|jrd}|du s| jrt|tƒs|}n|}|durl| jsl|jdu rl| jrl|jrA|du s?|du rA| jdu rAdS | j}|du rg| jD ]}t	||ƒ}|du rX n|s] dS qKdS |  
¡  }| _t||ƒS tt| j|g|d�ƒƒS )a<  Return whether or not the item is contained in this SpecifierSet.

        :param item:
            The item to check for, which can be a version string or a
            :class:`~packaging.version.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

        .. versionchanged:: 26.0

            With ``prereleases=None``, a prerelease now matches. A single
            version has no alternatives, so the :pep:`440` rule to accept
            prereleases when nothing else satisfies the specifiers applies.
            Earlier versions rejected it. An unparsable version now returns
            ``False`` instead of raising :exc:`~packaging.version.InvalidVersion`.
        NTFrÌ   )r   r¤   rå   r,   r   rE   rç   r…   r†   rN   r	  r   r3   rÍ   rk   )	rV   rc   r_   r  r™   Ú
check_itemÚboundsr(   rÎ   r%   r%   r&   rd   Ì  s:   (ÿ
ÿ

ÿ
zSpecifierSet.contains.re   rf   rg   rh   c                 C  ri   r#   r%   rj   r%   r%   r&   rk   $  rl   zSpecifierSet.filterrm   rn   ro   c                 C  ri   r#   r%   rj   r%   r%   r&   rk   ,  rl   rp   rq   rr   c                   sz   |du r| j dur| j }| jr7| jr%| j‰‡ ‡fdd„|D ƒ}t|ˆ |ƒS | j}|du r0|  ¡ }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:`~packaging.version.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.
        :param key:
            A callable that takes a single argument (an item from the iterable) and
            returns a version string or :class:`~packaging.version.Version`
            instance to be used for filtering.

        >>> 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']
        >>> list(SpecifierSet(">=1.2.3").filter(
        ... [{"ver": "1.2"}, {"ver": "1.3"}],
        ... key=lambda x: x["ver"]))
        [{'ver': '1.3'}]

        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']

        .. versionchanged:: 26.0

            Prerelease filtering now follows the PEP 440 recommendation of
            yielding prereleases only when no final release is present.

        .. versionchanged:: 26.1

            Added the ``key`` parameter.
        Nc                 3  s,   � | ]‰ t ‡ ‡fd d„ˆD ƒƒrˆ V  qdS )c                 3  s.   � | ]}|j ˆd u rˆ nˆˆ ƒdd�V  qd S )NTrÌ   rÇ   rê   )rc   rg   r%   r&   rÔ   z  s
   € ÿ
ÿz0SpecifierSet.filter.<locals>.<genexpr>.<genexpr>N)rþ   )rÑ   ©rg   r   )rc   r&   rÔ   w  s   € þý
ÿz&SpecifierSet.filter.<locals>.<genexpr>)r_   rç   rå   rÕ   r†   r	  r   )rV   re   r_   rg   rÖ   r   r%   r   r&   rk   4  s   <þr×   )rè   ré   r_   r?   r!   ra   )r!   rõ   rv   rÙ   )r!   rú   rÚ   rs   rt   )r\   r  r!   r    ru   )r!   r  rØ   )r!   r3   )r!   r  )r\   r)   r!   ra   )r\   r    r!   r3   )rc   rË   r!   r3   rz   )rc   rË   r_   r?   r  r?   r!   r3   rw   rx   ry   r{   ) rO   rP   rQ   rR   r|   rš   rù   r~   r_   r�   r©   r±   r¼   rX   r[   r  r^   r  r  r	  r  r
  r  r  r  r  r  rÉ   rd   r‚   rƒ   rk   r%   r%   r%   r&   r    þ  sV    ý
,


9



 





#
'




üXüü
ür    re   c                 c  sž   � g }g }d}| D ]:}t |du r|n||ƒƒ}|du r,|r!|V  n
| |¡ | |¡ q	|js<|s8|E dH  d}|V  q	|sC| |¡ q	|sM|E dH  dS dS )z?Filter per PEP 440: exclude prereleases unless no finals exist.FNT)r   Úappendr¤   )re   rg   Úall_nonfinalÚarbitrary_stringsÚfound_finalrc   r>   r%   r%   r&   râ   Š  s0   €



€ÿrâ   )r!   r"   )r(   r)   r!   r*   )r1   r)   r!   r2   )r=   r   r>   r   r!   r?   )rÖ   rp   rg   rq   r_   r?   r!   rr   )re   rp   rg   rq   r!   rr   )<rR   Ú
__future__r   r   rÜ   r‚   r   r   r   r   r   r   r†   r
   r   r   r   r   r   r   r   r   Úutilsr   r™   r   ÚsysÚcollections.abcr   r   r   Úversion_infor   Útyping_extensionsr“   r   r   r$   r'   r0   r4   r5   r/   rË   r6   Ú__ge__Ú__le__r^   Ú__ne__r<   rà   rN   r  r   ÚABCMetar   r   rÕ   r    râ   r%   r%   r%   r&   Ú<module>   sZ    ,	



	ü
V    
     