M/eWtdZddlZddlZddlmZddlmZddlmZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZdd lmZddlmZddlmZej*eZdZ dZ dZ GddZeZe dZGddZGddZde eeffdZ de eefddfdZ!y)zFThis modules define the actual display implementations used in CertbotN)Any)Iterable)List)Optional)TextIO)Tuple)TypeVar)Union)errors) constants) completer)util)osokcancelzO- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ceZdZddZy)_DisplayServiceNcd|_yNdisplay)selfs ?/usr/lib/python3/dist-packages/certbot/_internal/display/obj.py__init__z_DisplayService.__init__)s LP )returnN)__name__ __module__ __qualname__rrrrr(sQrrTceZdZdZdededdffd Z d#deded eded eddf d Z d$ded e e e eefe efd e ede ede ede e de ededede ee ffdZ d%dede ede ededede eeff dZ d&dededede ede edededefdZ d%dede ede e ede ededede ee effdZdede ede edede ef dZdedefdZ d%dede ede ededede eeff dZdee ee fde ede efdZded e e e eefe efddfd Zd!e de ee ffd"ZxZS)' FileDisplayzFile-based display.outfileforce_interactiverNcLt|||_||_d|_y)NF)superrr$r%skipped_interaction)rr$r% __class__s rrzFileDisplay.__init__6s%  !2#( rmessagepausewrapdecoratec|rtj|}tjd||jj |rdnddz|rdndzj tjt||jj|r=|j|rtjdy tjdy y ) 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 Notifying user: %s{line}{frame}{line} {msg}{line} {frame}{line}lineframemsgzPress Enter to Continuez!Not pausing for user confirmationN) r wrap_linesloggerdebugr$writeformatrlinesep SIDE_FRAMEflush _can_interactinput_with_timeout)rr*r+r,r%r-s r notificationzFileDisplay.notification<s oog.G )73 '/#R !)or3RZZzwG   !!"34''(AB @A rchoicesok_label cancel_label help_labeldefaultcli_flag unused_kwargsc  |j||||} | t| fS|j|||jt |\} } | | dz fS)aCDisplay 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 one exists) :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 )_return_defaultOK _print_menu_get_valid_int_anslen) rr*rCrDrErFrGrHr%rIreturn_defaultcode selections rmenuzFileDisplay.menu]sc4--gwJ[\  %~% % '*11#g,?iY]""rc |j||||}|t|fStjd|zdz}tj|}|dvrt dfSt|fS)aAccept input from the user. :param str message: message to display to the user :param default: default value to return (if one exists) :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 z%s (Enter 'c' to cancel): )cCz-1)rLrMrr8rACANCEL)rr*rGrHr%rIrQanss rinputzFileDisplay.inputsr --gwJ[\  %~% %//"="GH3N%%g. * 4< 3wr yes_labelno_labelc |j||||}||Stj|}|jj dj t jtt jz||jj tjdj tj|tj|} | j|djs"| j|djry| j|djs"| j|djry)aQuery 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 one exists) :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 z{0}{frame}{msg}{0}{frame})r6r7Tz {yes}/{no}: )yesnorF)rLrr8r$r;r<rr=r>r?rAparens_around_char startswithlowerupper) rr*r\r]rGrHr%rIrQrZs ryesnozFileDisplay.yesnos3(--gwJ[\  %! !//'* 6== JJj2::57>D E )).*?*?++I6**84+@+67C y|1134y|1134x{0023x{0023rtagsc |j||||}|t|fS |j|||jdd\}} |tk(r| j s.dj dt dt|dzD} tj| } |j| |} | r|| fS|jjdtjz|jjn|gfS)aCDisplay 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 one exists) :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 TzrSelect the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown)r%rVc32K|]}t|ywr)str).0xs r z(FileDisplay.checklist..s"Ia3q6"IsrKz!** Error - Invalid selection **%s)rLrMrNr[stripjoinrangerPrseparate_list_input_scrub_checklist_inputr$r;rr=r?) rr*rfrGrHr%rIrQrRrZindices selected_tagss r checklistzFileDisplay.checklists$--gwJ[\  %~% %   Wd + $G6:#;ID# rzyy{(("I5CIaK3H"IIC2237 $ ; ;GT J  .. ""7"**DF ""$Rx'rpromptc|j|ry| enumeraterr8r?)rr*rCrWidescr7s rrNzFileDisplay._print_menuUs z'!*e43:;a!A$s1Q4&);G; bjj\'2::,?@ : 23!!, +GAtCr$.C LL  ts3 4 LL  rzz *  + : 23 r?)rr*r+r,r-rIs rrBz"NoninteractiveDisplay.notificationsz oog.G )73 '/#R !)or3RZZzwG  rrCrDrErFrGc T||j||dt|zt|fS)a_Avoid displaying a menu. :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 int default: the default choice :param dict kwargs: absorbs various irrelevant labelling arguments :returns: tuple of (`code`, `index`) where `code` - str display exit code `index` - int index of the user's selection :rtype: tuple :raises errors.MissingCommandlineFlag: if there was no default z Choices: )rreprrM) rr*rCrDrErFrGrHrIs rrTzNoninteractiveDisplay.menus1* ?(((K$w- 0 :param dict kwargs: absorbs default_status arg :returns: tuple of (`code`, `tags`) where `code` - str display exit code `tags` - list of selected tags :rtype: tuple z? ?)rrnrM)rr*rfrGrHrIs rrtzNoninteractiveDisplay.checklists5 ?(((DIIdOcrrr!r#rrrr rrrsL '/*   8 $ 3 9 QQ   CLbbJ I6I6X U;(==> {,AABtr