o
    Ëý°jžu  ã                	   @   s¨  d dl Z d dl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mZmZ ddlmZ ddlmZmZmZ eeef Zeeeef Zeded�Zeeegef ZG dd	„ d	eƒZG d
d„ de jd�Z G dd„ de ƒZ!G dd„ de!ƒZ"dedeegef dedeegef fd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 )$é    N)ÚCallableÚDictÚIterableÚIteratorÚListÚOptionalÚPatternÚSetÚTupleÚTypeVarÚUnioné   )Úcanonicalize_version)ÚLegacyVersionÚVersionÚparseÚVersionTypeVar)Úboundc                   @   s   e Zd ZdZdS )ÚInvalidSpecifierzH
    An invalid specifier was found, users should refer to PEP 440.
    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© r   r   ú“/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/pip/_vendor/packaging/specifiers.pyr   !   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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 )ÚBaseSpecifierÚreturnc                 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__(   ó    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   )zq
        Returns a boolean representing whether or not the two Specifier like
        objects are equal.
        Nr   ©r   r#   r   r   r   Ú__eq__5   r!   zBaseSpecifier.__eq__c                 C   r   )zg
        Returns whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   r   r   r   r   Úprereleases<   r!   zBaseSpecifier.prereleasesÚvalueNc                 C   r   )zd
        Sets whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   ©r   r'   r   r   r   r&   C   r!   Úitemr&   c                 C   r   )zR
        Determines if the given item is contained within this specifier.
        Nr   ©r   r)   r&   r   r   r   ÚcontainsJ   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   ÚfilterP   r!   zBaseSpecifier.filter©N)r   r   r   ÚabcÚabstractmethodÚstrr    Úintr"   ÚobjectÚboolr%   Úabstractpropertyr   r&   Úsetterr+   r   r   r-   r   r   r   r   r   '   s,    ÿÿÿþr   )Ú	metaclassc                   @   sl  e Zd ZU i Zeeef ed< ee ed< d+dedee	 dd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fdd„Zedefdd„ƒZedefdd„ƒZedee	 fdd „ƒZejd!e	ddfd"d „ƒZd#ede	fd$d%„Z	d,d#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 )-Ú_IndividualSpecifierÚ
_operatorsÚ_regexÚ NÚspecr&   r   c                 C   sH   | j  |¡}|std|› d�ƒ‚| d¡ ¡ | d¡ ¡ f| _|| _d S )NzInvalid specifier: 'ú'ÚoperatorÚversion)r:   Úsearchr   ÚgroupÚstripÚ_specÚ_prereleases)r   r<   r&   Úmatchr   r   r   Ú__init___   s   þ
z_IndividualSpecifier.__init__c                 C   s8   | j d urd| j›�nd}d| jj› dt| ƒ›|› d�S )Nú, prereleases=r;   ú<ú(ú)>)rD   r&   Ú	__class__r   r1   ©r   Úprer   r   r   Ú__repr__l   s
   
ÿýz_IndividualSpecifier.__repr__c                 C   s   dj | jŽ S )Nz{}{})ÚformatrC   r   r   r   r   r    u   s   z_IndividualSpecifier.__str__c                 C   s   | j d t| j d ƒfS )Nr   r   )rC   r   r   r   r   r   Ú_canonical_specx   s   z$_IndividualSpecifier._canonical_specc                 C   ó
   t | jƒS r.   )ÚhashrP   r   r   r   r   r"   |   ó   
z_IndividualSpecifier.__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 r.   )Ú
isinstancer1   rK   r   ÚNotImplementedrP   r$   r   r   r   r%      s   
ÿz_IndividualSpecifier.__eq__Úopc                 C   s   t | d| j| › �ƒ}|S )NÚ	_compare_)Úgetattrr9   )r   rV   Úoperator_callabler   r   r   Ú_get_operatorŠ   s   ÿz"_IndividualSpecifier._get_operatorr?   c                 C   s   t |ttfƒst|ƒ}|S r.   )rT   r   r   r   ©r   r?   r   r   r   Ú_coerce_version�   s   z$_IndividualSpecifier._coerce_versionc                 C   ó
   | j d S )Nr   ©rC   r   r   r   r   r>   •   ó   
