a
    e0hym                     @   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m	Z	m
Z
 ddlmZmZm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)VersionLegacyVersionparsec                   @   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   X/var/www/auris/lib/python3.9/site-packages/pkg_resources/_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__+   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   prereleases2   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   9   s    Nc                 C   s   dS )zR
        Determines if the given item is contained within this specifier.
        Nr   r   itemr   r   r   r   contains@   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   filterF   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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__R   s    z_IndividualSpecifier.__init__c                 C   s0   | j d urd| jnd}d| jjt| |S )N, prereleases={0!r}r(   z<{0}({1!r}{2})>)r1   r-   r   	__class__r   strr   prer   r   r   __repr___   s    z_IndividualSpecifier.__repr__c                 C   s   dj | j S )Nz{0}{1})r-   r0   r   r   r   r   r   l   s    z_IndividualSpecifier.__str__c                 C   s
   t | jS N)hashr0   r   r   r   r   r   o   s    z_IndividualSpecifier.__hash__c                 C   sN   t |tr2z| |}W qB ty.   t Y S 0 nt || jsBtS | j|jkS r;   
isinstancer   r6   r   NotImplementedr0   r   r   r   r   r   r   s    
z_IndividualSpecifier.__eq__c                 C   sN   t |tr2z| |}W qB ty.   t Y S 0 nt || jsBtS | j|jkS r;   r=   r   r   r   r   r   }   s    
z_IndividualSpecifier.__ne__c                 C   s   t | d| j| S )Nz_compare_{0})getattrr-   
_operators)r   opr   r   r   _get_operator   s    z"_IndividualSpecifier._get_operatorc                 C   s   t |ttfst|}|S r;   )r>   r	   r   r
   r   r*   r   r   r   _coerce_version   s    z$_IndividualSpecifier._coerce_versionc                 C   s
   | j d S )Nr   r0   r   r   r   r   r)      s    z_IndividualSpecifier.operatorc                 C   s
   | j d S )Nr   rF   r   r   r   r   r*      s    z_IndividualSpecifier.versionc                 C   s   | j S r;   r1   r   r   r   r   r      s    z _IndividualSpecifier.prereleasesc                 C   s
   || _ d S r;   rG   r   r   r   r   r      s    c                 C   s
   |  |S r;   r    r   r   r   r   r   __contains__   s    z!_IndividualSpecifier.__contains__c                 C   s:   |d u r| j }| |}|jr&|s&dS | | j|| jS NF)r   rE   is_prereleaserC   r)   r*   r   r   r   r   r       s    

z_IndividualSpecifier.containsc                 c   s   d}g }d|d ur|ndi}|D ]F}|  |}| j|fi |r |jr\|s\| js\|| q d}|V  q |s|r|D ]
}|V  qtd S )NFr   T)rE   r    rL   r   append)r   r!   r   yieldedfound_prereleaseskwr*   parsed_versionr   r   r   r"      s"    
z_IndividualSpecifier.filter)r(   N)N)N)r   r   r   rA   r4   r:   r   r   r   r   rC   rE   propertyr)   r*   r   r&   rJ   r    r"   r   r   r   r   r'   N   s(   





r'   c                   @   sv   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 Z
dd Zdd Zdd Zdd Zdd Zdd Zd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)==!=<=>=<>c                 C   s   t |tstt|}|S r;   )r>   r	   r7   rD   r   r   r   rE      s    
zLegacySpecifier._coerce_versionc                 C   s   ||  |kS r;   rE   r   prospectiver2   r   r   r   _compare_equal   s    zLegacySpecifier._compare_equalc                 C   s   ||  |kS r;   rb   rc   r   r   r   _compare_not_equal   s    z"LegacySpecifier._compare_not_equalc                 C   s   ||  |kS r;   rb   rc   r   r   r   _compare_less_than_equal   s    z(LegacySpecifier._compare_less_than_equalc                 C   s   ||  |kS r;   rb   rc   r   r   r   _compare_greater_than_equal   s    z+LegacySpecifier._compare_greater_than_equalc                 C   s   ||  |k S r;   rb   rc   r   r   r   _compare_less_than  s    z"LegacySpecifier._compare_less_thanc                 C   s   ||  |kS r;   rb   rc   r   r   r   _compare_greater_than  s    z%LegacySpecifier._compare_greater_thanN)r   r   r   
_regex_strrecompileVERBOSE
IGNORECASEr+   rA   rE   re   rf   rg   rh   ri   rj   r   r   r   r   rS      s&   	rS   c                    s   t   fdd}|S )Nc                    s   t |tsdS  | ||S rK   )r>   r   rc   fnr   r   wrapped  s    
z)_require_version_compare.<locals>.wrapped)	functoolswraps)rq   rr   r   rp   r   _require_version_compare
  s    ru   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
            )
        )
        rT   rU   
