o
    Mfx                  	   @   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   i/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/setuptools/_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	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   )zu
        Returns a boolean representing whether or not the two Specifier like
        objects are not equal.
        Nr   r$   r   r   r   __ne__<   r!   zBaseSpecifier.__ne__c                 C   r   )zg
        Returns whether or not pre-releases as a whole are allowed by this
        specifier.
        Nr   r   r   r   r   prereleasesC   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'   J   r!   itemr'   c                 C   r   )zR
        Determines if the given item is contained within this specifier.
        Nr   r   r*   r'   r   r   r   containsQ   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   filterW   r!   zBaseSpecifier.filterN)r   r   r   abcabstractmethodstrr    intr"   objectboolr%   r&   abstractpropertyr   r'   setterr,   r   r   r.   r   r   r   r   r   '   s0    r   )	metaclassc                   @   s~  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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__f   s   
z_IndividualSpecifier.__init__c                 C   s0   | j d urd| jnd}d| jjt| |S )N, prereleases=r<   z<{}({!r}{})>)rE   r'   format	__class__r   r2   r   prer   r   r   __repr__s   s
   
z_IndividualSpecifier.__repr__c                 C   s   dj | j S )Nz{}{})rI   rD   r   r   r   r   r    |   s   z_IndividualSpecifier.__str__c                 C   s   | j d t| j d fS )Nr   r   )rD   r   r   r   r   r   _canonical_spec   s   z$_IndividualSpecifier._canonical_specc                 C   
   t | jS r/   )hashrN   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/   )
isinstancer2   rJ   r   NotImplementedrN   r$   r   r   r   r%         
z_IndividualSpecifier.__eq__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/   )rR   r2   rJ   r   rS   rD   r$   r   r   r   r&      rT   z_IndividualSpecifier.__ne__opc                 C   s   t | d| j|  }|S )N	_compare_)getattrr:   )r   rU   operator_callabler   r   r   _get_operator   s   z"_IndividualSpecifier._get_operatorr@   c                 C   s   t |ttfst|}|S r/   )rR   r   r   r   r   r@   r   r   r   _coerce_version   s   z$_IndividualSpecifier._coerce_versionc                 C   
   | j d S )Nr   rD   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/   rE   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__   rQ   z!_IndividualSpecifier.__contains__c                 C   s>   |d u r| j }| |}|jr|sdS | | j}||| jS NF)r'   r[   is_prereleaserY   r?   r@   )r   r*   r'   normalized_itemrX   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,   rf   r'   append)r   r-   r'   yieldedfound_prereleaseskwr@   parsed_versionr   r   r   r.      s*   
z_IndividualSpecifier.filterr<   Nr/   )#r   r   r   r:   r   r2   __annotations__r   r   r5   rG   rM   r    propertyr
   rN   r3   r"   r4   r%   r&   CallableOperatorrY   UnparsedVersionParsedVersionr[   r?   r@   r'   r7   rd   r,   r   r   r.   r   r   r   r   r9   a   sL   
 	
r9   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)==!=<=>=<>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)superrG   warningswarnDeprecationWarning)r   r=   r'   rJ   r   r   rG     s
   zLegacySpecifier.__init__r@   c                 C   s   t |tstt|}|S r/   )rR   r   r2   rZ   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_thanrm   )r   r   r   
_regex_strrecompileVERBOSE
IGNORECASEr;   r:   r2   r   r5   rG   rq   r   r[   r   r   r   r   r   r   __classcell__r   r   r   r   rs      s0     		
rs   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 re   )rR   r   r   r   r   r   wrapped4  s   
z)_require_version_compare.<locals>.wrapped)	functoolswrapsrr   r2   r5   )r   r   r   r   r   _require_version_compare1  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
            )
        )
        rt   ru   
compatiblerv   rw   rx   ry   rz   r{   	arbitrary)~=r|   r}   r~   r   r   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_splitrY   )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   r2   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   rf   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/   )r2   lowerr   r   r   r   _compare_arbitrary7  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)rE   rD   r   r   rf   )r   r?   r@   r   r   r   r'   :  s   


zSpecifier.prereleasesr(   Nc                 C   r`   r/   r_   r)   r   r   r   r'   S  r^   )r   r   r   r   r   r   r   r   r;   r:   r   rr   r2   r5   r   r   r   r   r   r   r   r   r   ro   r'   r7   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_regexrA   extendgroupsrh   )r@   resultr*   rF   r   r   r   r   [  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>g  s    

z!_is_not_suffix.<locals>.<genexpr>)devabrcpost)anyr   r   r   r   r   f  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>p      z_pad_version.<locals>.<lambda>c                 S   r   r/   r   r   r   r   r   r   q  r   r   r   0)rh   r   r   r   r   insertmaxchain)r   r   
left_splitright_splitr   r   r   r   l  s   
,,r   c                   @   s6  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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   )rC   r   sr   r   r   
<listcomp>  s    z)SpecifierSet.__init__.<locals>.<listcomp>,)	r   setaddr   r   rs   	frozenset_specsrE   )r   r   r'   split_specifiersparsed	specifierr   r   r   rG     s   

zSpecifierSet.__init__c                 C   s*   | j d urd| jnd}dt| |S )NrH   r<   z<SpecifierSet({!r}{})>)rE   r'   rI   r2   rK   r   r   r   rM     s
   
zSpecifierSet.__repr__c                 C   s   d tdd | jD S )Nr   c                 s   s    | ]}t |V  qd S r/   )r2   r   r   r   r   r     s    z'SpecifierSet.__str__.<locals>.<genexpr>)r   sortedr   r   r   r   r   r      s   zSpecifierSet.__str__c                 C   rO   r/   )rP   r   r   r   r   r   r"     rQ   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.)rR   r2   r   rS   r   r   rE   
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/   rR   r2   r9   r   rS   r   r$   r   r   r   r%     
   
zSpecifierSet.__eq__c                 C   s6   t |ttfrtt|}nt |tstS | j|jkS r/   r   r$   r   r   r   r&     r   zSpecifierSet.__ne__c                 C   rO   r/   )r   r   r   r   r   r   __len__  rQ   zSpecifierSet.__len__c                 C   rO   r/   )iterr   r   r   r   r   __iter__  rQ   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>)rE   r   r   r   r   r   r   r'     s
   
zSpecifierSet.prereleasesr(   c                 C   r`   r/   r_   r)   r   r   r   r'     r^   r*   c                 C   ra   r/   rb   rc   r   r   r   rd     rQ   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   Nrb   r   r*   r'   r   r   r     s    z(SpecifierSet.contains.<locals>.<genexpr>)rR   r   r   r   r'   rf   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.   r5   rR   r   r   r   rf   rh   )r   r-   r'   r=   filteredrj   r*   rl   r   r   r   r.   	  s,   




zSpecifierSet.filterrm   r/   )r   r   r   r2   r   r5   rG   rM   r    r3   r"   r   r   r4   r%   r&   r   r   r9   r   ro   r'   r7   rq   rd   r,   r   r   r.   r   r   r   r   r   ~  sL    
	
r   )+r0   r   r   r   r   typingr   r   r   r   r   r   r   r	   r
   r   r   utilsr   r@   r   r   r   rr   r2   rq   r   r5   rp   r   r   ABCMetar   r9   rs   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s<   4: <
  
.