z_IndividualSpecifier.operatorc                 C   r]   )Nr   r^   r   r   r   r   r?   ™   r_   z_IndividualSpecifier.versionc                 C   s   | j S r.   ©rD   r   r   r   r   r&   �   s   z _IndividualSpecifier.prereleasesr'   c                 C   ó
   || _ d S r.   r`   r(   r   r   r   r&   ¡   r_   r)   c                 C   ó
   |   |¡S r.   ©r+   ©r   r)   r   r   r   Ú__contains__¥   rS   z!_IndividualSpecifier.__contains__c                 C   s>   |d u r| j }|  |¡}|jr|sdS |  | j¡}||| jƒS ©NF)r&   r\   Úis_prereleaserZ   r>   r?   )r   r)   r&   Únormalized_itemrY   r   r   r   r+   ¨   s   

z_IndividualSpecifier.containsr,   c                 c   sŽ   � d}g }d|d ur|ndi}|D ]#}|   |¡}| j|fi |¤Žr4|jr/|s/| js/| |¡ qd}|V  q|sA|rC|D ]	}|V  q;d S d S d S )NFr&   T)r\   r+   rg   r&   Úappend)r   r,   r&   ÚyieldedÚfound_prereleasesÚkwr?   Úparsed_versionr   r   r   r-   ¿   s*   €
ÿÿ€þz_IndividualSpecifier.filter©r;   Nr.   )"r   r   r   r9   r   r1   Ú__annotations__r   r   r4   rF   rN   r    Úpropertyr
   rP   r2   r"   r3   r%   ÚCallableOperatorrZ   ÚUnparsedVersionÚParsedVersionr\   r>   r?   r&   r6   re   r+   r   r   r-   r   r   r   r   r8   Z   sJ   
 	ÿÿÿ
þÿÿÿþr8   c                       sø   e Zd ZdZe de d ejejB ¡Zdddddd	d
œZ	d"de
dee ddf‡ 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d„Zde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d„Zdede
defd d!„Z‡  ZS )#ÚLegacySpecifieraÛ  
        (?P<operator>(==|!=|<=|>=|<|>))
        \s*
        (?P<version>
            [^,;\s)]* # Since this is a "legacy" specifier, and the version
                      # string can be just about anything, we match everything
                      # except for whitespace, a semi-colon for marker support,
                      # a closing paren since versions can be enclosed in
                      # them, and a comma since it's a version separator.
        )
        ú^\s*ú\s*$ÚequalÚ	not_equalÚless_than_equalÚgreater_than_equalÚ	less_thanÚgreater_than)ú==ú!=ú<=ú>=rH   ú>r;   Nr<   r&   r   c                    s   t ƒ  ||¡ t dt¡ d S )NzZCreating a LegacyVersion has been deprecated and will be removed in the next major release)ÚsuperrF   ÚwarningsÚwarnÚDeprecationWarning)r   r<   r&   ©rK   r   r   rF   ü   s
   ýzLegacySpecifier.__init__r?   c                 C   s   t |tƒstt|ƒƒ}|S r.   )rT   r   r1   r[   r   r   r   r\     s   
zLegacySpecifier._coerce_versionÚprospectivec                 C   s   ||   |¡kS r.   ©r\   ©r   r‡   r<   r   r   r   Ú_compare_equal
  ó   zLegacySpecifier._compare_equalc                 C   s   ||   |¡kS r.   rˆ   r‰   r   r   r   Ú_compare_not_equal  r‹   z"LegacySpecifier._compare_not_equalc                 C   s   ||   |¡kS r.   rˆ   r‰   r   r   r   Ú_compare_less_than_equal  r‹   z(LegacySpecifier._compare_less_than_equalc                 C   s   ||   |¡kS r.   rˆ   r‰   r   r   r   Ú_compare_greater_than_equal  s   z+LegacySpecifier._compare_greater_than_equalc                 C   s   ||   |¡k S r.   rˆ   r‰   r   r   r   Ú_compare_less_than  r‹   z"LegacySpecifier._compare_less_thanc                 C   s   ||   |¡kS r.   rˆ   r‰   r   r   r   Ú_compare_greater_than  r‹   z%LegacySpecifier._compare_greater_thanrn   )r   r   r   Ú
_regex_strÚreÚcompileÚVERBOSEÚ
IGNORECASEr:   r9   r1   r   r4   rF   rr   r   r\   rŠ   rŒ   r�   rŽ   r�   r�   Ú__classcell__r   r   r†   r   rt   ã   s0    ú 		ÿÿ
þrt   ÚfnÚ	Specifierr   c              	      s,   t  ˆ ¡dddtdtdtf‡ fdd„ƒ}|S )Nr   r˜   r‡   r<   r   c                    s   t |tƒsdS ˆ | ||ƒS rf   )rT   r   r‰   ©r—   r   r   Úwrapped"  s   
z)_require_version_compare.<locals>.wrapped)Ú	functoolsÚwrapsrs   r1   r4   )r—   rš   r   r™   r   Ú_require_version_compare  s    r�   c                	   @   s8  e 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	e
dededefdd„ƒZe
dededefdd„ƒZe
dededefdd„ƒZe
dededefdd„ƒZe
dededefdd„ƒZe
dededefdd„ƒZe
dededefdd„ƒZdededefdd „Zedefd!d"„ƒZejd#edd$fd%d"„ƒZd$S )&r˜   a  
        (?P<operator>(~=|==|!=|<=|>=|<|>|===))
        (?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]*    # We just match everything, except for whitespace
                          # since we are only testing for strict identity.
            )
            |
            (?:
                # 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
                (?:                   # pre release
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?

                # You cannot use a wild card and a dev or local version
                # together so group them with a | and make them optional.
                (?:
                    (?:[-_\.]?dev[-_\.]?[0-9]*)?         # dev release
                    (?:\+[a-z0-9]+(?:[-_\.][a-z0-9]+)*)? # local
                    |
                    \.\*  # Wild card syntax of .*
                )?
            )
            |
            (?:
                # 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
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [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
                    [-_\.]?
                    (a|b|c|rc|alpha|beta|pre|preview)
                    [-_\.]?
                    [0-9]*
                )?
                (?:                                   # post release
                    (?:-[0-9]+)|(?:[-_\.]?(post|rev|r)[-_\.]?[0-9]*)
                )?
                (?:[-_\.]?dev[-_\.]?[0-9]*)?          # dev release
            )
        )
        ru   rv   Ú
compatiblerw   rx   ry   rz   r{   r|   Ú	arbitrary)ú~=r}   r~   r   r€   rH   r�   ú===r‡   r<   r   c                 C   sJ   d  tt tt|ƒ¡ƒd d… ¡}|d7 }|  d¡||ƒo$|  d¡||ƒS )NÚ.éÿÿÿÿú.*r€   r}   )ÚjoinÚlistÚ	itertoolsÚ	takewhileÚ_is_not_suffixÚ_version_splitrZ   )r   r‡   r<   Úprefixr   r   r   Ú_compare_compatible—  s   ÿÿzSpecifier._compare_compatiblec           	      C   sv   |  d¡r+t|jƒ}t|d d… ƒ}tt|ƒƒ}|d t|ƒ… }t||ƒ\}}||kS t|ƒ}|js7t|jƒ}||kS )Nr¤   éþÿÿÿ)Úendswithr   Úpublicrª   r1   ÚlenÚ_pad_versionÚlocal)	r   r‡   r<   Ú
split_specÚsplit_prospectiveÚshortened_prospectiveÚpadded_specÚpadded_prospectiveÚspec_versionr   r   r   rŠ   ­  s   

ÿ
zSpecifier._compare_equalc                 C   s   |   ||¡ S r.   )rŠ   r‰   r   r   r   rŒ   Õ  s   zSpecifier._compare_not_equalc                 C   s   t |jƒt |ƒkS r.   ©r   r¯   r‰   r   r   r   r�   Ù  s   z"Specifier._compare_less_than_equalc                 C   s   t |jƒt |ƒkS r.   r¹   r‰   r   r   r   rŽ   á  s   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   rg   Úbase_version©r   r‡   rº   r<   r   r   r   r�   ë  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   r�     s   
zSpecifier._compare_greater_thanc                 C   s   t |ƒ ¡ t |ƒ ¡ kS r.   )r1   Úlowerr‰   r   r   r   Ú_compare_arbitrary%  s   zSpecifier._compare_arbitraryc                 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}   r€   r   r    r¡   r}   r¤   r­   TF)rD   rC   r®   r   rg   )r   r>   r?   r   r   r   r&   (  s   


zSpecifier.prereleasesr'   Nc                 C   ra   r.   r`   r(   r   r   r   r&   A  r_   )r   r   r   r‘   r’   r“   r”   r•   r:   r9   r�   rs   r1   r4   r¬   rŠ   rŒ   r�   rŽ   r�   r�   r   rÀ   rp   r&   r6   r   r   r   r   r˜   +  sJ    ]ø'ÿÿþ	z^([0-9]+)((?:a|b|c|rc)[0-9]+)$r?   c                 C   s@   g }|   d¡D ]}t |¡}|r| | ¡ ¡ q| |¡ q|S )Nr¢   )ÚsplitÚ_prefix_regexr@   ÚextendÚgroupsri   )r?   Úresultr)   rE   r   r   r   rª   I  s   
rª   Úsegmentc                    s   t ‡ fdd„dD ƒƒ S )Nc                 3   s   � | ]}ˆ   |¡V  qd S r.   )Ú
startswith)Ú.0r«   ©rÆ   r   r   Ú	<genexpr>U  s   € 

