HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/certbot/_internal/display/__pycache__/obj.cpython-311.pyc
�

E��c�W���dZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZeje��ZdZ	dZ	dZ	Gd�d��Ze��Ze
d��ZGd�d��ZGd�d��Zdeeeffd�Z deeefddfd�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��eZdZdd�ZdS)�_DisplayService�returnNc��d|_dS�N��display)�selfs �?/usr/lib/python3/dist-packages/certbot/_internal/display/obj.py�__init__z_DisplayService.__init__)s
��LP�����)rN)�__name__�
__module__�__qualname__r�rrrr(s.������Q�Q�Q�Q�Q�Qrr�Tc�p��eZdZdZdededdf�fd�Z		d'd	ed
ededededdfd
�Z			d(d	ede	e
eeefe
efdeedeedeedee
deedededeee
ffd�Z		d)d	edeedeedededeeeffd�Z			d*d	edededeedeedededefd�Z		d)d	ede
edee
edeedededeee
effd�Zdedeedeededeef
d�Zdedefd �Z		d)d	edeedeedededeeeffd!�Zd"ee	ee
fde
ede
efd#�Zd	ede	e
eeefe
efddfd$�Zd%e
deee
ffd&�Z�xZS)+�FileDisplayzFile-based display.�outfile�force_interactiverNc�r��t�����||_||_d|_dS)NF)�superrr$r%�skipped_interaction)rr$r%�	__class__s   �rrzFileDisplay.__init__6s6���
�����������!2���#(�� � � rTF�message�pause�wrap�decoratec���|rtj|��}t�d|��|j�|rdnddz|rdndz�tjt|�����|j�
��|rG|�|��rtjd��d	St�d��d	Sd	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-s      r�notificationzFileDisplay.notification<s����	/��o�g�.�.�G����)�7�3�3�3�����'/�7�#�#�R�
��!)�1�o�o�r�3���R�Z�z�w��G�G�		
�	
�	
�	
��������	B��!�!�"3�4�4�
B��'�(A�B�B�B�B�B����@�A�A�A�A�A�		B�	Br�choices�ok_label�cancel_label�
help_label�default�cli_flag�
unused_kwargsc	���|�||||��}
|
�	t|
fS|�||��|�t	|����\}}||dz
fS)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*rCrDrErFrGrHr%rI�return_default�code�	selections
             r�menuzFileDisplay.menu]sq��4�-�-�g�w��J[�\�\���%��~�%�%�����'�*�*�*��1�1�#�g�,�,�?�?���i��Y��]�"�"rc���|�||||��}|�	t|fStjd|z��dz}tj|��}|dvr	t
dfSt|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)rLrMrr8rA�CANCEL)rr*rGrHr%rIrQ�anss        r�inputzFileDisplay.input�sy�� �-�-�g�w��J[�\�\���%��~�%�%��/�"=��"G�H�H�3�N���%�g�.�.���*����4�<���3�w�r�Yes�No�	yes_label�no_labelc�<�|�||||��}|�|Stj|��}|j�d�tjttjz|�����|j�	��	tj
d�tj|��tj|�������}	|	�|d�
����s-|	�|d�����rdS|	�|d�
����s-|	�|d�����rdS��)	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})r6r7Tz{yes}/{no}: )�yes�norF)rLrr8r$r;r<rr=r>r?rA�parens_around_char�
startswith�lower�upper)
rr*r^r_rGrHr%rIrQrZs
          r�yesnozFileDisplay.yesno�s���(�-�-�g�w��J[�\�\���%�!�!��/�'�*�*������6�=�=��J�j�2�:�5�7�>�D�D�	E�	E�	E��������	��)�.�*?�*?��+�I�6�6��*�8�4�4�+@�+6�+6�7�7�C����y��|�1�1�3�3�4�4�
����y��|�1�1�3�3�4�4�
��t����x��{�0�0�2�2�3�3�
����x��{�0�0�2�2�3�3�
��u�	r�tagsc	�P�|�||||��}|�	t|fS	|�||��|�dd���\}}	|tkr�|	���s=d�d�t
dt|��dz��D����}	tj	|	��}
|�
|
|��}|r||fS|j�dtjz��|j���n|gfS��)	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

        NTzrSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown)r%rVc3�4K�|]}t|��V��dSr)�str)�.0�xs  r�	<genexpr>z(FileDisplay.checklist.<locals>.<genexpr>�s(����"I�"I�a�3�q�6�6�"I�"I�"I�"I�"I�"IrrKz!** Error - Invalid selection **%s)rLrMrNr[�strip�join�rangerPr�separate_list_input�_scrub_checklist_inputr$r;rr=r?)rr*rhrGrHr%rIrQrRrZ�indices�
selected_tagss            r�	checklistzFileDisplay.checklist�sE��$�-�-�g�w��J[�\�\���%��~�%�%�	 ����W�d�+�+�+��
�
�$G�6:�#�;�;�I�D�#�
�r�z�z��y�y�{�{�J��(�(�"I�"I�5��C��I�I�a�K�3H�3H�"I�"I�"I�I�I�C��2�3�7�7�� $� ;� ;�G�T� J� J�
� �/���.�.���"�"�7�"�*�D�F�F�F���"�"�$�$�$�$��R�x��'	 r�promptc��|�|��rdS|�Cd�|��}|r|d�|��z
}tj|���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@r<r�Errorr9r:)rrwrGrHr%r7s      rrLzFileDisplay._return_default�s������/�0�0�	��4��?�B�I�I�&�Q�Q�C��
H��6�6<�f�X�6F�6F�H���,�s�#�#�#����<��V�	�	�	��rc���|js9|s7tj���r|j���rdS|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(r9�warningr�FORCE_INTERACTIVE_FLAG)rr%s  rr@zFileDisplay._can_interacts���
�"�	�&7�	��I�����	�#'�<�#6�#6�#8�#8�	��4��'�	,��N�N�?��0�	
2�
2�
2�
(,�D�$��urc��tj��5|�||||��cddd��S#1swxYwYdS)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)r
�	Completerr[)rr*rGrHr%rIs      r�directory_selectzFileDisplay.directory_select's��� �
 �
"�
"�	M�	M��:�:�g�w��:K�L�L�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M�	M����	M�	M�	M�	M�	M�	Ms
�9�=�=rtc����	d�|D��}n#t$rgcYSwxYwtt|����}|D]}|dks|t���krgcS� �fd�|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`

        c�,�g|]}t|����Sr )�int)rl�indexs  r�
