o
    Ch9                     @  s   d Z ddlmZ ddlZddlmZmZ ddlmZ ddl	m
Z
mZmZ ddlmZmZ ddlmZmZmZ G d	d
 d
ZG dd dZG dd deZG dd deeZG dd deZG dd deeZg dZdS )aG  
Virtual environments in the traditional sense are built as reference to the host python. This file allows declarative
references to elements on the file system, allowing our system to automatically detect what modes it can support given
the constraints: e.g. can the file system symlink, can the files be read, executed, etc.
    )annotationsN)ABCabstractmethod)OrderedDict)S_IXGRPS_IXOTHS_IXUSR)fs_is_case_sensitivefs_supports_symlink)copymake_exesymlinkc                   @     e Zd ZdZdZdZdS )RefMustNAr   r   N)__name__
__module____qualname__r   COPYSYMLINK r   r   ~/var/www/html/myvaluetrips/my_value_trip_new/venv/lib/python3.10/site-packages/virtualenv/create/via_global_ref/builtin/ref.pyr          r   c                   @  r   )RefWhenANYr   r   N)r   r   r   r   r   r   r   r   r   r   r      r   r   c                   @  sr   e Zd ZdZe Ze Zej	e
jfdddZdddZed	d
 Zedd Zedd Zedd Zdd ZdS )PathRefzABase class that checks if a file reference can be symlink/copied.returnNonec                 C  st   || _ || _|| _z| | _W n ty   d| _Y nw | jr"d nd| _| jr*d nd| _| jr5d | _d S d| _d S NF)mustwhensrcexistsOSError	_can_read	_can_copy_can_symlinkselfr!   r   r    r   r   r   __init__$   s   
zPathRef.__init__strc                 C  s   | j j d| j dS )N(src=))	__class__r   r!   r(   r   r   r   __repr__0   s   zPathRef.__repr__c                 C  s   | j d u rE| j r:z!| jd d| _ W d    n1 sw   Y  W | j S W | j S  ty9   d| _ Y | j S w tt| jtj| _ | j S )NrbTF)	r$   r!   is_fileopenr#   osaccessr*   R_OKr.   r   r   r   can_read3   s   

zPathRef.can_readc                 C  s2   | j d u r| jtjkr| j| _ | j S | j| _ | j S N)r%   r   r   r   can_symlinkr6   r.   r   r   r   can_copy@   s   
zPathRef.can_copyc                 C  s8   | j d u r| jtjkr| j| _ | j S | jo| j| _ | j S r7   )r&   r   r   r   r9   FS_SUPPORTS_SYMLINKr6   r.   r   r   r   r8   I   s   
zPathRef.can_symlinkc                 C  s   t r7   )NotImplementedError)r(   creatorsymlinksr   r   r   runR   s   zPathRef.runc                 C  s,   | j tjkrtS | j tjkrtS |rtS tS r7   )r   r   r   r   r   r   )r(   r=   r   r   r   methodV   s
   zPathRef.methodNr   r   r   r*   )r   r   r   __doc__r
   r:   r	   FS_CASE_SENSITIVEr   r   r   r   r)   r/   propertyr6   r9   r8   r   r>   r?   r   r   r   r   r      s    




r   c                      sD   e Zd ZdZejejfd
 fddZe	dd Z
e	dd	 Z  ZS )
ExePathRefzJBase class that checks if a executable can be references via symlink/copy.r   r   c                   s   t  ||| d | _d S r7   )superr)   _can_runr'   r-   r   r   r)   a      
zExePathRef.__init__c                 C  s   | j r| jS dS r   )r:   can_runr.   r   r   r   r8   e   s   zExePathRef.can_symlinkc                 C  sF   | j d u r | j j}tttfD ]}||@ rd| _  | j S d| _ | j S )NTF)rG   r!   statst_moder   r   r   )r(   modekeyr   r   r   rJ   k   s   
zExePathRef.can_runr@   )r   r   r   rB   r   r   r   r   r)   rD   r8   rJ   __classcell__r   r   rH   r   rE   ^   s    
rE   c                      s4   e Zd ZdZejejfd fddZdd Z	  Z
S )	PathRefToDestzLink a path on the file system.r   r   c                   s   t  ||| || _d S r7   )rF   r)   dest)r(   r!   rQ   r   r    rH   r   r   r)   {   rI   zPathRefToDest.__init__c                 C  s`   |  || j}| |}t|tr|n|f}|j s#|jjddd |D ]}|| j| q%d S )NT)parentsexist_ok)rQ   r!   r?   
isinstancelistparentr"   mkdir)r(   r<   r=   rQ   r?   dest_iterabledstr   r   r   r>      s   

zPathRefToDest.runr@   )r   r   r   rB   r   r   r   r   r)   r>   rO   r   r   rH   r   rP   x   s    rP   c                   @  s6   e Zd ZdZejejfdddZdd Z	dd	d
Z
dS )ExePathRefToDestz#Link a exe path on the file system.r   r   c                 C  sd   t | ||| t| |||| | js!ttdd |D  }|d | _|dd  | _|| _	d S )Nc                 s  s    | ]	}|  d fV  qd S r7   )lower).0ir   r   r   	<genexpr>   s    z,ExePathRefToDest.__init__.<locals>.<genexpr>r      )
rE   r)   rP   rC   rU   r   keysbasealiasesrQ   )r(   r!   targetsrQ   r   r    r   r   r   r)      s   

zExePathRefToDest.__init__c                 C  s   |  || jj}|| j }| |}|| j| |st| | jD ]#}|| }| r/|  |r8|	| j nt
| j| |sDt| q!d S r7   )rQ   r!   rV   ra   r?   r   rb   r"   unlink
symlink_tor   )r(   r<   r=   bin_dirrQ   r?   extra	link_filer   r   r   r>      s"   


zExePathRefToDest.runr*   c                 C  s   | j j d| j d| j dS )Nr+   z, alias=r,   )r-   r   r!   rb   r.   r   r   r   r/      s   zExePathRefToDest.__repr__Nr@   rA   )r   r   r   rB   r   r   r   r   r)   r>   r/   r   r   r   r   rZ      s
    	rZ   )rE   rZ   r   rP   r   r   )rB   
__future__r   r3   abcr   r   collectionsr   rK   r   r   r   virtualenv.infor	   r
   virtualenv.util.pathr   r   r   r   r   r   rE   rP   rZ   __all__r   r   r   r   <module>   s    @"