U
    +|jÐ}  ã                   @   s\  d dl mZmZmZ 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 ddlmZ ddlmZ ddlmZmZmZ erÎd dlmZmZmZmZmZmZmZmZ eeef Zeeeef Zeeege f Z!G d	d
„ d
e"ƒZ#G dd„ deej$e%ƒƒZ&G dd„ de&ƒZ'G dd„ de'ƒZ(dd„ Z)G dd„ de'ƒZ*e +d¡Z,dd„ Z-dd„ Z.G dd„ de&ƒZ/dS )é    )Úabsolute_importÚdivisionÚprint_functionNé   )Ústring_typesÚwith_metaclass)ÚTYPE_CHECKING)Úcanonicalize_version)ÚLegacyVersionÚVersionÚparse)ÚCallableÚDictÚIterableÚIteratorÚListÚOptionalÚTupleÚUnionc                   @   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   úhC:\Users\snmko\Desktop\web_content\django_cbt\venv\Lib\site-packages\pip/_vendor/packaging/specifiers.pyr      s   r   c                   @   s€   e Zd Zejdd„ ƒZejdd„ ƒZejdd„ ƒZejdd„ ƒZej	d	d
„ ƒZ
e
jdd
„ ƒZ
ejddd„ƒZejddd„ƒZdS )ÚBaseSpecifierc                 C   s   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__    s    zBaseSpecifier.__str__c                 C   s   dS )zF
        Returns a hash value for this Specifier like object.
        Nr   r   r   r   r   Ú__hash__(   s    zBaseSpecifier.__hash__c                 C   s   dS )zq
        Returns a boolean representing whether or not the two Specifier like
        objects are equal.
        Nr   ©r   Úotherr   r   r   Ú__eq__/   s    zBaseSpecifier.__eq__c                 C   s   dS )zu
        Returns a boolean representing whether or not the two Specifier like
        objects are not equal.
        Nr   r!   r   r   r   Ú__ne__7   s    zBaseSpecifier.__ne__c                 C   s   dS )zg
        Returns whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   r   r   r   r   Úprereleases?   s    zBaseSpecifier.prereleasesc                 C   s   dS )zd
        Sets whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   ©r   Úvaluer   r   r   r%   G   s    Nc                 C   s   dS )zR
        Determines if the given item is contained within this specifier.
        Nr   ©r   Úitemr%   r   r   r   ÚcontainsO   s    zBaseSpecifier.containsc                 C   s   dS )z•
        Takes an iterable of items and filters them so that only items which
        are contained within this specifier are allowed in it.
        Nr   )r   Úiterabler%   r   r   r   ÚfilterV   s    zBaseSpecifier.filter)N)N)r   r   r   ÚabcÚabstractmethodr   r    r#   r$   Úabstractpropertyr%   Úsetterr*   r,   r   r   r   r   r      s    





r   c                   @   s¬   e Zd Zi Zd"dd„Zdd„ Zdd„ Zed	d
„ ƒZdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zedd„ ƒZedd„ ƒZedd„ ƒZejdd„ ƒZdd„ Zd#dd„Zd$d d!„ZdS )%Ú_IndividualSpecifierÚ Nc                 C   sF   | j  |¡}|std |¡ƒ‚| d¡ ¡ | d¡ ¡ f| _|| _d S )NzInvalid specifier: '{0}'ÚoperatorÚversion)Ú_regexÚsearchr   ÚformatÚgroupÚstripÚ_specÚ_prereleases)r   Úspecr%   Úmatchr   r   r   Ú__init__c   s    þz_IndividualSpecifier.__init__c                 C   s0   | j d k	rd | j¡nd}d | jjt| ƒ|¡S )Nú, prereleases={0!r}r2   z<{0}({1!r}{2})>)r;   r7   r%   Ú	__class__r   Ústr©r   Úprer   r   r   Ú__repr__q   s
    ÿýz_IndividualSpecifier.__repr__c                 C   s   dj | jŽ S )Nz{0}{1})r7   r:   r   r   r   r   r   {   s    z_IndividualSpecifier.__str__c                 C   s   | j d t| j d ƒfS )Nr   r   )r:   r	   r   r   r   r   Ú_canonical_spec   s    z$_IndividualSpecifier._canonical_specc                 C   s
   t | jƒS ©N)ÚhashrE   r   r   r   r   r    „   s    z_IndividualSpecifier.__hash__c                 C   sT   t |tƒr8z|  t|ƒ¡}W qH tk