<listcomp>z6FileDisplay._scrub_checklist_input.<locals>.<listcomp>Gs��;�;�;�%�3�u�:�:�;�;�;rrKc�&��g|]
}�|dz
��S)rKr )rlr�rhs  �rr�z6FileDisplay._scrub_checklist_input.<locals>.<listcomp>Ss!���9�9�9�E��U�Q�Y��9�9�9r)�
ValueError�list�setrP)rrtrh�indices_intr�s  `  rrsz"FileDisplay._scrub_checklist_input:s����	�;�;�7�;�;�;�K�K���	�	�	��I�I�I�	�����3�{�+�+�,�,��!�	�	�E��q�y�y�E�C��I�I�-�-��	�	�	�.�:�9�9�9�[�9�9�9�9s���c�|�|r't|dt��rd�|D��}|j�tj�|�tj����|j�ttjz��t|d��D]\\}}|�d|��}|j�tj	|����|j�tj���]|j�ttjz��|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)

        rc�4�g|]}|d�d|d����S)rz - rKr )rlrWs  rr�z+FileDisplay._print_menu.<locals>.<listcomp>as.��;�;�;�a�!�A�$�)�)�1�Q�4�)�)�;�;�;rrKz: N)�
isinstance�tupler$r;rr=r>�	enumeraterr8r?)rr*rC�i�descr7s      rrNzFileDisplay._print_menuUs���	<�z�'�!�*�e�4�4�	<�;�;�7�;�;�;�G�	
����b�j�?�'�?�2�:�?�?�@�@�@�����:��
�2�3�3�3�!��!�,�,�	+�	+�G�A�t��.�.�$�.�.�C��L���t��s�3�3�4�4�4�
�L���r�z�*�*�*�*�����:��
�2�3�3�3���������r�max_c��d}|dkrd�|���}nd}|dkr�tj|��}|�d��s|�d��r	tdfS	t|��}|dks||kr	d}t�n`#t$rS|j�d�tj
����|j���YnwxYw|dk��t|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

        ���rKzMSelect the appropriate number [1-{max_}] then [enter] (press 'c' to cancel): )r�z@Press 1 [enter] to confirm the selection (press 'c' to cancel): rWrXz{0}** Invalid input **{0})
