M/e dZddlZddlZddlmZddlmZddlmZddl m Z de de fd Z d e de fd Z dd ee d ede fdZde dee fdZdee de fdZdej$de fdZy)z#Internal Certbot display utilities.N)List)Optional)messages)miscmsgreturnc |j}g}|D]*}|jtj|ddd,dj |S)zFormat lines nicely to 80 chars. :param str msg: Original message :returns: Formatted message respecting newlines in message :rtype: str PF)break_long_wordsbreak_on_hyphens ) splitlinesappendtextwrapfilljoin)rlinesfixed_llines @/usr/lib/python3/dist-packages/certbot/_internal/display/util.py wrap_linesr sX NN EG%x}}  "" $ %% 99W labelc4dj|d|ddS)znPlace parens around first character of label. :param str label: Must contain at least one character z({first}){rest}rN)firstrest)format)rs rparens_around_charr!s$  # #%(qr # CCrprompttimeoutc|r=tjj|tjjt j ||}|st |jdS)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 )sysstdoutwriteflushrreadline_with_timeoutEOFErrorrstrip)r r!rs rinput_with_timeoutr**sR&     % %gv 6D  ;;t rinput_c~|jdd}|jDcgc] }t|c}Scc}w)zSeparate a comma or space separated list. :param str input_: input from the user :returns: strings :rtype: list , )replacesplitstr)r+ no_commasstrings rseparate_list_inputr4Hs5sC(I'0oo&7 8FCK 88 8s:domainsc|syt|}|dk(r|dS|dk(rdj|Sdj|d|dz S)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 rrz and z{0} and {1} more domains)lenrr)r5lengths rsummarize_domain_listr;WsU  \F {qz 1||G$$)00VAXFFrerrorc|j|jf}t|rdjd|DS|jr |jS|j S)zReturns 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 :: c3&K|] }|| yw)N).0parts r z&describe_acme_error..xsFDT5E4Fs)titledetailanyr descriptiontyp)r<partss rdescribe_acme_errorrIosQ[[%,, 'E 5z{{FEFFF    99r)Ng@)__doc__r#rtypingrracmer acme_messagescertbot.compatrr1rrfloatr*r4r;ErrorrIr?rrrQs) *CC,DcDcDx}eRU< 9 9S 9G49GG0 }22 s r