o
    $¼"b±  ã                   @   sH   d dl mZmZ d dlmZ d dlmZ ddlmZ G dd„ deƒZ	dS )	é    )Úabsolute_importÚunicode_literals)ÚArgumentTypeError)ÚOrderedDicté   )ÚComponentBuilderc                       s<   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Z‡  ZS )ÚActivationSelectorc                    sN   d | _ t‡ fdd„|  d¡ ¡ D ƒƒ}tt| ƒ ˆ |d|¡ d| j_d | _	d S )Nc                 3   s&   � | ]\}}|  ˆ ¡r||fV  qd S )N)Úsupports©Ú.0ÚkÚv©Úinterpreter© úB/usr/lib/python3/dist-packages/virtualenv/run/plugin/activators.pyÚ	<genexpr>   s   € ÿ
ÿz.ActivationSelector.__init__.<locals>.<genexpr>zvirtualenv.activateÚ
activatorszoptions for activation scripts)
Údefaultr   ÚoptionsÚitemsÚsuperr   Ú__init__ÚparserÚdescriptionÚactive)Úselfr   r   Úpossible©Ú	__class__r   r   r   
   s   ÿ
zActivationSelector.__init__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ÚformatÚ_extract_activators)r   ÚnameÚchoicesr   r   r   Úadd_selector_arg_parse   s   
úz)ActivationSelector.add_selector_arg_parsec                    sB   dd„ |  d¡D ƒ}‡ fdd„|D ƒ}|rtd d |¡¡ƒ‚|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   r.   ©r   r   r   r0       s    z-the following activators are not available {})Úsplitr   r(   r&   )r   Úentered_strÚelementsÚmissingr   r1   r   r)      s
   z&ActivationSelector._extract_activatorsc                    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>)   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   r)   r   r   r   r   r'   ÚvaluesÚadd_parser_argumentsr   )r   r   Ú	activatorr   r6   r   Úhandle_selected_arg_parse%   s   ÿø
ÿz,ActivationSelector.handle_selected_arg_parsec                    s   ‡ fdd„| j  ¡ D ƒS )Nc                    s   g | ]}|ˆ ƒ‘qS r   r   )r   Úactivator_class©r   r   r   r0   8   s    z-ActivationSelector.create.<locals>.<listcomp>)r   r;   )r   r   r   r@   r   Úcreate7   s   zActivationSelector.create)	Ú__name__Ú
__module__Ú__qualname__r   r,   r)   r>   rA   Ú__classcell__r   r   r   r   r   	   s    	r   N)
Ú
__future__r   r   Úargparser   Úcollectionsr   Úbaser   r   r   r   r   r   Ú<module>   s
    