%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/certbot/_internal/display/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/certbot/_internal/display/__pycache__/obj.cpython-312.pyc

�

M/�e�W��t�dZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZej*e�ZdZ	dZ	dZ	Gd�d�Ze�Ze
d�ZGd�d�ZGd�d�Zdeeeffd�Z deeefddfd�Z!y)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�Zy)�_DisplayServiceNc��d|_y�N��display)�selfs �?/usr/lib/python3/dist-packages/certbot/_internal/display/obj.py�__init__z_DisplayService.__init__)s	��LP���)�returnN)�__name__�
__module__�__qualname__r�rrrr(s��Qrr�Tc���eZdZdZdededdf�fd�Z		d#deded	eded
eddfd�Z			d$dede	e
eeefe
efd
eedeedeedee
deedededeee
ffd�Z		d%dedeedeedededeeeffd�Z			d&dedededeedeedededefd�Z		d%dede
edee
edeedededeee
effd�Zdedeedeededeef
d�Zdedefd�Z		d%dedeedeedededeeeffd�Zdee	ee
fde
ede
efd�Zdede	e
eeefe
efddfd �Zd!e
deee
ffd"�Z�xZS)'�FileDisplayzFile-based display.�outfile�force_interactiverNc�L��t�|��||_||_d|_y)NF)�superrr$r%�skipped_interaction)rr$r%�	__class__s   �rrzFileDisplay.__init__6s%���
�������!2���#(�� r�message�pause�wrap�decoratec��|rtj|�}tjd|�|jj|rdnddz|rdndzj
tjt|���|jj�|r=|j|�rtjd�y	tjd�y	y	)
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�o�g�.�G����)�7�3������'/�#�R�
��!)�o�r�3���R�Z�Z�z�w��G�		
�	
��������!�!�"3�4��'�'�(A�B����@�A�	r�choices�ok_label�cancel_label�
help_label�default�cli_flag�
unused_kwargsc	��|j||||�}
|
�t|
fS|j||�|jt	|��\}}||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

        �)�_return_default�OK�_print_menu�_get_valid_int_ans�len)
rr*rCrDrErFrGrHr%rI�return_default�code�	selections
             r�menuzFileDisplay.menu]sc��4�-�-�g�w��J[�\���%��~�%�%�����'�*��1�1�#�g�,�?���i��Y��]�"�"rc���|j||||�}|�t|fStjd|z�dz}tj|�}|dvrt
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

        z%s (Enter 'c' to cancel):� )�c�Cz-1)rLrMrr8rA�CANCEL)rr*rGrHr%rIrQ�anss        r�inputzFileDisplay.input�sr�� �-�-�g�w��J[�\���%��~�%�%��/�/�"=��"G�H�3�N���%�%�g�.���*���4�<���3�w�r�	yes_label�no_labelc���|j||||�}|�|Stj|�}|jj	djtjttjz|���|jj�	tjdjtj|�tj|����}	|	j|dj��s"|	j|dj��ry|	j|dj��s"|	j|dj��ry��)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

        z{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�s3��(�-�-�g�w��J[�\���%�!�!��/�/�'�*�������6�=�=��J�J�j�2�:�:�5�7�>�D�	E���������)�)�.�*?�*?��+�+�I�6��*�*�8�4�+@�+6�7�C����y��|�1�1�3�4����y��|�1�1�3�4�����x��{�0�0�2�3����x��{�0�0�2�3��r�tagsc	��|j||||�}|�t|fS	|j||�|jdd��\}}	|tk(r�|	j	�s.djd�t
dt|�dz�D��}	tj|	�}
|j|
|�}|r||fS|jjdtjz�|jj�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

        TzrSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown)r%rVc3�2K�|]}t|����y�wr)�str)�.0�xs  r�	<genexpr>z(FileDisplay.checklist.<locals>.<genexpr>�s����"I�a�3�q�6�"I�s�rKz!** Error - Invalid selection **%s)rLrMrNr[�strip�join�rangerPr�separate_list_input�_scrub_checklist_inputr$r;rr=r?)rr*rfrGrHr%rIrQrRrZ�indices�
selected_tagss            r�	checklistzFileDisplay.checklist�s��$�-�-�g�w��J[�\���%��~�%�%�����W�d�+��
�
�$G�6:�#�;�I�D�#�
�r�z��y�y�{��(�(�"I�5��C��I�a�K�3H�"I�I�C��2�2�3�7�� $� ;� ;�G�T� J�
� ���.�.����"�"�7�"�*�*�D�F����"�"�$��R�x��'r�promptc���|j|�ry|�<dj|�}|r|dj|�z
}tj|��tjd||�|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:)rrurGrHr%r7s      rrLzFileDisplay._return_default�st�����/�0���?�B�I�I�&�Q�C���6�6<�f�X�6F�H���,�,�s�#�#����<��V�	��rc��|js:|s8tjj�r|jj�ry|j
s+tjdtj�d|_y)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_interactsd��
�"�"�&7��I�I����4�<�<�#6�#6�#8���'�'��N�N�?��0�0�	
2�
(,�D�$�rc�~�tj�5|j||||�cddd�S#1swYyxYw)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��:�:�g�w��:K�L�	M�	M�	M�s�3�<rrc��	|D�cgc]
}t|���}}tt|��}|D]}|dks|t	|�kDs�gcS|D�cgc]
}||dz
��c}Scc}w#t$rgcYSwxYwcc}w)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`

        rK)�int�
ValueError�list�setrP)rrrrf�index�indices_ints     rrqz"FileDisplay._scrub_checklist_input:s���	�3:�;�%�3�u�:�;�K�;�
�3�{�+�,��!�	�E��q�y�E�C��I�-��	�	�.9�9�E��U�Q�Y��9�9��<���	��I�	��:s'�A'�A"�A'�A8�"A'�'A5�4A5c��|r-t|dt�r|D�cgc]}|d�d|d����}}|jjtj
�|�tj
���|jjttj
z�t|d�D]c\}}|�d|��}|jjtj|��|jjtj
��e|jjttj
z�|jj�ycc}w)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)

        rz - rKz: N)�
isinstance�tupler$r;rr=r>�	enumeraterr8r?)rr*rCrW�i�descr7s       rrNzFileDisplay._print_menuUs���z�'�!�*�e�4�3:�;�a�!�A�$��s�1�Q�4�&�)�;�G�;�	
�����b�j�j�\�'��2�:�:�,�?�@������:��
�
�2�3�!��!�,�	+�G�A�t��C�r�$��.�C��L�L���t���s�3�4�
�L�L���r�z�z�*�	+�	
�����:��
�
�2�3��������<s�E�max_c���d}|dkDrdj|��}nd}|dkrdtj|�}|jd�s|jd�rtdfS	t|�}|dks||kDrd}t�	|dkr�dt|fS#t$rU|jjdjtj��|jj�Y�kwxYw)	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<rrArbrYr�r�r$r;rr=r?rM)rr�rS�	input_msgrZs     rrOzFileDisplay._get_valid_int_ansrs����	��!�8�%�%+�V��V�%6�
�3�I��!�m��)�)�)�4�C��~�~�c�"�c�n�n�S�&9��r�z�!�	
%���H�	��q�=�I��$4� "�I�$�$�%5�
�!�m��9�}����
%����"�"�/�6�6�r�z�z�B�D����"�"�$�
%�s�"B�AC,�+C,)TTFT)NNNNNF)NNF)�Yes�NoNNF)rrr�__doc__r�boolrrirBr
rrrr�rrTr[rertr!rLr@r�rrqrNrO�
__classcell__�r)s@rr#r#2s1����)��)�4�)�D�)�KO�GK�B�C�B��B�4�B�(,�B�@D�B�PT�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�h�s�m�M�#+�C�=�M�LP�M�*-�M�27��S��/�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	dded	eed
ede	jfd�Z		ddeded
edededdfd�Z
			ddedeeeeefeefdeedeedeedeed	eededeeeffd�Zd dedeed	eededeeeff
d�Z		d!dedeedeedeed	eededefd�Z		d dedeedeeed	eededeeeeffd�Z		d dedeed	eededeeeff
d�Z�xZS)"�NoninteractiveDisplayzKA display utility implementation that never asks for interactive user inputr$�unused_argsrIrNc�0��t�|��||_yr)r'rr$)rr$r�rIr)s    �rrzNoninteractiveDisplay.__init__�s���
������rr*rH�extrac�z�d}||z
}|r|d|zz
}|r|dj|�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�sN��N���w�����4�%�<��C���=�D�D�X�N�N�C��,�,�S�1�1rr+r,r-c�,�|rtj|�}tjd|�|jj|rdnddz|rdndzj
tjt|���|jj�y)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�sz����o�o�g�.�G����)�7�3������'/�#�R�
��!)�o�r�3���R�Z�Z�z�w��G�		
�	
�����rrCrDrErFrGc�T�|�|j||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

        z	Choices: )r��reprrM)	rr*rCrDrErFrGrHrIs	         rrTzNoninteractiveDisplay.menu�s1��*�?��(�(��(�K�$�w�-�<W�X�X��7�{�rc�:�|�|j||��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�.�|�|j||��|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       rrezNoninteractiveDisplay.yesno�s!���?��(�(��(�;�;��rrfc�`�|�%|j||dj|�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

        z? �?)r�rnrM)rr*rfrGrHrIs      rrtzNoninteractiveDisplay.checklist�s5���?��(�(��(�D�I�I�d�O�c�<Q�R�R��7�{�rc�(�|j|||�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�5r)r1)FTT)NNNNN)NN)NNNN)rrrr�rrrrirrr�r�r�rBr
rrr�rTr[rerrtr�r�r�s@rr�r��sh���U����c��C��TX��
(*�	2��	2���
�	2�!$�	2�.4�.K�.K�	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�h�s�m�6�#+�C�=�6�JM�6�RW�X[�]`�X`�Ra�6rr�rc�X�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�#s.������N�O�	O����rrc��|t_y)zqSet the display service.

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

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

Zerion Mini Shell 1.0