r<rrArdrYr�r�r$r;rr=r?rM)rr�rS�	input_msgrZs     rrOzFileDisplay._get_valid_int_ansrs/���	��!�8�8�%�%+�V��V�%6�%6�
�I�3�I��!�m�m��)�)�4�4�C��~�~�c�"�"�
"�c�n�n�S�&9�&9�
"��r�z�!�	
%���H�H�	��q�=�=�I��$4�$4� "�I�$�$�%5���
%�
%�
%���"�"�/�6�6�r�z�B�B�D�D�D���"�"�$�$�$�$�$�
%�����!�m�m��9�}�s�0$B�AC2�1C2)TTFT)NNNNNF)NNF)r\r]NNF)rrr�__doc__r�boolrrkrBr
rrrr�rrTr[rgrvr!rLr@r�rrsrNrO�
__classcell__�r)s@rr#r#2s4���������)��)�4�)�D�)�)�)�)�)�)�KO�GK�B�B�C�B��B�4�B�(,�B�@D�B�PT�B�B�B�B�DLP�HL�GL�"#�"#�C�"#�%��U�3��8�_�0E�t�C�y�0P�*Q�"#���}�"#�;C�C�=�"#�!�#��"#�8@��
�"#� ��}�"#�AE�"#�"�	"#�',�C��H�o�	"#�"#�"#�"#�H\`�(-���S��8�C�=��8�TW�=��!%��@C��HM�c�SV�h������:KO�HL�(-�*�*�S�*�S�*�C�*���~�*�8@��
�*�!%�*�@C�*�HL�*�*�*�*�XW[�LQ�) �) ��) �D��I�) ���c��@S�) �$�S�M�) �EI�) �#&�) �+0��d�3�i��+@�) �) �) �) �V�c��H�Q�K��"*�3�-��DH��MU�VW�[�����:�t�������*GK�SX�M�M��M�h�s�m�M�#+�C�=�M�LP�M�*-�M�27��S��/�M�M�M�M�&:�h�u�S�#�X��.G�:�%)�#�Y�:�37��9�:�:�:�:�6�3��"�4��c�3�h��#8�$�s�)�#C�D��IM�����:"�s�"�u�S�#�X��"�"�"�"�"�"�"�"rr#c���eZdZdZdedededdf�fd�Z	d d	ed
eedede	j
fd�Z		d!d	edededededdfd�Z
			d"d	edeeeeefeefdeedeedeedeed
