
    3i(                       U d Z ddlmZ ddlZddlZddlZddlZddlmZ ddl	m
Z
mZ ej                  dk\  rddddnd	diZe
rdd
lmZ  ej                   dej"                        Zded<    ej                   dej"                        Zded<   ddddZded<    edi e G d d             Z edi e G d d             Z edi e G d d             Zg dZy)zKVersion specifier support using only standard library (PEP 440 compatible).    )annotationsN)	dataclass)TYPE_CHECKINGFinal)   
   T)frozenkw_onlyslotsr	   )Iteratorz
    ^
    (\d+)               # major
    (?:\.(\d+))?        # optional minor
    (?:\.(\d+))?        # optional micro
    (?:(a|b|rc)(\d+))?  # optional pre-release suffix
    $
    zFinal[re.Pattern[str]]_VERSION_REzr
    ^
    (===|==|~=|!=|<=|>=|<|>)  # operator
    \s*
    (.+)                       # version string
    $
    _SPECIFIER_RE      r   )abrczFinal[dict[str, int]]
_PRE_ORDERc                      e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
ed<   ded<   e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y)SimpleVersiona  
    Simple PEP 440-like version parser using only standard library.

    :param version_str: the original version string.
    :param major: major version number.
    :param minor: minor version number.
    :param micro: micro (patch) version number.
    :param pre_type: pre-release label (``"a"``, ``"b"``, or ``"rc"``), or ``None``.
    :param pre_num: pre-release sequence number, or ``None``.
    :param release: the ``(major, minor, micro)`` tuple.
    strversion_strintmajorminormicroz
str | Nonepre_type
int | Nonepre_numztuple[int, int, int]releasec                   |j                         }t        j                  |      x}sd| }t        |      t	        |j                  d            }|j                  d      rt	        |j                  d            nd}|j                  d      rt	        |j                  d            nd} | |||||j                  d      |j                  d      rt	        |j                  d            nd|||f	      S )
z}
        Parse a PEP 440 version string (e.g. ``3.12.1``).

        :param version_str: the version string to parse.
        zInvalid version: r   r   r   r         N)r   r   r   r   r   r   r    )stripr   match
ValueErrorr   group)clsr   strippedr%   msgr   r   r   s           N/var/www/opsc/venv/lib/python3.12/site-packages/python_discovery/_specifier.pyfrom_stringzSimpleVersion.from_string?   s     $$&$**8444%k]3CS/!EKKN#',{{1~EKKN#1',{{1~EKKN#1 [[^+0;;q>CA'tE5)
 	
    c                    t        |t              st        S | j                  |j                  k(  xr4 | j                  |j                  k(  xr | j
                  |j
                  k(  S N)
isinstancer   NotImplementedr    r   r   selfothers     r+   __eq__zSimpleVersion.__eq__W   sO    %/!!||u}},r%..1PrUYUaUaejererUrrr-   c                Z    t        | j                  | j                  | j                  f      S r/   )hashr    r   r   r3   s    r+   __hash__zSimpleVersion.__hash__\   s     T\\4==$,,?@@r-   c                   t        |t              st        S | j                  |j                  k7  r| j                  |j                  k  S | j                  |j                  y| j                  y|j                  yt
        | j                     t
        |j                     k7  r't
        | j                     t
        |j                     k  S | j                  xs d|j                  xs dk  S )NFTr   )r0   r   r1   r    r   r   r   r2   s     r+   __lt__zSimpleVersion.__lt___   s    %/!!<<5==(<<%--//== U^^%;== >>!dmm$
5>>(BBdmm,z%../III!emm&8q99r-   c                    | |k(  xs | |k  S r/    r2   s     r+   __le__zSimpleVersion.__le__n   s    u},u,r-   c                :    t        |t              st        S | |k   S r/   )r0   r   r1   r2   s     r+   __gt__zSimpleVersion.__gt__q   s    %/!!5=  r-   c                    | |k   S r/   r=   r2   s     r+   __ge__zSimpleVersion.__ge__v   s    %<r-   c                    | j                   S r/   r   r8   s    r+   __str__zSimpleVersion.__str__y   s    r-   c                "    d| j                    dS )NzSimpleVersion('')rD   r8   s    r+   __repr__zSimpleVersion.__repr__|   s     !1!1 2"55r-   N)r   r   returnr   r4   objectrI   boolrI   r   rI   r   )__name__
__module____qualname____doc____annotations__classmethodr,   r5   r9   r;   r>   r@   rB   rE   rH   r=   r-   r+   r   r   )   sl    
 JJJ!!
 
