File: //lib/python3.9/site-packages/certbot/_internal/display/__pycache__/util.cpython-39.pyc
a
}|�g�
� @ s� d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
eed�dd �Zeed
�dd�Z
dee eed�dd�Zeee d�dd�Zee ed�dd�Zejed�dd�ZdS )z#Internal Certbot display utilities.� N)�List)�Optional)�messages)�misc)�msg�returnc C s8 | � � }g }|D ]}|�tj|dddd�� qd�|�S )z�Format lines nicely to 80 chars.
:param str msg: Original message
:returns: Formatted message respecting newlines in message
:rtype: str
�P F)Zbreak_long_wordsZbreak_on_hyphens�
)�
splitlines�append�textwrap�fill�join)r �linesZfixed_l�line� r �B/usr/lib/python3.9/site-packages/certbot/_internal/display/util.py�
wrap_lines s �
r )�labelr c C s dj | d | dd� d�S )znPlace parens around first character of label.
:param str label: Must contain at least one character
z({first}){rest}r � N)�first�rest)�format)r r r r �parens_around_char! s r � ��@)�prompt�timeoutr c C s8 | rt j�| � t j�� t�|| �}|s.t�|�d�S )a Get user input with a timeout.
Behaves the same as the builtin input, however, an error is raised if
a user doesn't answer after timeout seconds. The default timeout
value was chosen to place it just under 12 hours for users following
our advice and running Certbot twice a day.
:param str prompt: prompt to provide for input
:param float timeout: maximum number of seconds to wait for input
:returns: user response
:rtype: str
:raises errors.Error if no answer is given before the timeout
r )�sys�stdout�write�flushr Zreadline_with_timeout�EOFError�rstrip)r r r r r r �input_with_timeout* s
r# )�input_r c C s | � dd�}dd� |�� D �S )z�Separate a comma or space separated list.
:param str input_: input from the user
:returns: strings
:rtype: list
�,� c S s g | ]}t |��qS r )�str)�.0�stringr r r �
<listcomp>T � z'separate_list_input.<locals>.<listcomp>)�replace�split)r$ Z no_commasr r r �separate_list_inputH s r. )�domainsr c C sJ | sdS t | �}|dkr | d S |dkr2d�| �S d�| d |d �S dS )aM Summarizes a list of domains in the format of:
example.com.com and N more domains
or if there is are only two domains:
example.com and www.example.com
or if there is only one domain:
example.com
:param list domains: `str` list of domains
:returns: the domain list summary
:rtype: str
� r r � z and z{0} and {1} more domainsN)�lenr r )r/ �lengthr r r �summarize_domain_listW s
r4 )�errorr c C s: | j | jf}t|�r(d�dd� |D ��S | jr4| jS | jS )z�Returns a human-readable description of an RFC7807 error.
:param error: The ACME error
:returns: a string describing the error, suitable for human consumption.
:rtype: str
z :: c s s | ]}|d ur|V qd S )Nr )r( �partr r r � <genexpr>x r+ z&describe_acme_error.<locals>.<genexpr>)�titleZdetail�anyr �description�typ)r5 �partsr r r �describe_acme_erroro s r= )Nr )�__doc__r r �typingr r Zacmer Z
acme_messagesZcertbot.compatr r'