ÿz!_is_not_suffix.<locals>.<genexpr>)ÚdevÚaÚbÚrcÚpost)ÚanyrÉ   r   rÉ   r   r©   T  s   
ÿr©   Ú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)ri   r¦   r§   r¨   r°   ÚinsertÚmaxÚchain)rÑ   rÒ   Ú
left_splitÚright_splitr   r   r   r±   Z  s   
,,r±   c                   @   s$  e Zd Z	d#dede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edee fdd„ƒZejdeddfdd„ƒZdedefdd„Z	d$d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 )%ÚSpecifierSetr;   NÚ
specifiersr&   r   c              	   C   sj   dd„ |  d¡D ƒ}tƒ }|D ]}z	| t|ƒ¡ W q ty*   | t|ƒ¡ Y qw t|ƒ| _|| _d S )Nc                 S   s   g | ]
}|  ¡ r|  ¡ ‘qS r   )rB   ©rÈ   Úsr   r   r   Ú
<listcomp>s  s    z)SpecifierSet.__init__.<locals>.<listcomp>ú,)	rÁ   ÚsetÚaddr˜   r   rt   Ú	frozensetÚ_specsrD   )r   rá   r&   Úsplit_specifiersÚparsedÚ	specifierr   r   r   rF   m  s   ÿ