.s
A:-!
  6r-   r   c                      e Zd ZU dZded<   ded<   ded<   ded<   ded	<   d
ed<   e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y)SimpleSpecifiera+  
    Simple PEP 440-like version specifier using only standard library.

    :param spec_str: the original specifier string (e.g. ``>=3.10``).
    :param operator: the comparison operator (``==``, ``>=``, ``<``, etc.).
    :param version_str: the version portion of the specifier, without the operator.
    :param is_wildcard: ``True`` if the specifier uses a wildcard suffix (``.*``).
    :param wildcard_precision: number of version components before the wildcard, or ``None``.
    :param version: the parsed version, or ``None`` if parsing failed.
    r   spec_stroperatorr   rL   is_wildcardr   wildcard_precisionzSimpleVersion | Noneversionc                   |j                         }t        j                  |      x}sd| }t        |      |j	                  d      }|j	                  d      j                         }|j                  d      }d}|r|dd }t        |j                  d            }	 t        j                  |      }	 | ||||||	      S # t        $ r d}	Y w xY w)	z~
        Parse a single PEP 440 specifier (e.g. ``>=3.10``).

        :param spec_str: the specifier string to parse.
        zInvalid specifier: r   r   z.*N.)rW   rX   r   rY   rZ   r[   )
r$   r   r%   r&   r'   endswithlensplitr   r,   )
r(   rW   r)   r%   r*   opr   rY   rZ   r[   s
             r+   r,   zSimpleSpecifier.from_string   s     >>#&,,X666'z2CS/![[^kk!n**,!**40)-%cr*K!$[%6%6s%;!<	#//<G ##1
 	
  	G	s   C   CCc                    	 t        |t              rt        j                  |      n|}| j
                  y| j                  r| j                  |      S | j                  |      S # t        $ r Y yw xY w)z~
        Check if a version string satisfies this specifier.

        :param version_str: the version string to test.
        F)	r0   r   r   r,   r&   r[   rY   _check_wildcard_check_standard)r3   r   	candidates      r+   containszSimpleSpecifier.contains   sr    	BL[Z]B^11+>doI <<''	22##I..  		s   'A$ $	A0/A0c                N   | j                   y| j                  dk(  r=|j                  d | j                   | j                   j                  d | j                   k(  S | j                  dk(  r=|j                  d | j                   | j                   j                  d | j                   k7  S y)NF==!=)r[   rX   r    rZ   )r3   rf   s     r+   rd   zSimpleSpecifier._check_wildcard   s    <<==D $$%>t'>'>?4<<CWCWXqZ^ZqZqCrrr==D $$%>t'>'>?4<<CWCWXqZ^ZqZqCrrrr-   c                   | j                   y| j                  dk(  r!t        |      t        | j                         k(  S | j                  dk(  r| j                  |      S t        j                  t        j
                  t        j                  t        j                  t        j                  t        j                  d}| j                  |v r  || j                     || j                         S y)NFz===z~=)ri   rj   <z<=>z>=)
