Ë
    M/ÅeÒ4  ã                   ó>  — d Z ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 dd	lm
Z
 dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  ej.                  e«      Zd8dededefd„Zdeej:                     de	ej:                     fd„Zd9dee   de	e   dee   fd„Z	 d9de	ej@                     de	e   dee   fd„Z!dee   dee   fd„Z"dee   dee   fd„Z#	 d9dee   de	e   de
eee   f   fd „Z$d:d!edee   fd"„Z%dee   ddfd#„Z&d$ee   ddfd%„Z'd&eddfd'„Z(d(ed)e)d*ed+eddf
d,„Z*dee   defd-„Z+	 d9d.ed/e
eef   f   d0eegef   d1ed2e	e   d3ede
eef   fd4„Z,d0eegef   d5ed3ede
eef   fd6„Z-d0eegef   d5ed3ede
eef   fd7„Z.y);z+Contains UI methods for LE user operations.é    N)Úindent)ÚAny)ÚCallable)ÚIterable)ÚList)ÚOptional)ÚTuple)Úerrors)Ú
interfaces)Úutil)Úaccount)ÚosÚinvalidÚoptionalÚreturnc                 ó¨  — d}d}d}|r| r||z  }d}nd}nd}	 	 t        j                  | r||z   n|d¬«      \  }}|t         j                  k7  r,|rt        j
                  d«      ‚t        j
                  d	«      ‚t        j                  |«      r|S |r||z   }d}t        |«      } Œ�# t        j                  $ r d}t        j                  |«      ‚w xY w)
aJ  Prompt for valid email address.

    :param bool invalid: True if an invalid address was provided by the user
    :param bool optional: True if the user can use
        --register-unsafely-without-email to avoid providing an e-mail

    :returns: e-mail address
    :rtype: str

    :raises errors.Error: if the user cancels

    z-There seem to be problems with that address. zCEnter email address (used for urgent renewal and security notices)
a  

If you really want to skip this, you can run the client with --register-unsafely-without-email but you will then be unable to receive notice about impending expiration or revocation of your certificates or problems with your Certbot installation that will lead to failure to renew.

FT©Úforce_interactivezoYou should register before running non-interactively, or provide --agree-tos and --email <email_address> flags.zHAn e-mail address or --register-unsafely-without-email must be provided.z#An e-mail address must be provided.)	Údisplay_utilÚ
input_textr
   ÚMissingCommandlineFlagÚOKÚErrorr   Ú
safe_emailÚbool)r   r   Úinvalid_prefixÚmsgÚunsafe_suggestionÚsuggest_unsafeÚcodeÚemails           ú5/usr/lib/python3/dist-packages/certbot/display/ops.pyÚ	get_emailr#      s  € ð E€NØ
P€CðPÐñ ÙØÐ$Ñ$ˆCØ"‰Nà!‰Nàˆà
ð	5Ü&×1Ñ1É'°.À3Ò2FÐWZØDHôJ‰KˆD�%ð ”<—?‘?Ò"ÙÜ—l‘lðJóKð Kô —,‘,ÐDÓEÐEÜ�?‰?˜5Ô!ØˆLÙØ# cÑ)ˆCØ"ˆNä�u“+ˆð+ øô ×,Ñ,ò 	5ðOˆCä×/Ñ/°Ó4Ð4ð	5ús   š!B& Â&+CÚaccountsc                 ó¦   — | D �cg c]  }|j                   ‘Œ }}t        j                  d|d¬«      \  }}|t        j                  k(  r| |   S yc c}w )zChoose an account.

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

    zPlease choose an accountTr   N)Úslugr   Úmenur   )r$   ÚaccÚlabelsr    Úindexs        r"   Úchoose_accountr+   L   sS   € ð #+Ö+˜3ˆc�h‹hÐ+€FÐ+ä×#Ñ#Ð$>ÀÐZ^Ô_�K€Dˆ%ØŒ|�‰ÒØ˜‰ÐØùò ,s   …AÚvaluesÚquestionc                 ór   — t        j                  |r|nd| d¬«      \  }}|t         j                  k(  r|r|S g S )a  Display 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
    Ú T)Útagsr   )r   Ú	checklistr   )r,   r-   r    Úitemss       r"   Úchoose_valuesr3   \   s<   € ô ×(Ñ(±X©À2ÈFØ;?ôA�K€Dˆ%àŒ|�‰Ò¡5ØˆØ€Ió    Ú	installerc                 óô   — | €t         j                  d«       t        «       S t        | j	                  «       «      }t        |«      }|s