zSpecifierSet.__init__c                 C   s.   | j d urd| j›�nd}dt| ƒ›|› d�S )NrG   r;   z<SpecifierSet(rJ   )rD   r&   r1   rL   r   r   r   rN   …  s
   
ÿýzSpecifierSet.__repr__c                 C   s   d  tdd„ | jD ƒƒ¡S )Nrå   c                 s   s   � | ]}t |ƒV  qd S r.   )r1   râ   r   r   r   rÊ   �  s   € z'SpecifierSet.__str__.<locals>.<genexpr>)r¥   Úsortedré   r   r   r   r   r    Ž  s   zSpecifierSet.__str__c                 C   rQ   r.   )rR   ré   r   r   r   r   r"   ‘  rS   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ƒ‚)NzFCannot combine SpecifierSets with True and False prerelease overrides.)rT   r1   rà   rU   rè   ré   rD   Ú
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 r.   )rT   r1   r8   rà   rU   ré   r$   r   r   r   r%   «  s
   
zSpecifierSet.__eq__c                 C   rQ   r.   )r°   ré   r   r   r   r   Ú__len__³  rS   zSpecifierSet.__len__c                 C   rQ   r.   )Úiterré   r   r   r   r   Ú__iter__¶  rS   zSpecifierSet.__iter__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>)rD   ré   rÐ   r   r   r   r   r&   ¹  s
   
zSpecifierSet.prereleasesr'   c                 C   ra   r.   r`   r(   r   r   r   r&   Ë  r_   r)   c                 C   rb   r.   rc   rd   r   r   r   re   Ï  rS   zSpecifierSet.__contains__c                    sL   t ˆ ttfƒstˆ ƒ‰ ˆd u r| j‰ˆsˆ jrdS t‡ ‡fdd„| jD ƒƒS )NFc                 3   s   � | ]
}|j ˆ ˆd �V  qdS )ró   Nrc   râ   ©r)   r&   r   r   rÊ   í  s   € z(SpecifierSet.contains.<locals>.<genexpr>)rT   r   r   r   r&   rg   Úallré   r*   r   rô   r   r+   Ò  s   
zSpecifierSet.containsr,   c                 C   s¬   |d u r| j }| jr| jD ]}|j|t|ƒd�}q|S g }g }|D ](}t|ttfƒs/t|ƒ}n|}t|tƒr7q!|jrD|sD|sC| 	|¡ q!| 	|¡ q!|sT|rT|d u rT|S |S )Nró   )
r&   ré   r-   r4   rT   r   r   r   rg   ri   )r   r,   r&   r<   Úfilteredrk   r)   rm   r   r   r   r-   ï  s,   




€zSpecifierSet.filterrn   r.   )r   r   r   r1   r   r4   rF   rN   r    r2   r"   r   rï   r3   r%   rð   r   r8   rò   rp   r&   r6   rr   re   r+   r   r   r-   r   r   r   r   rà   l  sJ    ÿÿÿ
þ	ÿÿÿ
þÿÿÿþrà   )+r/   r›   r§   r’   rƒ   Útypingr   r   r   r   r   r   r   r	   r
   r   r   Úutilsr   r?   r   r   r   rs   r1   rr   r   r4   rq   rî   r   ÚABCMetar   r8   rt   r�   r˜   r“   rÂ   rª   r©   r±   rà   r   r   r   r   Ú<module>   s<   43 
<ÿ
þ  
.