o
    6a%                     @   sj  d Z ddlZ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 ddlm	Z	 ddl
Z
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 ddlmZ ddlmZ ejZ	 ejZ	 dZdZ	 dZ	 deddfddZ		d6dedededededdfddZ		d7ded e	ee eeef f d!ee d"ee dedeeef fd#d$Z		d7ded!ee d"ee dedeeef f
d%d&Z 	(		d8ded)ed*ed!ee d"ee dedefd+d,Z!			d7ded-ee d!ee d"ee dedeeee f fd.d/Z"		d7ded!ee d"ee dedeeef f
d0d1Z#d2d3 Z$G d4d5 d5Z%eee%ej&e' ej&e'< dS )9a$  Certbot display.

This module (`certbot.display.util`) or its companion `certbot.display.ops`
should be used whenever:

- Displaying status information to the user on the terminal
- Collecting information from the user via prompts

Other messages can use the `logging` module. See `log.py`.

    N)
ModuleType)cast)List)Optional)Tuple)Union)FileDisplay)NoninteractiveDisplay)
SIDE_FRAME)input_with_timeout)separate_list_input)summarize_domain_list)objH   helpescmsgreturnc                 C   s   t  j| dddd dS )zMDisplay a basic status message.

    :param str msg: message to display

    F)pausedecoratewrapNr   get_displaynotification)r    r   6/usr/lib/python3/dist-packages/certbot/display/util.pynotify5   s   r   TFmessager   r   force_interactiver   c                 C   s   t  j| ||||d dS )a  Displays a notification and waits for user acceptance.

    :param str message: Message to display
    :param bool pause: Whether or not the program should pause for the
        user's confirmation
    :param bool wrap: Whether or not the application should wrap text
    :param bool force_interactive: True if it's safe to prompt the user
        because it won't cause any workflow regressions
    :param bool decorate: Whether to surround the message with a
        decorated frame

    )r   r   r   r   Nr   )r   r   r   r   r   r   r   r   r   >   s   
r   choicesdefaultcli_flagc                 C      t  j| ||||dS )a	  Display a menu.

    .. todo:: This doesn't enable the help label/button (I wasn't sold on
        any interface I came up with for this). It would be a nice feature.

    :param str message: title of menu
    :param choices: Menu lines, len must be > 0
    :type choices: list of tuples (tag, item) or
        list of descriptions (tags will be enumerated)
    :param default: default value to return (if one exists)
    :param str cli_flag: option used to set this value with the CLI
    :param bool force_interactive: True if it's safe to prompt the user
        because it won't cause any workflow regressions

    :returns: tuple of (`code`, `index`) where
        `code` - str display exit code
        `index` - int index of the user's selection

    :rtype: tuple

    r    r!   r   )r   r   menu)r   r   r    r!   r   r   r   r   r$   P   s   r$   c                 C      t  j| |||dS )a  Accept input from the user.

    :param str message: message to display to the user
    :param default: default value to return (if one exists)
    :param str cli_flag: option used to set this value with the CLI
    :param bool force_interactive: True if it's safe to prompt the user
        because it won't cause any workflow regressions

    :returns: tuple of (`code`, `input`) where
        `code` - str display exit code
        `input` - str of the user's input
    :rtype: tuple

    r#   )r   r   inputr   r    r!   r   r   r   r   
input_textl   s   r(   YesNo	yes_labelno_labelc                 C   s   t  j| |||||dS )an  Query the user with a yes/no question.

    Yes and No label must begin with different letters, and must contain at
    least one letter each.

    :param str message: question for the user
    :param str yes_label: Label of the "Yes" parameter
    :param str no_label: Label of the "No" parameter
    :param default: default value to return (if one exists)
    :param str cli_flag: option used to set this value with the CLI
    :param bool force_interactive: True if it's safe to prompt the user
        because it won't cause any workflow regressions

    :returns: True for "Yes", False for "No"
    :rtype: bool

    )r+   r,   r    r!   r   )r   r   yesno)r   r+   r,   r    r!   r   r   r   r   r-      s   r-   tagsc                 C   r"   )a  Display a checklist.

    :param str message: Message to display to user
    :param list tags: `str` tags to select, len(tags) > 0
    :param default: default value to return (if one exists)
    :param str cli_flag: option used to set this value with the CLI
    :param bool force_interactive: True if it's safe to prompt the user
        because it won't cause any workflow regressions

    :returns: tuple of (`code`, `tags`) where
        `code` - str display exit code
        `tags` - list of selected tags
    :rtype: tuple

    r#   )r   r   	checklist)r   r.   r    r!   r   r   r   r   r/      s   r/   c                 C   r%   )a  Display a directory selection screen.

    :param str message: prompt to give the user
    :param default: default value to return (if one exists)
    :param str cli_flag: option used to set this value with the CLI
    :param bool force_interactive: True if it's safe to prompt the user
        because it won't cause any workflow regressions

    :returns: tuple of the form (`code`, `string`) where
        `code` - display exit code
        `string` - input entered by the user

    r#   )r   r   directory_selectr'   r   r   r   r0      s   r0   c                 C   s8   d | }|r|d |7 }|dus|sJ |dS dS )a0  Verify that provided arguments is a valid display call.

    :param str prompt: prompt for the user
    :param default: default answer to prompt
    :param str cli_flag: command line option for setting an answer
        to this question
    :param bool force_interactive: if interactivity is forced

    z)Invalid display call for this prompt:
{0}z7
You can set an answer to this prompt with the {0} flagN)format)promptr    r!   r   r   r   r   r   assert_valid_call   s   

r3   c                   @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )_DisplayUtilDeprecationModulez
    Internal class delegating to a module, and displaying warnings when attributes
    related to deprecated attributes in the certbot.display.util module.
    c                 C   s   || j d< d S N_module)__dict__)selfmoduler   r   r   __init__   s   z&_DisplayUtilDeprecationModule.__init__c                 C   s*   |dv rt jd|tdd t| j|S )N)	r   r	   r
   r   r   r   WIDTHHELPESCzT{0} attribute in certbot.display.util module is deprecated and will be removed soon.   )
stacklevel)warningswarnr1   DeprecationWarninggetattrr6   r8   attrr   r   r   __getattr__   s   z)_DisplayUtilDeprecationModule.__getattr__c                 C   s   t | j|| d S N)setattrr6   )r8   rE   valuer   r   r   __setattr__   s   z)_DisplayUtilDeprecationModule.__setattr__c                 C   s   t | j| d S rG   )delattrr6   rD   r   r   r   __delattr__      z)_DisplayUtilDeprecationModule.__delattr__c                 C   s   dgt | j S r5   )dirr6   )r8   r   r   r   __dir__   rM   z%_DisplayUtilDeprecationModule.__dir__N)	__name__
__module____qualname____doc__r:   rF   rJ   rL   rO   r   r   r   r   r4      s    r4   )TTFT)NNF)r)   r*   NNF)(rS   systypesr   typingr   r   r   r   r   r@   certbot._internal.display.objr   r	   r
   certbot._internal.display.utilr   r   r   certbot._internal.displayr   OKCANCELr;   r<   r=   strr   boolr   intr$   r(   r-   r/   r0   r3   r4   modulesrP   r   r   r   r   <module>   s    	
 