t        «       S t        ||«      \  }}|t        j                  k(  r|r|S g S )aQ  Display 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_namesr   r   )r5   r-   ÚdomainsÚnamesr    s        r"   Úchoose_namesr@   m   sq   € ð ÐÜ�‰Ð;Ô<Ü%Ó'Ð'ä�9×*Ñ*Ó,Ó-€GÜ˜gÓ&€EáÜ%Ó'Ð'ä  xÓ0�K€Dˆ%ØŒ|�‰Ò¡5ØˆØ€Ir4   r>   c                 ó”   — g }| D ]'  }	 |j                  t        j                  |«      «       Œ) |S # t        j                  $ r Y ŒAw xY w)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      r"   r<   r<   ‹   sX   € ð  "€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   — | j                  d«      d d d…   dd  S )Nú.éÿÿÿÿé   )Úsplit)Úfqdns    r"   ú<lambda>z_sort_names.<locals>.<lambda>¤   s   € ¨$¯*©*°S«/¹$¸B¸$Ñ*?ÀÀÐ*C€ r4   )Úkey)Úsorted)rG   s    r"   Ú_sort_namesrR   œ   s   € ô �%ÑCÔDÐDr4   r?   Úoverride_questionc                 óž   — t        | «      }|r|}nd}t        j                  ||dd¬«      \  }} || D �cg c]  }t        |«      ‘Œ c}fS c c}w )a  Determine 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)r0   Úcli_flagr   )rR   r   r1   Ústr)r?   rS   Úsorted_namesr-   r    Úss         r"   r=   r=   §   s]   € ô ˜uÓ%€LÙØ$‰ðð 	ô ×(Ñ(Ø�|¨kÈTôS�K€Dˆ%à %Ö(˜Q”#�a•&Ò(Ð(Ð(ùÒ(s   ´A
Úprompt_prefixc                 ó  — t        j                  | dz   dd¬«      \  }}|t         j                  k(  rîi }d}	 t        j                  |«      }t        |«      D ]  \  }}	 t        j                  |«      ||<   Œ  |r}dj                  t        j                  «      }|j                  «       D ])  \  }	}
|d	j                  t        j                  |	|
«      z   }Œ+ |d
j                  t        j                  «      z   }|r%t        j                   |d¬«      }|r
t#        «       S g S |S g S # t
        $ r% g }dj                  t        j                  «      }Y �Œw xY w# t        j                  $ r}t        |«      ||<   Y d}~�Œ#d}~ww xY w)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)rU   T)rV   r   r/   ziInternationalized 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   )r   r   r   Úinternal_display_utilÚseparate_list_inputÚUnicodeEncodeErrorÚformatr   ÚlinesepÚ	enumerater   rC   r
   rD   rW   r2   Úyesnor9   )rZ   r    Úinput_Úinvalid_domainsÚretry_messageÚdomain_listÚirF   ÚeÚinvalid_domainÚerrÚretrys               r"   r9   r9   Á   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                 ó^   — t        j                  dj                  t        | «      «      «       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_installationrp   ÷   s%   € ô ×ÑØEß	‰Ô  Ó)Ó	*õr4   Úunused_domainsc                 ó.   — t        j                  d«       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)r   rm   )rq   s    r"   Úsuccess_renewalrs     s   € ô ×Ñð	.õr4   Ú	cert_pathc                 óL   — t        j                  dj                  | «      «       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)r   rm   r_   )rt   s    r"   Úsuccess_revocationrv     s!   € ô ×Ñð	#ß#)¡6¨)Ó#4õr4   Úcommand_nameÚ