eededeeeffd�Zd#d	edeed
eededeeeff
d�Z		d$d	edeedeedeed
eededefd�Z		d#d	edeedeeed
eededeeeeffd�Z		d#d	edeed
eededeeeff
d�Z�xZS)%�NoninteractiveDisplayzKA display utility implementation that never asks for interactive user inputr$�unused_argsrIrNc�V��t�����||_dSr)r'rr$)rr$r�rIr)s    �rrzNoninteractiveDisplay.__init__�s$���
������������rr1r*rH�extrac��d}||z
}|r|d|zz
}|r|d�|��z
}tj|��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))r<r�MissingCommandlineFlag)rr*rHr�r7s     r�_interaction_failz'NoninteractiveDisplay._interaction_fail�s\��N���w����	 ��4�%�<��C��	O��=�D�D�X�N�N�N�C��,�S�1�1�1rFTr+r,r-c�4�|rtj|��}t�d|��|j�|rdnddz|rdndz�tjt|�����|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/r0r1r2r3r4N)rr8r9r:r$r;r<rr=r>r?)rr*r+r,r-rIs      rrBz"NoninteractiveDisplay.notification�s����	/��o�g�.�.�G����)�7�3�3�3�����'/�7�#�#�R�
��!)�1�o�o�r�3���R�Z�z�w��G�G�		
�	
�	
�	
��������rrCrDrErFrGc�f�|�'|�||dt|��z���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��reprrM)	rr*rCrDrErFrGrHrIs	         rrTzNoninteractiveDisplay.menu�s6��*�?��(�(��(�K�$�w�-�-�<W�X�X�X��7�{�rc�D�|�|�||���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

        )r�rM�rr*rGrHrIs     rr[zNoninteractiveDisplay.input�s)���?��(�(��(�;�;�;��7�{�rr^r_c�6�|�|�||���|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

        )r�)rr*r^r_rGrHrIs       rrgzNoninteractiveDisplay.yesno�s$���?��(�(��(�;�;�;��rrhc�r�|�-|�||d�|��dz���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�rprM)rr*rhrGrHrIs      rrvzNoninteractiveDisplay.checklist�s:���?��(�(��(�D�I�I�d�O�O�c�<Q�R�R�R��7�{�rc�0�|�|||��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

        )r[r�s     rr�z&NoninteractiveDisplay.directory_selects��$�z�z�'�7�H�5�5�5r)r1)FTT)NNNNN)NN)NNNN)rrrr�rrrrkrrr�r�r�rBr
rrr�rTr[rgrrvr�r�r�s@rr�r��s)�������U�U����c��C��TX�������
(*�	2�	2��	2���
�	2�!$�	2�.4�.K�	2�	2�	2�	2�LP�&*���C����D��#��=@��EI�����0LP�HL�'+���C��%��U�3��8�_�0E�t�C�y�0P�*Q����}��;C�C�=��!�#���8@��
�� ��}��?B��GL�C�QT�H�o�����4��S��8�C�=��8�TW�=��"��',�S�#�X������"^b�HL���S��X�c�]��X�VY�]����~��8@��
��"��'+�����"[_�,0�����H�S�M��H�T�RU�Y�DW��$�S�M��CF��KP�QT�VZ�[^�V_�Q_�K`�����$GK�37�6�6��6�h�s�m�6�#+�C�=�6�JM�6�RW�X[�]`�X`�Ra�6�6�6�6�6�6�6�6rr�rc�P�tjstd���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.)�_SERVICErr�r rr�get_displayr�#s4����O��N�O�O�	O���rrc��|t_dS)zqSet the display service.

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

    N)r�rrs r�set_displayr�1s���H���r)"r��loggingr{�typingrrrrrrr	r
�certbotr�certbot._internalr�certbot._internal.displayr
r�certbot.compatr�	getLoggerrr9rMrYr>rr�r!r#r�r�r�r rr�<module>r�sB��L�L�����
�
�
�
�������������������������������������������������������'�'�'�'�'�'�/�/�/�/�/�/�*�*�*�*�*�*�������	��	�8�	$�	$��
��3�	��9��
��Q�Q�Q�Q�Q�Q�Q�Q�
�?�����G�C�L�L��b�b�b�b�b�b�b�b�JI6�I6�I6�I6�I6�I6�I6�I6�X�U�;�(=�=�>�������{�,A�A�B��t������r