compatiblerV   rW   rX   rY   rZ   r[   	arbitrary)~=r\   r]   r^   r_   r`   ra   ===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>  s   z/Specifier._compare_compatible.<locals>.<lambda>.*r_   r\   )joinlist	itertools	takewhile_version_splitrC   )r   rd   r2   prefixr   r   r   _compare_compatible  s    zSpecifier._compare_compatiblec                 C   sp   | drPt|j}t|d d }tt|}|d t| }t||\}}nt|}|jsht|j}||kS )Nr   )endswithr   publicr   r7   len_pad_versionlocalrc   r   r   r   re     s    


zSpecifier._compare_equalc                 C   s   |  || S r;   )re   rc   r   r   r   rf     s    zSpecifier._compare_not_equalc                 C   s   |t |kS r;   r   rc   r   r   r   rg     s    z"Specifier._compare_less_than_equalc                 C   s   |t |kS r;   r   rc   r   r   r   rh     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   rL   base_versionrc   r   r   r   ri     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 urZt |jt |jkrZdS dS r   )r   is_postreleaser   r   rc   r   r   r   rj     s    
zSpecifier._compare_greater_thanc                 C   s   t | t | kS r;   )r7   lowerrc   r   r   r   _compare_arbitrary  s    zSpecifier._compare_arbitraryc                 C   sR   | j d ur| j S | j\}}|dv rN|dkr@|dr@|d d }t|jrNdS dS )N)r\   r_   r^   ry   rz   r\   r   r   TF)r1   r0   r   r
   rL   )r   r)   r*   r   r   r   r     s    


zSpecifier.prereleasesc                 C   s
   || _ d S r;   rG   r   r   r   r   r     s    N)r   r   r   rk   rl   rm   rn   ro   r+   rA   ru   r   re   rf   rg   rh   ri   rj   r   rR   r   r&   r   r   r   r   rv     sB   _

"





rv   z^([0-9]+)((?:a|b|c|rc)[0-9]+)$c                 C   s@   g }|  dD ],}t|}|r0||  q|| q|S )Nr{   )split_prefix_regexr,   extendgroupsrM   )r*   resultr   r3   r   r   r   r   '  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 r;   isdigitr   r   r   r   r   6      z_pad_version.<locals>.<lambda>c                 S   s   |   S r;   r   r   r   r   r   r   7  r   r   r   0)rM   r   r   r   r   insertmaxchain)leftright
left_splitright_splitr   r   r   r   2  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 )!SpecifierSetr(   Nc              	   C   sl   dd | dD }t }|D ]8}z|t| W q tyT   |t| Y q0 qt|| _|| _d S )Nc                 S   s   g | ]}|  r|  qS r   )r/   .0sr   r   r   
<listcomp>R  r   z)SpecifierSet.__init__.<locals>.<listcomp>,)	r   setaddrv   r   rS   	frozenset_specsr1   )r   
specifiersr   parsed	specifierr   r   r   r4   O  s    
zSpecifierSet.__init__c                 C   s*   | j d urd| jnd}dt| |S )Nr5   r(   z<SpecifierSet({0!r}{1})>)r1   r-   r   r7   r8   r   r   r   r:   d  s
    zSpecifierSet.__repr__c                 C   s   d tdd | jD S )Nr   c                 s   s   | ]}t |V  qd S r;   )r7   r   r   r   r   	<genexpr>n  r   z'SpecifierSet.__str__.<locals>.<genexpr>)r   sortedr   r   r   r   r   r   m  s    zSpecifierSet.__str__c                 C   s
   t | jS r;   )r<   r   r   r   r   r   r   p  s    zSpecifierSet.__hash__c                 C   s   t |trt|}nt |ts"tS t }t| j|jB |_| jd u rX|jd urX|j|_n<| jd urv|jd u rv| j|_n| j|jkr| j|_ntd|S )NzFCannot combine SpecifierSets with True and False prerelease overrides.)r>   r   r   r?   r   r   r1   
ValueError)r   r   r   r   r   r   __and__s  s     





zSpecifierSet.__and__c                 C   sF   t |trt|}n&t |tr,tt|}nt |ts:tS | j|jkS r;   r>   r   r   r'   r7   r?   r   r   r   r   r   r     s    



zSpecifierSet.__eq__c                 C   sF   t |trt|}n&t |tr,tt|}nt |ts:tS | j|jkS r;   r   r   r   r   r   r     s    



zSpecifierSet.__ne__c                 C   s
   t | jS r;   )r   r   r   r   r   r   __len__  s    zSpecifierSet.__len__c                 C   s
   t | jS r;   )iterr   r   r   r   r   __iter__  s    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     r   z+SpecifierSet.prereleases.<locals>.<genexpr>)r1   r   anyr   r   r   r   r     s
    
zSpecifierSet.prereleasesc                 C   s
   || _ d S r;   rG   r   r   r   r   r     s    c                 C   s
   |  |S r;   rH   rI   r   r   r   rJ     s    zSpecifierSet.__contains__c                    sL   t  ttfst  d u r$| js2 jr2dS t fdd| jD S )NFc                 3   s   | ]}|j  d V  qdS )r   NrH   r   r   r   r   r   r     s   z(SpecifierSet.contains.<locals>.<genexpr>)r>   r	   r   r
   r   rL   allr   r   r   r   r   r      s    
zSpecifierSet.containsc                 C   s   |d u 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 u r|S |S d S )Nr   )
r   r   r"   boolr>   r	   r   r
   rL   rM   )r   r!   r   r2   filteredrO   r   rQ   r   r   r   r"     s*    



zSpecifierSet.filter)r(   N)N)N)r   r   r   r4   r:   r   r   r   r   r   r   r   rR   r   r&   rJ   r    r"   r   r   r   r   r   M  s    
	




r   )
__future__r   r   r   r#   rs   r   rl   _compatr   r   r*   r   r	   r
   r   r   ABCMetaobjectr   r'   rS   ru   rv   rm   r   r   r   r   r   r   r   r   <module>   s&   9 	4	  