returncodeÚstdoutÚstderrc                 ó  — |j                  «       |j                  «       }}|dk7  rt        j                  d| |«       |r$t        j                  | › dt        |d«      › �«       |r"t        j                  d| t        |d«      «       yy)aq  Display 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

    r   z%s reported error code %dz ran with output:
ú z%s ran with error output:
%sN)Ústripr7   Úwarningr   rm   r   )rw   rx   ry   rz   Ú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ð r4   c                 ó  — t        | «      dk(  rdj                  | d   «      S t        | «      dk(  rdj                  | ¬«      S t        | «      dkD  r/dj                  dj                  d	„ | d
d D «       «      d| d   «      S y)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'

    rL   zhttps://{0}r   é   z%https://{dom[0]} and https://{dom[1]})Údomz	{0}{1}{2}z, c              3   ó&   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   ‚NrK   z, and https://r/   )Úlenr_   Újoinro   s    r"   rn   rn   -  s‹   € ô ˆ7ƒ|�qÒØ×#Ñ# G¨A¡JÓ/Ð/Ü	ˆW‹˜Ò	Ø6×=Ñ=À'Ð=ÓJÐJÜ	ˆW‹˜Ò	Ø×!Ñ!Ø�I‰IÑA°G¸C¸R°LÔAÓAØØ�B‰Kóð 	ð
 r4   Úmethod.Ú	validatorÚmessageÚdefaultÚkwargsc                 óÆ  — |�		  ||«       	  | |fd|i|¤Ž\  }}|t        j                  k(  r	  ||«       ||fS ||fS # t         j                  $ r4 t        j                  d||d¬«       t	        dj                  |«      «      ‚w xY w# t         j                  $ rC}t        j                  d||d¬«       t        j                  t        |«      d¬«       Y d }~nd }~ww xY wŒÖ)	Nz>Encountered invalid default value "%s" when prompting for "%s"T)Úexc_infozInvalid default "{0}"rŽ   z/Validator rejected "%s" when prompting for "%s"F)Úpause)
r
   r   r7   r8   ÚAssertionErrorr_   r   r   ÚnotificationrW   )r‹   rŒ   r�   rŽ   r�   r    ÚrawÚerrors           r"   Ú_get_validatedr—   B  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	 ¿ABÂ	CÂ9CÃCÚargsc                 ó>   — t        t        j                  | g|¢­i |¤ŽS )a  Like `~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—   r   r   ©rŒ   r˜   r�   s      r"   Úvalidated_inputr›   _  s!   € ô œ,×1Ñ1°9ÐN¸tÒNÀvÑNÐNr4   c                 ó>   — t        t        j                  | 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ž   n  s!   € ô œ,×7Ñ7¸ÐTÀTÒTÈVÑTÐTr4   )FT)N)r/   )/Ú__doc__ÚloggingÚtextwrapr   Útypingr   r   r   r   r   r	   Úcertbotr
   r   r   Úcertbot._internalr   Úcertbot._internal.displayr\   Úcertbot.compatr   Úcertbot.displayr   Ú	getLoggerÚ__name__r7   r   rW   r#   ÚAccountr+   r3   Ú	Installerr@   r<   rR   r=   r9   rp   rs   rv   Úintr�   rn   r—   r›   rž   r†   r4   r"   ú<module>r­      sÊ  ðÙ 1Û Ý Ý Ý Ý Ý Ý Ý å Ý Ý Ý %Ý CÝ Ý 0à	ˆ×	Ñ	˜8Ó	$€ñ3�tð 3¨tð 3¸só 3ðl˜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ôUr4   