JFIF$        dd7 

Viewing File: /usr/lib/python3.9/site-packages/certbot/_internal/display/__pycache__/obj.cpython-39.opt-1.pyc

a

}|�g4X�@s0dZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZe�e�ZdZdZdZGdd�d�Ze�Ze
d�ZGdd�d�ZGdd�d�Zeeefd�dd�Z eeefdd�dd�Z!dS) zFThis modules define the actual display implementations used in Certbot�N)�Any)�Iterable)�List)�Optional)�TextIO)�Tuple)�TypeVar)�Union)�errors)�	constants)�	completer)�util)�os�ok�cancelzO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -c@seZdZdd�dd�ZdS)�_DisplayServiceN��returncCs
d|_dS�N��display)�self�r�A/usr/lib/python3.9/site-packages/certbot/_internal/display/obj.py�__init__)sz_DisplayService.__init__)�__name__�
__module__�__qualname__rrrrrr(sr�Tc
s�eZdZdZeedd��fdd�Zd*eeeeedd�d	d
�Zd+ee	e
eeefe
efeeeeeeee
eeeeeee
fd�
dd
�Zd,eeeeeeeeeefd�dd�Zd-eeeeeeeeeed�dd�Zd.ee
eee
eeeeeeee
efd�dd�Zeeeeeeeed�dd�Zeed�dd�Zd/eeeeeeeeeefd�dd �Zee	ee
fe
ee
ed!�d"d#�Zee	e
eeefe
efdd$�d%d&�Ze
eee
fd'�d(d)�Z�ZS)0�FileDisplayzFile-based display.N)�outfile�force_interactivercs t���||_||_d|_dS)NF)�superrr r!�skipped_interaction)rr r!��	__class__rrr6s
zFileDisplay.__init__TF)�message�pause�wrapr!�decoratercCs~|rt�|�}t�d|�|j�|r(dndd|r6dndjtjt	|d��|j�
�|rz|�|�rpt�d�n
t�d�d	S)
aDisplays 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

        �Notifying user: %s�{line}{frame}{line}��{msg}{line}�
{frame}{line}��line�frame�msgzPress Enter to Continuez!Not pausing for user confirmationN)
r
�
wrap_lines�logger�debugr �write�formatr�linesep�
SIDE_FRAME�flush�
_can_interact�input_with_timeout)rr&r'r(r!r)rrr�notification<s"

�
���

zFileDisplay.notification)
r&�choices�ok_label�cancel_label�
help_label�default�cli_flagr!�
unused_kwargsrc	
KsJ|�||||�}
|
dur t|
fS|�||�|�t|��\}}||dfS)aCDisplay 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

        N�)�_return_default�OK�_print_menu�_get_valid_int_ans�len)
rr&r>r?r@rArBrCr!rD�return_default�code�	selectionrrr�menu]szFileDisplay.menu)r&rBrCr!rDrcKsT|�||||�}|dur t|fSt�d|�d}t�|�}|dvrLtdfSt|fS)aAccept 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

        Nz%s (Enter 'c' to cancel):� )�c�Cz-1)rFrGr
r3r<�CANCEL)rr&rBrCr!rDrK�ansrrr�input�s
zFileDisplay.input�Yes�No)r&�	yes_label�no_labelrBrCr!rDrc
Ks�|�||||�}|dur|St�|�}|j�djtjttj|d��|j�	�t�
djt�|�t�|�d��}	|	�|d�
��s�|	�|d���r�dS|	�|d�
��s�|	�|d���rPdSqPdS)	a�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

        Nz{0}{frame}{msg}{0}{frame})r1r2z{yes}/{no}: )Zyes�norTF)rFr
r3r r6r7rr8r9r:r<Zparens_around_char�
startswith�lower�upper)
rr&rWrXrBrCr!rDrKrSrrr�yesno�s(

�
���zFileDisplay.yesno)r&�tagsrBrCr!rDrcKs�|�||||�}|dur t|fS|�||�|jddd�\}}	|tkr�|	��spd�dd�tdt|�d�D��}	t�	|	�}
|�
|
|�}|r�||fS|j�d	t
j�|j��q |gfSq dS)
aCDisplay 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

        NzrSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shownT)r!rOcss|]}t|�VqdSr)�str)�.0�xrrr�	<genexpr>��z(FileDisplay.checklist.<locals>.<genexpr>rEz!** Error - Invalid selection **%s)rFrGrHrT�strip�join�rangerJr
