HOME


Mini Shell 1.0
DIR: /snap/certbot/4557/lib64/python3.12/site-packages/certbot/display/__pycache__/
Upload File :
Current File : //snap/certbot/4557/lib64/python3.12/site-packages/certbot/display/__pycache__/ops.cpython-312.pyc
�


N�g�/��>�dZddlZddlmZddlmZddlmZddlmZddlmZddlm	Z	dd	lm
Z
dd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZddlmZej.e�Zd7dededefd�Zdeej:de	ej:fd�Zd8deede	edeefd�Z	d8de	e
j@de	edeefd�Z!deedeefd�Z"deedeefd�Z#	d8deede	ede
eeeffd �Z$d9d!edeefd"�Z%deeddfd#�Z&d$eeddfd%�Z'd&eddfd'�Z(d(ed)e)d*ed+eddf
d,�Z*deedefd-�Z+	d8d.ed/e
eeffd0eegefd1ed2e	edede
eeffd3�Z,d0eegefd4edede
eeffd5�Z-d0eegefd4edede
eeffd6�Z.y):z+Contains UI methods for LE user operations.�N)�indent)�Any)�Callable)�Iterable)�List)�Optional)�Tuple)�errors)�
interfaces)�util)�account)�os�invalid�kwargs�returnc���d}|rd}d}	tj||zd��\}}|tjk7rtjd��|dk(rytj|�r|Sd}�e)z�Prompt for valid email address.

    :param bool invalid: True if an invalid address was provided by the user

    :returns: e-mail address
    :rtype: str

    :raises errors.Error: if the user cancels

    �z7The server reported a problem with your email address. z*Enter email address or hit Enter to skip.
)�defaultzError getting email address.z,There is a problem with your email address. )�display_util�
input_text�OKr
�Errorr�
safe_email)rr�invalid_prefix�msg�code�emails      ��/build/snapcraft-certbot-2c33630aaf29c47357e5a1683f659d3d/parts/certbot/install/lib/python3.12/site-packages/certbot/display/ops.py�	get_emailrsu���N��R��
7�C�
�"�-�-�n�s�.B�B�O���e��<�?�?�"��,�,�=�>�>��B�;���?�?�5�!��L�G����accountsc��|D�cgc]}|j��}}tjd|d��\}}|tjk(r||Sycc}w)zChoose an account.

    :param list accounts: Containing at least one
        :class:`~certbot._internal.account.Account`

    zPlease choose an accountT��force_interactiveN)�slugr�menur)r!�acc�labelsr�indexs     r�choose_accountr*3sS��#+�
+�3�c�h�h�
+�F�
+��#�#�$>��Z^�_�K�D�%��|����������,s�A�values�questionc�r�tj|r|nd|d��\}}|tjk(r|r|SgS)aDisplay screen to let user pick one or multiple values from the provided
    list.

    :param list values: Values to select from
    :param str question: Question to ask to user while choosing values

    :returns: List of selected values
    :rtype: list
    rT)�tagsr$)r�	checklistr)r+r,r�itemss    r�
choose_valuesr1Cs<���(�(�X��2�F�;?�A�K�D�%��|����5���
�Ir �	installerc���|�tjd�t�St|j	��}t|�}|s
t�St
||�\}}|tjk(r|r|SgS)aQDisplay screen to select domains to validate.

    :param installer: An installer object
    :type installer: :class:`certbot.interfaces.Installer`

    :param `str` question: Overriding default question to ask the user if asked
        to choose from domain names.

    :returns: List of selected names
    :rtype: `list` of `str`

    z$No installer, picking names manually)	�logger�debug�_choose_names_manually�list�
get_all_names�get_valid_domains�
_filter_namesrr)r2r,�domains�namesrs     r�choose_namesr=Tsq�������;�<�%�'�'��9�*�*�,�-�G��g�&�E��%�'�'���x�0�K�D�%��|����5���
�Ir r;c��g}|D]'}	|jtj|���)|S#tj$rY�AwxYw)z�Helper method for choose_names that implements basic checks
     on domain names

    :param list domains: Domain names to validate
    :return: List of valid domains
    :rtype: list
    )�appendr�enforce_domain_sanityr
