a ‚oe€ ã@sºdZddlZddlZddlmZddlmZddlmZddl m Z e e dœdd „Z e e d œd d „Z dee ee dœdd„Ze ee dœdd„Zee e dœdd„Zeje dœdd„ZdS)z#Internal Certbot display utilities.éN)ÚList)ÚOptional)Úmessages)Úmisc)ÚmsgÚreturnc Cs8| ¡}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 éPF)Zbreak_long_wordsZbreak_on_hyphensÚ )Ú splitlinesÚappendÚtextwrapÚfillÚjoin)rÚlinesZfixed_lÚline©rú?C:\Program Files\Certbot\pkgs\certbot\_internal\display\util.pyÚ wrap_lines s ü r)ÚlabelrcCsdj|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)rrrrÚparens_around_char!srç”á@)ÚpromptÚtimeoutrcCs8|rtj |¡tj ¡t ||¡}|s.t‚| d¡S)aGet 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ÚflushrZreadline_with_timeoutÚEOFErrorÚrstrip)rrrrrrÚinput_with_timeout*s   r#)Úinput_rcCs| dd¡}dd„| ¡DƒS)zƒSeparate a comma or space separated list. :param str input_: input from the user :returns: strings :rtype: list ú,ú cSsg|] }t|ƒ‘qSr)Ústr)Ú.0ÚstringrrrÚ Tóz'separate_list_input..)ÚreplaceÚsplit)r$Z no_commasrrrÚseparate_list_inputHs r.)ÚdomainsrcCsJ|sdSt|ƒ}|dkr |dS|dkr2d |¡Sd |d|d¡SdS)aMSummarizes 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 Úrréz and z{0} and {1} more domainsN)Úlenrr)r/ÚlengthrrrÚsummarize_domain_listWs  r4)ÚerrorrcCs:|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 :: css|]}|dur|VqdS)Nr)r(ÚpartrrrÚ xr+z&describe_acme_error..)ÚtitleZdetailÚanyrÚ descriptionÚtyp)r5ÚpartsrrrÚdescribe_acme_erroros  r=)Nr)Ú__doc__rr ÚtypingrrZacmerZ acme_messagesZcertbot.compatrr'rrÚfloatr#r.r4ÚErrorr=rrrrÚs