U
    |e                     @  s   d dl mZ d dlZd dlmZ ejdkr<d dlmZ dZn4d dl	mZm
Z
 edd	 e
d
ddd D ZG dd dZG dd deZddgZdS )    )annotationsN)OrderedDict)      )entry_points )r   versionc                 c  s   | ]}t |V  qd S N)int).0ir   r   >/tmp/pip-unpacked-wheel-tuxcr54r/virtualenv/run/plugin/base.py	<genexpr>   s     r   importlib_metadata.   c                   @  s,   e Zd ZdZdZedd Zedd ZdS )PluginLoaderNc                 C  sN   t jdkstdkr0tdd |  j|dD S tdd |  |i D S )N)r   
   )r      c                 s  s   | ]}|j | fV  qd S r	   nameloadr   er   r   r   r      s     z0PluginLoader.entry_points_for.<locals>.<genexpr>)groupc                 s  s   | ]}|j | fV  qd S r	   r   r   r   r   r   r      s     )sysversion_infoimportlib_metadata_versionr   r   selectgetclskeyr   r   r   entry_points_for   s    zPluginLoader.entry_points_forc                   C  s   t jd krt t _t jS r	   )r   _ENTRY_POINTSr   r   r   r   r   r      s    
zPluginLoader.entry_points)	__name__
__module____qualname___OPTIONSr$   classmethodr#   staticmethodr   r   r   r   r   r      s   
r   c                   @  sF   e Zd ZddddZedd Zdd Zd	d
 Zdd Zdd Z	dS )ComponentBuilderNone)returnc                 C  s<   || _ || _d | _|| _|j|d| _| |t| j d S )N)title)interpreterr   _impl_classpossibleadd_argument_groupparseradd_selector_arg_parselist)selfr/   r3   r   r1   r   r   r   __init__"   s    zComponentBuilder.__init__c                 C  s   | j d kr| || _ | j S r	   )r(   r#   r    r   r   r   options*   s    
zComponentBuilder.optionsc                 C  s   t d S r	   )NotImplementedError)r6   r   choicesr   r   r   r4   0   s    z'ComponentBuilder.add_selector_arg_parsec                 C  sH   t || j}|| jkr*d| j }t|| j| | _| ||j |S )NzNo implementation for )getattrr   r1   r/   RuntimeErrorr0   populate_selected_argparseapp_data)r6   r8   selectedmsgr   r   r   handle_selected_arg_parse3   s    
z*ComponentBuilder.handle_selected_arg_parsec                 C  s.   d| j  d| | j_| j| j| j| d S )Nzoptions for  )r   r3   descriptionr0   Zadd_parser_argumentsr/   )r6   r?   r>   r   r   r   r=   <   s    z+ComponentBuilder.populate_selected_argparsec                 C  s   |  || jS r	   )r0   r/   )r6   r8   r   r   r   create@   s    zComponentBuilder.createN)
r%   r&   r'   r7   r)   r8   r4   rA   r=   rD   r   r   r   r   r+   !   s   
	r+   )
__future__r   r   collectionsr   r   importlib.metadatar   r   r   r   tuplesplitr   r+   __all__r   r   r   r   <module>   s   
$$