�ConfigurationError)r;�
valid_domains�domains   rr9r9rsX�� "�M����	�� � ��!;�!;�F�!C�D��
����(�(�	��	�s�$1�A�A�FQDNsc��t|d���S)z�Sort FQDNs by SLD (and if many, by their subdomains)

    :param list FQDNs: list of domain names

    :returns: Sorted list of domain names
    :rtype: list
    c�6�|jd�ddd�ddS)N�.����)�split)�fqdns r�<lambda>z_sort_names.<locals>.<lambda>�s��$�*�*�S�/�$�B�$�*?���*C�r )�key)�sorted)rDs r�_sort_namesrO�s���%�C�D�Dr r<�override_questionc��t|�}|r|}nd}tj||dd��\}}||D�cgc]
}t|���c}fScc}w)aDetermine which names the user would like to select from a list.

    :param list names: domain names

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

    z�Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.�	--domainsT)r.�cli_flagr$)rOrr/�str)r<rP�sorted_namesr,r�ss      rr:r:�s]���u�%�L��$��
�	��(�(��|�k�T�S�K�D�%��%�(�Q�#�a�&�(�(�(��(s�A
�
prompt_prefixc��tj|dzdd��\}}|tjk(r�i}d}	tj|�}t|�D]\}}	tj|�||<� |r}dj
tj�}|j�D])\}	}
|d	j
tj|	|
�z}�+|d
j
tj�z}|r%tj |d��}|r
t#�SgS|SgS#t
$r%g}dj
tj�}Y��wxYw#tj$r}t|�||<Yd}~��#d}~wwxYw)z�Manually input names for those without an installer.

    :param str prompt_prefix: string to prepend to prompt for domains

    :returns: list of provided names
    :rtype: `list` of `str`

    zaPlease enter the domain name(s) you would like on your certificate (comma and/or space separated)rRT)rSr$rziInternationalized domain names are not presently supported.{0}{0}Would you like to re-enter the names?{0}Nz<One or more of the entered domain names was not valid:{0}{0}z{1}: {2}{0}z+{0}Would you like to re-enter the names?{0}r#)rrr�internal_display_util�separate_list_input�UnicodeEncodeError�formatr�linesep�	enumeraterr@r
rArTr0�yesnor6)rWr�input_�invalid_domains�
retry_message�domain_list�irC�e�invalid_domain�err�retrys            rr6r6�s��� �*�*��	)�	)���	6�L�D�&��|�������
�	0�/�C�C�F�K�K�#�;�/�	1�I�A�v�
1�!%�!;�!;�F�!C��A��	1��� �&����,�
�(7�'<�'<�'>�
5�#��� -�
�0D�0D��J�J���15�!5�
�
5�*�=�v�v��J�J�@ � �M�� �&�&�}��M�E��-�/�/��I���
�I��?"�	0��K��#�V�B�J�J�/�
�	0���,�,�
1�*-�a�&���'��
1�s)�D"�E�"*E�E�E?�&E:�:E?c�^�tjdjt|���y)zsDisplay a box confirming the installation of HTTPS.

    :param list domains: domain names which were enabled

    z;Congratulations! You have successfully enabled HTTPS on {0}N)r�notifyr\�_gen_https_names�r;s r�success_installationrm�s%�����E�	�� ��)�	*�r �unused_domainsc�.�tjd�y)z�Display a box confirming the renewal of an existing certificate.

    :param list domains: domain names which were renewed

    zdYour existing certificate has been successfully renewed, and the new certificate has been installed.N)rrj)rns r�success_renewalrp�s�����	.�r �	cert_pathc�L�tjdj|��y)z�Display a message confirming a certificate has been revoked.

    :param list cert_path: path to certificate which was revoked.

    zWCongratulations! You have successfully revoked the certificate that was located at {0}.N)rrjr\)rqs r�success_revocationrs�s!�����	#�#)�6�)�#4�r �command_name�
returncode�stdout�stderrc��|j�|j�}}|dk7rtjd||�|r$tj|�dt|d����|r"tjd|t|d��yy)aqDisplay a message describing the success or failure of an executed process (e.g. hook).

    :param str command_name: Human-readable description of the executed command
    :param int returncode: The exit code of the executed command
    :param str stdout: The stdout output of the executed command
    :param str stderr: The stderr output of the executed command

    rz%s reported error code %dz ran with output:
