o
    —‘£f”  ã                   @   sº   d 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	 ddl
mZ dgZe d¡Zd	d
hZdd„ Zdd„ Zdd„ ZG dd„ deƒZe d¡Zdd„ Zeƒ Z[eƒ Zddd„ZdS )zG
Parser for the environment markers micro-language defined in PEP 508.
é    Né   )Ústring_types)Úin_venvÚparse_marker)ÚLegacyVersionÚ	interpretz<((\d+(\.\d+)*\w*)|\'(\d+(\.\d+)*\w*)\'|\"(\d+(\.\d+)*\w*)\")Úpython_versionÚpython_full_versionc                 C   s   t | tƒo| tv S ©N)Ú
isinstancer   Ú_VERSION_MARKERS©Ús© r   úE/var/www/html/dev/env/lib/python3.10/site-packages/distlib/markers.pyÚ_is_version_marker   s   r   c                 C   s   t | tƒr| s	dS | d dv S )NFr   ú'")r   r   )Úor   r   r   Ú_is_literal#   s   r   c                 C   s   dd„ t  | ¡D ƒS )Nc                 S   s   h | ]
}t | ¡ d  ƒ’qS )r   )ÚLVÚgroups)Ú.0Úmr   r   r   Ú	<setcomp>*   s    z _get_versions.<locals>.<setcomp>)Ú_VERSION_PATTERNÚfinditerr   r   r   r   Ú_get_versions)   s   r   c                   @   sf   e Zd ZdZdd„ dd„ dd„ dd„ dd„ dd„ d	d„ d
d„ dd„ dd„ dd„ dd„ dœZdd„ ZdS )Ú	Evaluatorz<
    This class is used to evaluate marker expressions.
    c                 C   ó   | |kS r
   r   ©ÚxÚyr   r   r   Ú<lambda>3   ó    zEvaluator.<lambda>c                 C   r   r
   r   r   r   r   r   r"   4   r#   c                 C   ó   | |kp| |kS r
   r   r   r   r   r   r"   5   ó    c                 C   s   | |kS r
   r   r   r   r   r   r"   6   r#   c                 C   s   | |k S r
   r   r   r   r   r   r"   7   r#   c                 C   s   | |kp| |k S r
   r   r   r   r   r   r"   8   r%   c                 C   s   | |kS r
   r   r   r   r   r   r"   9   r#   c                 C   r$   r
   r   r   r   r   r   r"   :   r%   c                 C   s   | o|S r
   r   r   r   r   r   r"   ;   r#   c                 C   s   | p|S r
   r   r   r   r   r   r"   <   r#   c                 C   s   | |v S r
   r   r   r   r   r   r"   =   r#   c                 C   s   | |vS r
   r   r   r   r   r   r"   >   r#   )ú==ú===ú~=ú!=ú<ú<=ú>ú>=ÚandÚorÚinúnot inc           	      C   s"  t |tƒr#|d dv r|dd… }|S ||vrtd| ƒ‚|| }|S t |tƒs*J ‚|d }|| jvr9td| ƒ‚|d }|d	 }t|d ƒrVt|d	 ƒrVtd
|||f ƒ‚|  ||¡}|  ||¡}t|ƒsjt|ƒrw|dv rwt	|ƒ}t	|ƒ}nt|ƒr‡|dv r‡t	|ƒ}t
|ƒ}| j| ||ƒ}|S )zƒ
        Evaluate a marker expression returned by the :func:`parse_requirement`
        function in the specified context.
        r   r   r   éÿÿÿÿzunknown variable: %sÚopzop not implemented: %sÚlhsÚrhszinvalid comparison: %s %s %s)r*   r+   r,   r-   r'   r&   r)   r(   )r0   r1   )r   r   ÚSyntaxErrorÚdictÚ
operationsÚNotImplementedErrorr   Úevaluater   r   r   )	ÚselfÚexprÚcontextÚresultr3   ÚelhsÚerhsr4   r5   r   r   r   r:   A   s:   
èì
ÿ
zEvaluator.evaluateN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r8   r:   r   r   r   r   r   -   s     ôr   z\d+\.\d+c                  C   sŒ   dd„ } t tdƒr| tjjƒ}tjj}nd}d}t ¡ }t |¡}| 	d¡}||t
jt ¡ t ¡ t ¡ t ¡ t ¡ ttƒ ƒ||tjdœ}|S )Nc                 S   s<   d| j | j| jf }| j}|dkr||d t| jƒ 7 }|S )Nz%s.%s.%sÚfinalr   )ÚmajorÚminorÚmicroÚreleaselevelÚstrÚserial)ÚinfoÚversionÚkindr   r   r   Úformat_full_versionj   s
   z,default_context.<locals>.format_full_versionÚimplementationÚ0Ú r   )Úimplementation_nameÚimplementation_versionÚos_nameÚplatform_machineÚplatform_python_implementationÚplatform_releaseÚplatform_systemÚplatform_versionÚplatform_in_venvr	   r   Úsys_platform)ÚhasattrÚsysrP   rM   ÚnameÚplatformr   Ú_DIGITSÚmatchÚgroupÚosÚmachineÚpython_implementationÚreleaseÚsystemrJ   r   )rO   rT   rS   Úppvr   Úpvr>   r   r   r   Údefault_contexth   s2   
ÿ


ôrk   c              
   C   s|   zt | ƒ\}}W n ty } ztd| |f ƒ‚d}~ww |r-|d dkr-td| |f ƒ‚ttƒ}|r8| |¡ t ||¡S )zò
    Interpret a marker and return a result depending on environment.

    :param marker: The marker to interpret.
    :type marker: str
    :param execution_context: The context used for name lookup.
    :type execution_context: mapping
    z)Unable to interpret marker syntax: %s: %sNr   ú#z*unexpected trailing data in marker: %s: %s)r   Ú	Exceptionr6   r7   ÚDEFAULT_CONTEXTÚupdateÚ	evaluatorr:   )ÚmarkerÚexecution_contextr<   ÚrestÚer=   r   r   r   r   “   s    	ÿ€ÿÿ
r
   )rD   rd   Úrer^   r`   Úcompatr   Úutilr   r   rM   r   r   Ú__all__Úcompiler   r   r   r   r   Úobjectr   ra   rk   rn   rp   r   r   r   r   r   Ú<module>   s.   ÿ
8%