3 گa& @s,dZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z ddl Z dd l m Z dd lmZdd lmZdd lmZddlmZddlmZddlmZe jZe jZdZdZdZeddddZd1eeeeeddddZd2ee eeee eeffeeeeee eefdddZ d3eeeeeee eefdd d!Z!d4eeeeeeeeed$d%d&Z"d5eeeeeeeeee eeefd'd(d)Z#d6eeeeeee eefdd*d+Z$eeeedd,d-d.Z%Gd/d0d0Z&eee&ej'e(ej'e(<dS)7a$Certbot display. This module (`certbot.display.util`) or its companion `certbot.display.ops` should be used whenever: - Displaying status information to the user on the terminal - Collecting information from the user via prompts Other messages can use the `logging` module. See `log.py`. N) ModuleType)Any)cast)List)Optional)Tuple)Union)obj) FileDisplay)NoninteractiveDisplay) SIDE_FRAME)input_with_timeout)separate_list_input)summarize_domain_listHhelpesc)msgreturncCstjj|dddddS)zMDisplay a basic status message. :param str msg: message to display F)pausedecoratewrapN)r get_display notification)rr/usr/lib/python3.6/util.pynotify4srTF)messagerrforce_interactiverrcCstjj|||||ddS)aDisplays a notification and waits for user acceptance. :param str message: Message to display :param bool pause: Whether or not the program should pause for the user's confirmation :param bool wrap: Whether or not the application should wrap text :param bool force_interactive: True if it's safe to prompt the user because it won't cause any workflow regressions :param bool decorate: Whether to surround the message with a decorated frame )rrrrN)r rr)rrrrrrrrr=sr)rchoicesdefaultcli_flagrrcCstjj|||||dS)aDisplay a menu. .. todo:: This doesn't enable the help label/button (I wasn't sold on any interface I came up with for this). It would be a nice feature. :param str message: title of menu :param choices: Menu lines, len must be > 0 :type choices: list of tuples (tag, item) or list of descriptions (tags will be enumerated) :param default: default value to return, if interaction is not possible :param str cli_flag: option used to set this value with the CLI :param bool force_interactive: True if it's safe to prompt the user because it won't cause any workflow regressions :returns: tuple of (`code`, `index`) where `code` - str display exit code `index` - int index of the user's selection :rtype: tuple )r r!r)r rmenu)rrr r!rrrrr"Osr")rr r!rrcCstjj||||dS)aAccept input from the user. :param str message: message to display to the user :param default: default value to return, if interaction is not possible :param str cli_flag: option used to set this value with the CLI :param bool force_interactive: True if it's safe to prompt the user because it won't cause any workflow regressions :returns: tuple of (`code`, `input`) where `code` - str display exit code `input` - str of the user's input :rtype: tuple )r r!r)r rinput)rr r!rrrr input_textksr$YesNo)r yes_labelno_labelr r!rrcCstjj||||||dS)a~Query the user with a yes/no question. Yes and No label must begin with different letters, and must contain at least one letter each. :param str message: question for the user :param str yes_label: Label of the "Yes" parameter :param str no_label: Label of the "No" parameter :param default: default value to return, if interaction is not possible :param str cli_flag: option used to set this value with the CLI :param bool force_interactive: True if it's safe to prompt the user because it won't cause any workflow regressions :returns: True for "Yes", False for "No" :rtype: bool )r'r(r r!r)r ryesno)rr'r(r r!rrrrr)sr))rtagsr r!rrcCstjj|||||dS)a'Display a checklist. :param str message: Message to display to user :param list tags: `str` tags to select, len(tags) > 0 :param default: default value to return, if interaction is not possible :param str cli_flag: option used to set this value with the CLI :param bool force_interactive: True if it's safe to prompt the user because it won't cause any workflow regressions :returns: tuple of (`code`, `tags`) where `code` - str display exit code `tags` - list of selected tags :rtype: tuple )r r!r)r r checklist)rr*r r!rrrrr+sr+cCstjj||||dS)aDisplay a directory selection screen. :param str message: prompt to give the user :param default: default value to return, if interaction is not possible :param str cli_flag: option used to set this value with the CLI :param bool force_interactive: True if it's safe to prompt the user because it won't cause any workflow regressions :returns: tuple of the form (`code`, `string`) where `code` - display exit code `string` - input entered by the user )r r!r)r rdirectory_select)rr r!rrrrr,sr,)promptr r!rrcCs dj|}|r|dj|7}dS)a0Verify that provided arguments is a valid display call. :param str prompt: prompt for the user :param default: default answer to prompt :param str cli_flag: command line option for setting an answer to this question :param bool force_interactive: if interactivity is forced z)Invalid display call for this prompt: {0}z7 You can set an answer to this prompt with the {0} flagN)format)r-r r!rrrrrassert_valid_calls r/c@sdeZdZdZeddddZeedddZeedd d d Z eddd d Z e edddZ dS)_DisplayUtilDeprecationModulez Internal class delegating to a module, and displaying warnings when attributes related to deprecated attributes in the certbot.display.util module. N)modulercCs||jd<dS)N_module)__dict__)selfr1rrr__init__sz&_DisplayUtilDeprecationModule.__init__)attrrc Cs*|d krtjd j|td d t|j|S)Nr r r r rrWIDTHHELPESCzT{0} attribute in certbot.display.util module is deprecated and will be removed soon.) stacklevel) r r r r rrr7r8r9)warningswarnr.DeprecationWarninggetattrr2)r4r6rrr __getattr__s  z)_DisplayUtilDeprecationModule.__getattr__)r6valuercCst|j||dS)N)setattrr2)r4r6rArrr __setattr__sz)_DisplayUtilDeprecationModule.__setattr__cCst|j|dS)N)delattrr2)r4r6rrr __delattr__sz)_DisplayUtilDeprecationModule.__delattr__)rcCsdgt|jS)Nr2)dirr2)r4rrr__dir__sz%_DisplayUtilDeprecationModule.__dir__) __name__ __module__ __qualname____doc__rr5strrr@rCrErrGrrrrr0s r0)TTFT)NNF)NNF)r%r&NNF)NNF)NNF))rKsystypesrZtypingrrrrrrr<Zcertbot._internal.displayr Zcertbot._internal.display.objr r r Zcertbot._internal.display.utilr rrZOKZCANCELr7r8r9rLrboolrintr"r$r)r+r,r/r0modulesrHrrrr sN               B($6(