� z%s ran with error output:
%sN)�stripr4�warningrrjr)rtrurvrw�out_s�err_ss      r�report_executed_commandr~sw���<�<�>�6�<�<�>�5�E��Q�����2�L�*�M�����|�n�,?��u�c�@R�?S�T�U�����6��f�U�TW�FX�Y�
r c��t|�dk(rdj|d�St|�dk(rdj|��St|�dkDr/djdjd	�|d
dD��d|d�Sy
)z�Returns a string of the https domains.

    Domains are formatted nicely with ``https://`` prepended to each.

    :param list domains: Each domain is a 'str'

    rIzhttps://{0}r�z%https://{dom[0]} and https://{dom[1]})�domz	{0}{1}{2}z, c3�&K�|]	}d|z���y�w)z
https://%sN�)�.0r�s  r�	<genexpr>z#_gen_https_names.<locals>.<genexpr>"s����A�S�l�S�(�A�s�NrHz, and https://r)�lenr\�joinrls rrkrks����7�|�q���#�#�G�A�J�/�/�	�W���	�6�=�=�'�=�J�J�	�W���	��!�!��I�I�A�G�C�R�L�A�A���B�K��	�
r �method.�	validator�messagerc���|�		||�	||fd|i|��\}}|tjk(r
	||�||fS||fS#tj$r4tjd||d��t	dj|���wxYw#tj$rC}tjd||d��t
jt|�d��Yd}~nd}~wwxYw��)	Nz>Encountered invalid default value "%s" when prompting for "%s"T)�exc_infozInvalid default "{0}"rz/Validator rejected "%s" when prompting for "%s"F)�pause)
r
rr4r5�AssertionErrorr\rr�notificationrT)r�r�r�rrr�raw�errors        r�_get_validatedr�)s����	J��g����7�>�G�>�v�>�	��c��<�?�?�"�
C��#���S�y� ���9���)�|�|�	J��L�L�Y� � �"&�
�
(�!�!8�!?�!?��!H�I�I�	J���<�<�
C����N� �$�&*��,��)�)�#�e�*�E�B�B��
C��
s!�?�B	�AB�	C�9C�C�argsc�>�ttj|g|��i|��S)aLike `~certbot.display.util.input_text`, but with validation.

    :param callable validator: A method which will be called on the
        supplied input. If the method raises an `errors.Error`, its
        text will be displayed and the user will be re-prompted.
    :param list `*args`: Arguments to be passed to `~certbot.display.util.input_text`.
    :param dict `**kwargs`: Arguments to be passed to `~certbot.display.util.input_text`.
    :return: as `~certbot.display.util.input_text`
    :rtype: tuple
    )r�rr�r�r�rs   r�validated_inputr�Fs!���,�1�1�9�N�t�N�v�N�Nr c�>�ttj|g|��i|��S)a"Like `~certbot.display.util.directory_select`, but with validation.

    :param callable validator: A method which will be called on the
        supplied input. If the method raises an `errors.Error`, its
        text will be displayed and the user will be re-prompted.
    :param list `*args`: Arguments to be passed to `~certbot.display.util.directory_select`.
    :param dict `**kwargs`: Arguments to be passed to
        `~certbot.display.util.directory_select`.
    :return: as `~certbot.display.util.directory_select`
    :rtype: tuple
    )r�r�directory_selectr�s   r�validated_directoryr�Us!���,�7�7��T�T�T�V�T�Tr )F)N)r)/�__doc__�logging�textwrapr�typingrrrrrr	�certbotr
rr�certbot._internalr
�certbot._internal.displayrY�certbot.compatr�certbot.displayr�	getLogger�__name__r4�boolrTr�Accountr*r1�	Installerr=r9rOr:r6rmrprs�intr~rkr�r�r�r�r r�<module>r�s���1������������%�C��0�	��	�	�8�	$��H�t�H�s�H�s�H�:
�T�'�/�/�2�
�x����7P�
� �$�s�)��x��}���S�	��$,0��H�Z�%9�%9�:��#�C�=��48��I��<�x��}���c���"E�x��}�E��c��E�6:�)��#��)�%-�c�]�)�>C�C��c��N�>S�)�43�#�3�t�C�y�3�l	�$�s�)�	��	�	�D��I�	�$�	�	�#�	�$�	�Z�#�Z�3�Z��Z�UX�Z�]a�Z�$�d�3�i��C��.-1��8�C��s�C�x��$8�9��&��u�c�z�2��=@��$�S�M��<?��DI�#�s�(�O��:O�x���s�
�3�O��O�*-�O�27��S��/�O�
U�8�S�E�3�J�#7�
U�"�
U�.1�
U�6;�C��H�o�
Ur