U
    ]                     @   sf   d Z ddlZddlZddlmZ ddlmZ ddlmZ	 e
eZejjZdd Zdd	 Zd
eiZdS )zCertbot Enhancement Display    N)errors)
interfaces)utilc                 C   s<   zt |   W S  tk
r6   td|  tdY nX dS )a!  Display the enhancement to the user.

    :param str enhancement: One of the
        :class:`certbot.CONFIG.ENHANCEMENTS` enhancements

    :returns: True if feature is desired, False otherwise
    :rtype: bool

    :raises .errors.Error: if the enhancement provided is not supported

    z*Unsupported enhancement given to ask(): %szUnsupported EnhancementN)DISPATCHKeyErrorloggererrorr   Error)Zenhancement r
   >/usr/lib/python3/dist-packages/certbot/display/enhancements.pyask   s
    r   c                  C   s<   ddg} t tjjd| dddd\}}|tjkr4dS |d	kS )
zDetermines whether the user would like to redirect to HTTPS.

    :returns: True if redirect is desired, False otherwise
    :rtype: bool

    )zNo redirectz7Make no further changes to the webserver configuration.)ZRedirectzMake all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration.zUPlease choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.r   z--redirect / --no-redirectT)defaultZcli_flagZforce_interactiveF   )r   r   ZIDisplayZmenudisplay_utilZOK)choicescodeZ	selectionr
   r
   r   redirect_by_default%   s    
  

r   Zredirect)__doc__ZloggingZzope.componentzopeZcertbotr   r   Zcertbot.displayr   r   Z	getLogger__name__r   Z	componentZ
getUtilityr   r   r   r
   r
   r
   r   <module>   s   
 