r4   t Y S X nt || jƒsHtS | j|jkS rF   )Ú
isinstancer   r@   rA   r   ÚNotImplementedrE   r!   r   r   r   r#   ˆ   s    
z_IndividualSpecifier.__eq__c                 C   sT   t |tƒr8z|  t|ƒ¡}W qH tk
r4   t Y S X nt || jƒsHtS | j|jkS rF   )rH   r   r@   rA   r   rI   r:   r!   r   r   r   r$   ”   s    
z_IndividualSpecifier.__ne__c                 C   s   t | d | j| ¡ƒ}|S )Nz_compare_{0})Úgetattrr7   Ú
_operators)r   ÚopÚoperator_callabler   r   r   Ú_get_operator    s
     ÿz"_IndividualSpecifier._get_operatorc                 C   s   t |ttfƒst|ƒ}|S rF   )rH   r
   r   r   ©r   r4   r   r   r   Ú_coerce_version§   s    z$_IndividualSpecifier._coerce_versionc                 C   s
   | j d S )Nr   ©r:   r   r   r   r   r3   ­   s    z_IndividualSpecifier.operatorc                 C   s
   | j d S )Nr   rQ   r   r   r   r   r4   ²   s    z_IndividualSpecifier.versionc                 C   s   | j S rF   ©r;   r   r   r   r   r%   ·   s    z _IndividualSpecifier.prereleasesc                 C   s
   || _ d S rF   rR   r&   r   r   r   r%   ¼   s    c                 C   s
   |   |¡S rF   ©r*   ©r   r)   r   r   r   Ú__contains__Á   s    z!_IndividualSpecifier.__contains__c                 C   s>   |d kr| j }|  |¡}|jr&|s&dS |  | j¡}||| jƒS ©NF)r%   rP   Úis_prereleaserN   r3   r4   )r   r)   r%   Únormalized_itemrM   r   r   r   r*   Å   s    

z_IndividualSpecifier.containsc                 c   s€   d}g }d|d k	r|ndi}|D ]B}|   |¡}| j|f|Žr |jrX|sX| jsX| |¡ q d}|V  q |s||r||D ]
}|V  qpd S )NFr%   T)rP   r*   rW   r%   Úappend)r   r+   r%   ÚyieldedÚfound_prereleasesÚkwr4   Úparsed_versionr   r   r   r,   Û   s"    
ÿÿz_IndividualSpecifier.filter)r2   N)N)N)r   r   r   rK   r>   rD   r   ÚpropertyrE   r    r#   r$   rN   rP   r3   r4   r%   r0   rU   r*   r,   r   r   r   r   r1   _   s,   







r1   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‡ fdd„	Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Z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)ú==ú!=ú<=ú>=ú<ú>r2   Nc                    s"   t t| ƒ ||¡ t dt¡ d S )NzZCreating a LegacyVersion has been deprecated and will be removed in the next major release)Úsuperr_   r>   ÚwarningsÚwarnÚDeprecationWarning)r   r<   r%   ©r@   r   r   r>     s
    ýzLegacySpecifier.__init__c                 C   s   t |tƒstt|ƒƒ}|S rF   )rH   r
   rA   rO   r   r   r   rP   !  s    
