o
    Uh                     @  sB   d Z ddlmZ ddlZddlZedZG dd dZdgZdS )zOA Python specification is an abstract requirement definition of an interpreter.    )annotationsNzP^(?P<impl>[a-zA-Z]+)?(?P<version>[0-9.]+)?(?P<threaded>t)?(?:-(?P<arch>32|64))?$c                   @  sV   e Zd ZdZddd"ddZed#ddZd$ddZedd Z	dd Z
d%d d!ZdS )&
PythonSpecz2Contains specification about a Python Interpreter.Nfree_threadedstr_specstrimplementation
str | Nonemajor
int | Noneminormicroarchitecturepathr   bool | NonereturnNonec          	      C  s4   || _ || _|| _|| _|| _|| _|| _|| _d S N)r   r   r
   r   r   r   r   r   )	selfr   r   r
   r   r   r   r   r    r   p/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/virtualenv/discovery/py_spec.py__init__   s   
zPythonSpec.__init__string_specc              
   C  sV  d\}}}}}}}t j|r|}nd}	tt|}
|
rdd }za|
 }|d }|d ur~tdd |dD }t	|d	krAt
t	|d	krM|\}}}n+t	|d
krX|\}}n t	|dkrx|d }tt|d }|dkrxtt|dd  }t|d }d}	W n	 t
y   Y nw |d }|dv rd }||d }|	s|}| ||||||||dS )N)NNNNNNNFc                 S  s   | d u rd S t | S r   int)valr   r   r   _int_or_none-   s   z1PythonSpec.from_string_spec.<locals>._int_or_noneversionc                 s  s    | ]	}|rt |V  qd S r   r   ).0ir   r   r   	<genexpr>4   s    z.PythonSpec.from_string_spec.<locals>.<genexpr>.         r   	   threadedTimpl>   pypythonarchr   )osr   isabsrematchPATTERN	groupdicttuplesplitlen
ValueErrorr   r   bool)clsr   r'   r
   r   r   r&   r*   r   okr.   r   groupsr   versionsversion_datar   r   r   from_string_spec#   sF   
zPythonSpec.from_string_specwindowsr5   
re.Patternc             
   C  s   dj dd | j| j| jfD  }| jdu rdndt| j }| jr%dnd}|r+d	nd}|s4| jdu r6d
nd}tjd| d| | d| | d	tj	dS )z>Generate a regular expression for matching against a filename.z{}(\.{}(\.{})?)?c                 s  s     | ]}|d u r
dn|V  qd S )Nz\d+r   )r   vr   r   r   r    R   s    z)PythonSpec.generate_re.<locals>.<genexpr>Nr)   zpython|zt? z\.exe?z	(?P<impl>z)(?P<v>)$)flags)
formatr
   r   r   r   r-   escaper   compile
IGNORECASE)r   r<   r   r'   modsuffixversion_conditionalr   r   r   generate_reO   s     
	zPythonSpec.generate_rec                 C  s   | j d uotj | j S r   )r   r+   r,   r   r   r   r   is_abse   s   zPythonSpec.is_absc                 C  s   |j r| j r| j|jkrdS |jdur|j | j krdS |jdur,|j| jkr,dS |jdur9|j| jkr9dS t| j| j| j	f|j|j|j	fD ]\}}|dur]|dur]||kr] dS qJdS )z]Called when there's a candidate metadata spec to see if compatible - e.g. PEP-514 on Windows.FNT)
rM   r   r   lowerr   r   zipr
   r   r   )r   specourreqr   r   r   	satisfiesi   s   *zPythonSpec.satisfiesc                   s2   t  j}d}| dd fdd|D  dS )N)r   r
   r   r   r   r   r   (z, c                 3  s2    | ]}t  |d ur| dt  | V  qd S )N=)getattr)r   krL   r   r   r    |   s   0 z&PythonSpec.__repr__.<locals>.<genexpr>rA   )type__name__join)r   nameparamsr   rL   r   __repr__y   s   
$zPythonSpec.__repr__)r   r   r   r	   r
   r   r   r   r   r   r   r   r   r	   r   r   r   r   )r   r   )r<   r5   r   r=   )r   r   )rY   
__module____qualname____doc__r   classmethodr;   rK   propertyrM   rS   r]   r   r   r   r   r      s    
+
r   )	r`   
__future__r   r+   r-   rF   r/   r   __all__r   r   r   r   <module>   s    
u