r[   rX   r   _check_compatible_releaseeqneltlegtge)r3   rf   cmp_opss      r+   re   zSimpleSpecifier._check_standard   s    <<==E!y>S%666==D 11)<<++++++++
 ==G#)74==))T\\BBr-   c                @   | j                   y|| j                   k  ryt        | j                   j                        dk\  r_t        | j                   j                  d d       }|dxx   dz  cc<   t        j                  dj                  d |D                    }||k  S y)NFr   r   r^   c              3  2   K   | ]  }t        |        y wr/   )r   ).0ps     r+   	<genexpr>z<SimpleSpecifier._check_compatible_release.<locals>.<genexpr>   s     6S!s1v6Ss   T)r[   r`   r    listr   r,   join)r3   rf   upper_partsuppers       r+   rn   z)SimpleSpecifier._check_compatible_release   s    <<t||#t||##$)t||33CR89KOq O!--chh6S{6S.STEu$$r-   c                `    t        |t              st        S | j                  |j                  k(  S r/   )r0   rV   r1   rW   r2   s     r+   r5   zSimpleSpecifier.__eq__   s%    %1!!}}..r-   c                ,    t        | j                        S r/   )r7   rW   r8   s    r+   r9   zSimpleSpecifier.__hash__   s    DMM""r-   c                    | j                   S r/   rW   r8   s    r+   rE   zSimpleSpecifier.__str__   s    }}r-   c                "    d| j                    dS )NzSimpleSpecifier('rG   r   r8   s    r+   rH   zSimpleSpecifier.__repr__   s    "4==/44r-   N)rW   r   rI   rV   r   r   rI   rL   )rf   r   rI   rL   rJ   rM   rN   )rO   rP   rQ   rR   rS   rT   r,   rg   rd   re   rn   r5   r9   rE   rH   r=   r-   r+   rV   rV      se    	 MM""!!
 
</ &
/
#5r-   rV   c                  j    e Zd ZU dZded<   ded<   eddd       ZddZddZdd	Z	dd
Z
ddZddZy)SimpleSpecifierSetz
    Simple PEP 440-like specifier set using only standard library.

    :param specifiers_str: the original comma-separated specifier string.
    :param specifiers: the parsed individual specifiers.
    r   specifiers_strztuple[SimpleSpecifier, ...]
specifiersc                F   |j                         }g }|ro|j                  d      D ][  }|j                         }|st        j                  t              5  |j                  t        j                  |             ddd       ]  | |t        |            S # 1 sw Y   zxY w)z
        Parse a comma-separated PEP 440 specifier string (e.g. ``>=3.10,<4``).

        :param specifiers_str: the specifier string to parse.
        ,N)r   r   )	r$   ra   
contextlibsuppressr&   appendrV   r,   tuple)r(   r   r)   specs	spec_itemitems         r+   r,   zSimpleSpecifierSet.from_string  s     "'')')%^^C0 H	 (#,,Z8 H_%@%@%FGH HH
 (uU|DDH Hs   %BB 	c                Z    | j                   syt        fd| j                   D              S )z
        Check if a version satisfies all specifiers in the set.

        :param version_str: the version string to test.
        Tc              3  @   K   | ]  }|j                          y wr/   )rg   )ry   specr   s     r+   r{   z.SimpleSpecifierSet.contains.<locals>.<genexpr>  s     J$4==-Js   )r   all)r3   r   s    `r+   rg   zSimpleSpecifierSet.contains  s$     J$//JJJr-   c                ,    t        | j                        S r/   )iterr   r8   s    r+   __iter__zSimpleSpecifierSet.__iter__!  s    DOO$$r-   c                `    t        |t              st        S | j                  |j                  k(  S r/   )r0   r   r1   r   r2   s     r+   r5   zSimpleSpecifierSet.__eq__$  s*    %!34!!""e&:&:::r-   c                ,    t        | j                        S r/   )r7   r   r8   s    r+   r9   zSimpleSpecifierSet.__hash__)  s    D''((r-   c                    | j                   S r/   r   r8   s    r+   rE   zSimpleSpecifierSet.__str__,  s    """r-   c                "    d| j                    dS )NzSimpleSpecifierSet('rG   r   r8   s    r+   rH   zSimpleSpecifierSet.__repr__/  s    %d&9&9%:"==r-   N) )r   r   rI   r   r   )rI   zIterator[SimpleSpecifier]rJ   rM   rN   )rO   rP   rQ   rR   rS   rT   r,   rg   r   r5   r9   rE   rH   r=   r-   r+   r   r      sH     ++E E K%;
)#>r-   r   )rV   r   r   r=   )rR   
__future__r   r   rX   resysdataclassesr   typingr   r   version_info_DC_KWcollections.abcr   compileVERBOSEr   rS   r   r   r   rV   r   __all__r=   r-   r+   <module>r      s   Q "   	 
 ! '=@=M=MQX=XDTD	9_gim^n(&0bjj JJ
'# 
 )3

 JJ	)% 	 +,!1$=
! = VS6 S6 S6l Vv5 v5 v5r V5> 5> 5>pr-   