o 6a 0 @sdZddlZddlmZddlmZddlmZddlmZddl m Z ddl mZ e eZd/d d Zd d Zd0d dZd0ddZddZddZd0ddZd1ddZddZddZddZd ed!ed"ed#ed$df d%d&Zd'd(Zd0d)d*Zd+d,Z d-d.Z!dS)2z+Contains UI methods for LE user operations.N)indent)errors)util)osFTcCsd}d}d}|r|r||7}d}nd}nd} ztj|r ||n|dd\}}Wntjy7d}t|w|tjkrI|rDtdtd t|rP|S|rX||}d}t|}q) aJPrompt 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. FTforce_interactivezoYou should register before running non-interactively, or provide --agree-tos and --email flags.zHAn e-mail address or --register-unsafely-without-email must be provided.z#An e-mail address must be provided.) display_util input_textrMissingCommandlineFlagOKErrorr safe_emailbool)invalidoptionalinvalid_prefixmsgunsafe_suggestionsuggest_unsafecodeemailr5/usr/lib/python3/dist-packages/certbot/display/ops.py get_emails>     rcCs8dd|D}tjd|dd\}}|tjkr||SdS)zChoose an account. :param list accounts: Containing at least one :class:`~certbot._internal.account.Account` cSsg|]}|jqSr)slug).0accrrr Lsz"choose_account..zPlease choose an accountTrN)rmenur )accountslabelsrindexrrrchoose_accountDs  r"cCs*tj||dd\}}|tjkr|r|SgS)zDisplay screen to let user pick one or multiple values from the provided list. :param list values: Values to select from :returns: List of selected values :rtype: list T)tagsr)r checklistr )valuesquestionritemsrrr choose_valuesTs r(cCsZ|dur tdtSt|}t|}|stSt||\}}|tjkr+|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` Nz$No installer, picking names manually) loggerdebug_choose_names_manuallylist get_all_namesget_valid_domains _filter_namesrr ) installerr&domainsnamesrrrr choose_namescs  r3c Cs:g}|D]}z |t|WqtjyYqw|S)zHelper 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 )appendrenforce_domain_sanityrConfigurationError)r1 valid_domainsdomainrrrr.sr.cCst|dddS)zSort FQDNs by SLD (and if many, by their subdomains) :param list FQDNs: list of domain names :returns: Sorted list of domain names :rtype: list cSs|ddddddS)N.)split)fqdnrrrsz_sort_names..)key)sorted)FQDNsrrr _sort_namessrBcCs>t|}|r |}nd}tj||ddd\}}|dd|DfS)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 z1Which names would you like to activate HTTPS for? --domainsT)r#cli_flagrcSsg|]}t|qSr)str)rsrrrrsz!_filter_names..)rBrr$)r2override_question sorted_namesr&rrrrr/s  r/c Cs tj|dddd\}}|tjkri}d}zt|}Wnty-g}dtj}Ynwt |D]&\}}z t |||<Wq2t j yX}z t|||<WYd}~q2d}~ww|r|dtj}|D]\} } |d tj| | }qe|d tj}|rtj|dd } | rtSgS|SgS) zManually 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)rCT)rDrrIziInternationalized domain names are not presently supported.{0}{0}Would you like to re-enter the names?{0}Nz,sz#_gen_https_names..Nr:z, and https://rI)lenrMjoinr]rrrr\s    r\c Ks|dur#z||Wntjy"tjd||ddtd|w ||fd|i|\}}|tjkrdz ||||fWStjyc}ztjd||ddtjt |ddWYd}~n d}~ww||fSq$) Nz>Encountered invalid default value "%s" when prompting for "%s"T)exc_infozInvalid default "{0}"defaultz/Validator rejected "%s" when prompting for "%s"F)pause) rr r)r*AssertionErrorrMrr notificationrE)method validatormessagertkwargsrrawerrorrrr_get_validated3s8   r~cOttj|g|Ri|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 ryargsr{rrrvalidated_inputNs rcOr)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~rdirectory_selectrrrrvalidated_directory\s r)FT)N)rI)"__doc__loggingtextwraprcertbotrrcertbot._internal.displayrJcertbot.compatrcertbot.displayr getLogger__name__r)rr"r(r3r.rBr/r+r^r`rbrEintrmr\r~rrrrrrs2        6   6