Zseparate_list_input�_scrub_checklist_inputr r6rr8r:)rr&r^rBrCr!rDrKrLrS�indicesZ
selected_tagsrrr�	checklist�s&�
"
�zFileDisplay.checklist)�promptrBrCr!rcCsN|�|�rdS|dur<d�|�}|r2|d�|�7}t�|��t�d||�|S)a�Should we return the default instead of prompting the user?

        :param str prompt: prompt for the user
        :param T 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

        :returns: The default value if we should return it else `None`
        :rtype: T or `None`

        Nz-Unable to get an answer for the question:
{0}zA
You can provide an answer on the command line with the {0} flag.z-Falling back to default %s for the prompt:
%s)r;r7r
�Errorr4r5)rrjrBrCr!r2rrrrF�s 

��
�zFileDisplay._return_default)r!rcCs@|js|stj��r"|j��r"dS|js<t�dtj	�d|_dS)z�Can we safely interact with the user?

        :param bool force_interactive: if interactivity is forced

        :returns: True if the display can interact with the user
        :rtype: bool

        Tz�Skipped user interaction because Certbot doesn't appear to be running in a terminal. You should probably include --non-interactive or %s on the command line.F)
r!�sys�stdin�isattyr r#r4ZwarningrZFORCE_INTERACTIVE_FLAG)rr!rrrr;s	
���zFileDisplay._can_interactcKs<t��� |�||||�Wd�S1s.0YdS)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

        N)rZ	CompleterrT)rr&rBrCr!rDrrr�directory_select's
zFileDisplay.directory_select)rhr^rcstzdd�|D�}Wnty(gYS0tt�|����}|D] }|dksX|t��kr@gSq@�fdd�|D�S)z�Validate input and transform indices to appropriate tags.

        :param list indices: input
        :param list tags: Original tags of the checklist

        :returns: valid tags the user selected
        :rtype: :class:`list` of :class:`str`

        cSsg|]}t|��qSr)�int�r`�indexrrr�
<listcomp>Grcz6FileDisplay._scrub_checklist_input.<locals>.<listcomp>rEcsg|]}�|d�qS)rErrq�r^rrrsTrc)�
ValueError�list�dict�fromkeys�keysrJ)rrhr^Zindices_intrrrrtrrg:s

z"FileDisplay._scrub_checklist_input)r&r>rcCs�|r t|dt�r dd�|D�}|j�tj�|�tj���|j�ttj�t|d�D]6\}}|�d|��}|j�t�	|��|j�tj�qX|j�ttj�|j�
�dS)z�Print a menu on the screen.

        :param str message: title of menu
        :param choices: Menu lines
        :type choices: list of tuples (tag, item) or
            list of descriptions (tags will be enumerated)

        rcSs"g|]}|d�d|d���qS)rz - rEr)r`rPrrrrsbrcz+FileDisplay._print_menu.<locals>.<listcomp>rEz: N)�
isinstance�tupler r6rr8r9�	enumerater
r3r:)rr&r>�iZdescr2rrrrHVszFileDisplay._print_menu)�max_rcCs�d}|dkrdj|d�}nd}|dkr�t�|�}|�d�sD|�d�rLtdfSz$t|�}|dksf||krnd}t�Wqty�|j�d�t	j
��|j��Yq0qt|fS)	a5Get a numerical selection.

        :param int max: The maximum entry (len of choices), must be positive

        :returns: tuple of the form (`code`, `selection`) where
            `code` - str display exit code ('ok' or cancel')
            `selection` - int user's selection
        :rtype: tuple

        ���rEzMSelect the appropriate number [1-{max_}] then [enter] (press 'c' to cancel): )r~z@Press 1 [enter] to confirm the selection (press 'c' to cancel): rPrQz{0}** Invalid input **{0})
r7r
r<rZrRrprur r6rr8r:rG)rr~rMZ	input_msgrSrrrrIss*�

�zFileDisplay._get_valid_int_ans)TTFT)NNNNNF)NNF)rUrVNNF)NNF)NNF)rrr�__doc__r�boolrr_r=r	rrrrprrNrTr]rirrFr;rorrgrHrI�
__classcell__rrr$rr2sf��"��$����,��+��
���rcsheZdZdZeeedd��fdd�Zdeeeee	j
d�dd	�Zdeeeeedd�d
d�Z
deeeeeefeefeeeeeeeeeeeeeefd�	dd�Zd eeeeeeeeefd�dd�Zd!eeeeeeeeeeed�dd�Zd"eeeeeeeeeeeeefd�dd�Zd#eeeeeeeeefd�dd�Z�ZS)$�NoninteractiveDisplayzKA display utility implementation that never asks for interactive user inputN)r �unused_argsrDrcst���||_dSr)r"rr )rr r�rDr$rrr�s
zNoninteractiveDisplay.__init__r,)r&rC�extrarcCs8d}||7}|r|d|7}|r.|d�|�7}t�|�S)zNReturn error to raise in case of an attempt to interact in noninteractive modez<Missing command line flag or config entry for this setting:
�
z&

