U
    ÔZjy  ã                   @   sP   d Z ddlZddlZddlmZ ddlm  mZ	 e 
e¡Zdd„ Zdd„ ZdS )z)Contains UI methods for Nginx operations.é    N)Ú
interfacesc                 C   sj   | s
t ƒ S dd„ | D ƒ}|r0|d dd… |d< tj tj¡jd|dd�\}}|tjkrft	|| ƒ}|S g S )zðSelect multiple Vhosts to install the certificate for
    :param vhosts: Available Nginx VirtualHosts
    :type vhosts: :class:`list` of type `~obj.Vhost`
    :returns: List of VirtualHosts
    :rtype: :class:`list`of type `~obj.Vhost`
    c                 S   s   g | ]}|  ¡ d  ‘qS )Ú
)Údisplay_repr)Ú.0Úvhost© r   ú\/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/certbot_nginx/display_ops.pyÚ
<listcomp>   s     z)select_vhost_multiple.<locals>.<listcomp>éÿÿÿÿNz-Which server blocks would you like to modify?T)ÚtagsÚforce_interactive)
ÚlistÚzopeÚ	componentZ
getUtilityr   ZIDisplayZ	checklistÚdisplay_utilÚOKÚ_reversemap_vhosts)ÚvhostsZ	tags_listÚcodeÚnamesÚreturn_vhostsr   r   r   Úselect_vhost_multiple   s     þ


r   c                 C   s<   t ƒ }| D ],}|D ]"}| ¡  ¡ | ¡ kr| |¡ qq
|S )zmHelper function for select_vhost_multiple for mapping string
    representations back to actual vhost objects)r   r   ÚstripÚappend)r   r   r   Z	selectionr   r   r   r   r   #   s    r   )Ú__doc__ÚloggingZzope.componentr   Zcertbotr   Zcertbot.display.utilÚdisplayÚutilr   Ú	getLoggerÚ__name__Úloggerr   r   r   r   r   r   Ú<module>   s   
