o
    Th,                     @   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   c/var/www/html/construction_image-detection-poc/venv/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>2       zEvaluator.<lambda>c                 C   r   r
   r   r   r   r   r   r"   3   r#   c                 C      | |kp| |kS r
   r   r   r   r   r   r"   4       c                 C   s   | |kS r
   r   r   r   r   r   r"   5   r#   c                 C   s   | |k S r
   r   r   r   r   r   r"   6   r#   c                 C   s   | |kp| |k S r
   r   r   r   r   r   r"   7   r%   c                 C   s   | |kS r
   r   r   r   r   r   r"   8   r#   c                 C   r$   r
   r   r   r   r   r   r"   9   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 rt	|}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:   @   s6   


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_versionh   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_contextf   s.   



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*   

7$