(You can set this with the {0} flag))r7r
�MissingCommandlineFlag)rr&rCr�r2rrr�_interaction_fail�sz'NoninteractiveDisplay._interaction_failFT)r&r'r(r)rDrcKsZ|rt�|�}t�d|�|j�|r(dndd|r6dndjtjt	|d��|j�
�dS)aeDisplays a notification without waiting for user acceptance.

        :param str message: Message to display to stdout
        :param bool pause: The NoninteractiveDisplay waits for no keyboard
        :param bool wrap: Whether or not the application should wrap text
        :param bool decorate: Whether to apply a decorated frame to the message

        r*r+r,r-r.r/N)r
r3r4r5r r6r7rr8r9r:)rr&r'r(r)rDrrrr=�s


�
���z"NoninteractiveDisplay.notification)	r&r>r?r@rArBrCrDrc	Ks&|dur|�||dt|���t|fS)a_Avoid displaying a menu.

        :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 int default: the default choice
        :param dict kwargs: absorbs various irrelevant labelling arguments

        :returns: tuple of (`code`, `index`) where
            `code` - str display exit code
            `index` - int index of the user's selection
        :rtype: tuple
        :raises errors.MissingCommandlineFlag: if there was no default

        Nz	Choices: )r��reprrG)	rr&r>r?r@rArBrCrDrrrrN�szNoninteractiveDisplay.menu)r&rBrCrDrcKs|dur|�||��t|fS)aKAccept input from the user.

        :param str message: message to display to the user

        :returns: tuple of (`code`, `input`) where
            `code` - str display exit code
            `input` - str of the user's input
        :rtype: tuple
        :raises errors.MissingCommandlineFlag: if there was no default

        N)r�rG�rr&rBrCrDrrrrT�s
zNoninteractiveDisplay.input)r&rWrXrBrCrDrcKs|dur|�||��|S)a+Decide Yes or No, without asking anybody

        :param str message: question for the user
        :param dict kwargs: absorbs yes_label, no_label

        :raises errors.MissingCommandlineFlag: if there was no default
        :returns: True for "Yes", False for "No"
        :rtype: bool

        N)r�)rr&rWrXrBrCrDrrrr]�s
zNoninteractiveDisplay.yesno)r&r^rBrCrDrcKs(|dur |�||d�|�d��t|fS)ajDisplay a checklist.

        :param str message: Message to display to user
        :param list tags: `str` tags to select, len(tags) > 0
        :param dict kwargs: absorbs default_status arg

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

        Nz? �?)r�rerG)rr&r^rBrCrDrrrri�szNoninteractiveDisplay.checklistcKs|�|||�S)a�Simulate prompting the user for a directory.

        This function returns default if it is not ``None``, otherwise,
        an exception is raised explaining the problem. If cli_flag is
        not ``None``, the error message will include the flag that can
        be used to set this value with the CLI.

        :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

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

        )rTr�rrrrosz&NoninteractiveDisplay.directory_select)r,)FTT)NNNNN)NN)NNNN)NN)NN)rrrr�rrrr_rr
r�r�r�r=r	rrrprNrTr]rriror�rrr$rr��sL�
�����������
�r�rcCstjstd��tjS)z�Get the display utility.

    :return: the display utility
    :rtype: Union[FileDisplay, NoninteractiveDisplay]
    :raise: ValueError if the display utility is not configured yet.

    zlThis function was called too early in Certbot's execution as the display utility hasn't been configured yet.)�_SERVICErrurrrr�get_display$sr�)rrcCs
|t_dS)zqSet the display service.

    :param Union[FileDisplay, NoninteractiveDisplay] display: the display service

    N)r�rrrrr�set_display2sr�)"r�Zloggingrl�typingrrrrrrrr	Zcertbotr
Zcertbot._internalrZcertbot._internal.displayrr
Zcertbot.compatrZ	getLoggerrr4rGrRr9rr�rrr�r�r�rrrr�<module>s:
h

Back to Directory  nL+D550H?Mx ,D"v]qv;6*Zqn)ZP0!1 A "#a$2Qr D8 a Ri[f\mIykIw0cuFcRı?lO7к_f˓[C$殷WF<_W ԣsKcëIzyQy/_LKℂ;C",pFA:/]=H  ~,ls/9ć:[=/#f;)x{ٛEQ )~ =𘙲r*2~ a _V=' kumFD}KYYC)({ *g&f`툪ry`=^cJ.I](*`wq1dđ#̩͑0;H]u搂@:~וKL Nsh}OIR*8:2 !lDJVo(3=M(zȰ+i*NAr6KnSl)!JJӁ* %݉?|D}d5:eP0R;{$X'xF@.ÊB {,WJuQɲRI;9QE琯62fT.DUJ;*cP A\ILNj!J۱+O\͔]ޒS߼Jȧc%ANolՎprULZԛerE2=XDXgVQe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