o
    WiJ                     @  s   d dl mZ d dlmZ d dlmZ d dlmZ ddlm	Z	 er:d dl
mZ d dlmZ d d	lmZ d d
lmZmZ G dd de	ZdgZdS )    )annotations)ArgumentTypeError)OrderedDict)TYPE_CHECKING   )ComponentBuilder)Sequence)
PythonInfo)	Activator)VirtualEnvConfigParserVirtualEnvOptionsc                      sF   e Zd Zd fddZdddZdddZdddZdddZ  ZS )ActivationSelectorinterpreterr	   parserr   returnNonec                   sJ   d | _ t fdd| d D }t  |d| d| j_d | _d S )Nc                 3  s&    | ]\}}|  r||fV  qd S )N)supports.0kvr    T/home/ubuntu/.local/lib/python3.10/site-packages/virtualenv/run/plugin/activators.py	<genexpr>   s    
z.ActivationSelector.__init__.<locals>.<genexpr>zvirtualenv.activate
activatorszoptions for activation scripts)	defaultr   optionsitemssuper__init__r   descriptionactive)selfr   r   possible	__class__r   r   r       s   
zActivationSelector.__init__namestrchoicesSequence[str]c                 C  s2   d || _| jjd| | jddd| jd d S )N,z--comma_sep_listFz1activators to generate - default is all supported)r   metavarrequiredhelptype)joinr   r   add_argument_extract_activators)r#   r'   r)   r   r   r   add_selector_arg_parse   s   
z)ActivationSelector.add_selector_arg_parseentered_str	list[str]c                   sF   dd | dD } fdd|D }|r!dd| }t||S )Nc                 S  s   g | ]
}|  r|  qS r   )stripr   er   r   r   
<listcomp>*   s    z:ActivationSelector._extract_activators.<locals>.<listcomp>r+   c                   s   g | ]	}| j vr|qS r   )r$   r8   r#   r   r   r:   +   s    z+the following activators are not available )splitr1   r   )r#   r5   elementsmissingmsgr   r;   r   r3   )   s   z&ActivationSelector._extract_activatorsr   r   c                   sr   |j | ju r| | jn|j   fdd| j D | _| jjddddd d | j D ]
}|	| j| j
 q,d S )Nc                   s   i | ]\}}| v r||qS r   r   r   selected_activatorsr   r   
<dictcomp>5   s    z@ActivationSelector.handle_selected_arg_parse.<locals>.<dictcomp>z--promptpromptzsprovides an alternative prompt prefix for this environment (value of . means name of the current working directory))destr-   r/   r   )r   r   r3   r$   r   r"   r   r2   valuesadd_parser_argumentsr   )r#   r   	activatorr   r@   r   handle_selected_arg_parse1   s   
z,ActivationSelector.handle_selected_arg_parselist[Activator]c                   s&   | j d usJ  fdd| j  D S )Nc                   s   g | ]}| qS r   r   )r   activator_classr   r   r   r:   E   s    z-ActivationSelector.create.<locals>.<listcomp>)r"   rE   )r#   r   r   rK   r   createC   s   zActivationSelector.create)r   r	   r   r   r   r   )r'   r(   r)   r*   r   r   )r5   r(   r   r6   )r   r   r   r   )r   r   r   rI   )	__name__
__module____qualname__r    r4   r3   rH   rL   __classcell__r   r   r%   r   r      s    


r   N)
__future__r   argparser   collectionsr   typingr   baser   collections.abcr   python_discoveryr	   virtualenv.activation.activatorr
   virtualenv.config.cli.parserr   r   r   __all__r   r   r   r   <module>   s    7