zLegacySpecifier._coerce_versionc                 C   s   ||   |¡kS rF   ©rP   ©r   Úprospectiver<   r   r   r   Ú_compare_equal'  s    zLegacySpecifier._compare_equalc                 C   s   ||   |¡kS rF   rs   rt   r   r   r   Ú_compare_not_equal+  s    z"LegacySpecifier._compare_not_equalc                 C   s   ||   |¡kS rF   rs   rt   r   r   r   Ú_compare_less_than_equal/  s    z(LegacySpecifier._compare_less_than_equalc                 C   s   ||   |¡kS rF   rs   rt   r   r   r   Ú_compare_greater_than_equal3  s    z+LegacySpecifier._compare_greater_than_equalc                 C   s   ||   |¡k S rF   rs   rt   r   r   r   Ú_compare_less_than7  s    z"LegacySpecifier._compare_less_thanc                 C   s   ||   |¡kS rF   rs   rt   r   r   r   Ú_compare_greater_than;  s    z%LegacySpecifier._compare_greater_than)r2   N)r   r   r   Ú
_regex_strÚreÚcompileÚVERBOSEÚ
IGNORECASEr5   rK   r>   rP   rv   rw   rx   ry   rz   r{   Ú__classcell__r   r   rr   r   r_   þ   s"   ú	
r_   c                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc                    s   t |tƒsdS ˆ | ||ƒS rV   )rH   r   rt   ©Úfnr   r   ÚwrappedD  s    
z)_require_version_compare.<locals>.wrapped)Ú	functoolsÚwraps)rƒ   r„   r   r‚   r   Ú_require_version_compare@  s    r‡   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
ddœZ	e
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZe
dd„ ƒZdd„ Zedd„ ƒZejdd„ ƒZd S )!Ú	Specifiera  
        (?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
            )
        )
        r`   ra   Ú
compatiblerb   rc   rd   re   rf   rg   Ú	arbitrary)ú~=rh   ri   rj   rk   rl   rm   ú===c                 C   sN   d  tt dd„ t|ƒ¡ƒd d… ¡}|d7 }|  d¡||ƒoL|  d¡||ƒS )NÚ.c                 S   s   |   d¡ o|   d¡ S )NÚpostÚdev)Ú
startswith©Úxr   r   r   Ú<lambda>Ê  ó    z/Specifier._compare_compatible.<locals>.<lambda>éÿÿÿÿú.*rk   rh   )ÚjoinÚlistÚ	itertoolsÚ	takewhileÚ_version_splitrN   )r   ru   r<   Úprefixr   r   r   Ú_compare_compatibleº  s    þÿûÿ
 ÿzSpecifier._compare_compatiblec           	      C   sz   |  d¡rVt|jƒ}t|d d… ƒ}tt|ƒƒ}|d t|ƒ… }t||ƒ\}}||kS t|ƒ}|jsnt|jƒ}||kS d S )Nr–   éþÿÿÿ)Úendswithr   Úpublicr›   rA   ÚlenÚ_pad_versionÚlocal)	r   ru   r<   Ú
split_specÚsplit_prospectiveÚshortened_prospectiveÚpadded_specÚpadded_prospectiveÚspec_versionr   r   r   rv   ×  s    

 ÿ
zSpecifier._compare_equalc                 C   s   |   ||¡ S rF   )rv   rt   r   r   r   rw      s    zSpecifier._compare_not_equalc                 C   s   t |jƒt |ƒkS rF   ©r   r    rt   r   r   r   rx     s    z"Specifier._compare_less_than_equalc                 C   s   t |jƒt |ƒkS rF   rª   rt   r   r   r   ry     s    z%Specifier._compare_greater_than_equalc                 C   s<   t |ƒ}||k sdS |js8|jr8t |jƒt |jƒkr8dS dS ©NFT)r   rW   Úbase_version©r   ru   Úspec_strr<   r   r   r   rz     s    zSpecifier._compare_less_thanc                 C   s^   t |ƒ}||ksdS |js8|jr8t |jƒt |jƒkr8dS |jd k	rZt |jƒt |jƒkrZdS dS r«   )r   Úis_postreleaser¬   r£   r­   r   r   r   r{   2  s    
zSpecifier._compare_greater_thanc                 C   s   t |ƒ ¡ t |ƒ ¡ kS rF   )rA   Úlowerrt   r   r   r   Ú_compare_arbitraryS  s    zSpecifier._compare_arbitraryc                 C   sR   | j d k	r| j S | j\}}|dkrN|dkr@| d¡r@|d d… }t|ƒjrNdS dS )N)rh   rk   rj   r‹   rŒ   rh   r–   rž   TF)r;   r:   rŸ   r   rW   )r   r3   r4   r   r   r   r%   W  s    


zSpecifier.prereleasesc                 C   s
   || _ d S rF   rR   r&   r   r   r   r%   q  s    N)r   r   r   r|   r}   r~   r   r€   r5   rK   r‡   r�   rv   rw   rx   ry   rz   r{   r±   r^   r%   r0   r   r   r   r   rˆ   N  s<   ]ø

(




 
rˆ   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$c                 C   s@   g }|   d¡D ],}t |¡}|r0| | ¡ ¡ q| |¡ q|S )Nr�   )ÚsplitÚ_prefix_regexr6   ÚextendÚgroupsrY   )r4   Úresultr)   r=   r   r   r   r›   z  s    
r›   c              
   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   |   ¡ S rF   ©Úisdigitr‘   r   r   r   r“   ‹  r”   z_pad_version.<locals>.<lambda>c                 S   s   |   ¡ S rF   r·   r‘   r   r   r   r“   Œ  r”   r   r   Ú0)rY   r˜   r™   rš   r¡   ÚinsertÚmaxÚchain)ÚleftÚrightÚ
left_splitÚright_splitr   r   r   r¢   †  s    
,,r¢   c                   @   sŒ   e Zd Zddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zedd„ ƒZejdd„ ƒZdd„ Zddd„Zd dd„ZdS )!ÚSpecifierSetr2   Nc              	   C   sn   dd„ |  d¡D ƒ}tƒ }|D ]:}z| t|ƒ¡ W q tk
rV   | t|ƒ¡ Y qX qt|ƒ| _|| _d S )Nc                 S   s   g | ]}|  ¡ r|  ¡ ‘qS r   )r9   ©Ú.0Úsr   r   r   Ú
<listcomp>Ÿ  s      z)SpecifierSet.__init__.<locals>.<listcomp>ú,)	r²   ÚsetÚaddrˆ   r   r_   Ú	frozensetÚ_specsr;   )r   Ú
specifiersr%   Úsplit_specifiersÚparsedÚ	specifierr   r   r   r>   š  s    
zSpecifierSet.__init__c                 C   s*   | j d k	rd | j¡nd}d t| ƒ|¡S )Nr?   r2   z<SpecifierSet({0!r}{1})>)r;   r7   r%   rA   rB   r   r   r   rD   ±  s
    ÿýzSpecifierSet.__repr__c                 C   s   d  tdd„ | jD ƒƒ¡S )NrÆ   c                 s   s   | ]}t |ƒV  qd S rF   )rA   rÂ   r   r   r   Ú	<genexpr>½  s     z'SpecifierSet.__str__.<locals>.<genexpr>)r—   ÚsortedrÊ   r   r   r   r   r   »  s    zSpecifierSet.__str__c                 C   s
   t | jƒS rF   )rG   rÊ   r   r   r   r   r    ¿  s    zSpecifierSet.__hash__c                 C   s˜   t |tƒrt|ƒ}nt |tƒs"tS tƒ }t| j|jB ƒ|_| jd krX|jd k	rX|j|_n<| jd k	rv|jd krv| j|_n| j|jkrŒ| j|_ntdƒ‚|S )NzFCannot combine SpecifierSets with True and False prerelease overrides.)rH   r   rÁ   rI   rÉ   rÊ   r;   Ú
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 rF   ©rH   r   r1   rÁ   rA   rI   rÊ   r!   r   r   r   r#   Û  s
    
zSpecifierSet.__eq__c                 C   s6   t |ttfƒrtt|ƒƒ}nt |tƒs*tS | j|jkS rF   rÓ   r!   r   r   r   r$   ä  s
    
zSpecifierSet.__ne__c                 C   s
   t | jƒS rF   )r¡   rÊ   r   r   r   r   Ú__len__í  s    zSpecifierSet.__len__c                 C   s
   t | jƒS rF   )ÚiterrÊ   r   r   r   r   Ú__iter__ñ  s    zSpecifierSet.__iter__c                 C   s.   | j d k	r| j S | jsd S tdd„ | jD ƒƒS )Nc                 s   s   | ]}|j V  qd S rF   ©r%   rÂ   r   r   r   rÏ     s     z+SpecifierSet.prereleases.<locals>.<genexpr>)r;   rÊ   Úanyr   r   r   r   r%   õ  s
    
zSpecifierSet.prereleasesc                 C   s
   || _ d S rF   rR   r&   r   r   r   r%     s    c                 C   s
   |   |¡S rF   rS   rT   r   r   r   rU     s    zSpecifierSet.__contains__c                    sL   t ˆ ttfƒstˆ ƒ‰ ˆd kr$| j‰ˆs2ˆ jr2dS t‡ ‡fdd„| jD ƒƒS )NFc                 3   s   | ]}|j ˆ ˆd �V  qdS )r×   NrS   rÂ   ©r)   r%   r   r   rÏ   +  s     z(SpecifierSet.contains.<locals>.<genexpr>)rH   r
   r   r   r%   rW   ÚallrÊ   r(   r   rÙ   r   r*     s    
zSpecifierSet.containsc                 C   s°   |d kr| j }| jr6| jD ]}|j|t|ƒd�}q|S g }g }|D ]P}t|ttfƒs^t|ƒ}n|}t|tƒrnqB|jrˆ|sˆ|s’| 	|¡ qB| 	|¡ qB|s¨|r¨|d kr¨|S |S d S )Nr×   )
r%   rÊ   r,   ÚboolrH   r
   r   r   rW   rY   )r   r+   r%   r<   Úfilteredr[   r)   r]   r   r   r   r,   -  s*    




zSpecifierSet.filter)r2   N)N)N)r   r   r   r>   rD   r   r    rÒ   r#   r$   rÔ   rÖ   r^   r%   r0   rU   r*   r,   r   r   r   r   rÁ   ™  s"   

		


 ýrÁ   )0Ú
__future__r   r   r   r-   r…   r™   r}   ro   Ú_compatr   r   Ú_typingr   Úutilsr	   r4   r
   r   r   Útypingr   r   r   r   r   r   r   r   ZParsedVersionrA   ZUnparsedVersionrÛ   ZCallableOperatorrÑ   r   ÚABCMetaÚobjectr   r1   r_   r‡   rˆ   r~   r³   r›   r¢   rÁ   r   r   r   r   Ú<module>   s6   (@  B  +
