4V=jUddlmZddlmZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlm Z e j!rddl"m#Z#e j$dZ%e&Z'de(d<iddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7Z)d8Z*d9Z+dd>Z,dd@Z-ddEZ. dddPZ/ddRZ0 dddZZ1 ddd]Z2 ddd`Z3 ddddZ4e j5ddFdGddFdedfdgdhd#ddddi dd{Z6e j5 dddZ6 dddZ6ddZ7dddZ8 dddZ9ddZ: dddZ;e j5 dddZde(d<dddZ?ddZ@dddZAdS)) annotationsN)AbstractContextManager)redirect_stdout)gettext)isatty strip_ansi)WIN)Abort) UsageError)resolve_color_default)Choice) convert_type) ParamType)echo)LazyFile ProgressBarVt.Callable[[str], str]visible_prompt_funcblackredgreen yellow!blue"magenta#cyan$white%reset' bright_blackZ bright_red[ bright_green\ bright_yellow] bright_blue^bright_magenta_ bright_cyan` bright_whiteazz'***'messagestrvaluereturnc|t|t}|r1tjdtj|dt|}|S)aReplace occurrences of ``value`` in ``message`` with a fixed mask. Both ``repr(value)`` (the form built-in :class:`ParamType` errors use via ``{value!r}``) and the raw value are masked. The raw-value pass uses word-boundary lookarounds so a substring like ``"1"`` does not match inside ``"10"``, and ``"ent"`` does not match inside ``"Authentication"``. The empty string is skipped to avoid matching at every boundary. z(?>G  & /ry'' / / /1CW   Npromptc4ddl}||S)Nr)getpass)rIrKs rFhidden_prompt_funcrLNsNNN ??6 " ""rHfunctexterrboolctr-t|ddd|||ddS|rcrtnt} t||S#ttf$r#rt dt dwxYw)NrO)rLrrWKeyboardInterruptEOFErrorrr )rNfrOrqs rF prompt_funczprompt..prompt_funcst", E  2E $#AtS11 1!8, $ $ $ $Ts####''t #  $s $4ANTzRepeat for confirmationzError: {message})r;ryz+Error: The two entered values do not match.rNr<r>r<)rri_r rGr;rformat)rNr[rqrrr^rtrvrYrOr]r}rIr=resulter;value2is_emptys ` ` rFrIrIs| $ $ $ $ $ $ $!$00  m\7L$FP $ & &"#$=">"> +,?OOH K''E $   Z&&FF   >HW(E:::aiG %&&--g->>C H H H H HHHH # M  [!455F y/ZH     F??M Q< = =3GGGG/Hs, A88 CACC bool | Noneabortct||||dn|rdnd} tt||}n$#t t f$rtdwxYw|dvrd}n1|dvrd}n*| |d kr|}nttd |  |r|st|S) aPrompts for confirmation (yes/no question). If the user aborts the input by sending a interrupt signal this function will catch it and raise a :exc:`Abort` exception. :param text: the question to ask. :param default: The default value to use when no input is given. If ``None``, repeat until input is given. :param abort: if this is set to `True` a negative answer aborts the exception by raising :exc:`Abort`. :param prompt_suffix: a suffix that should be added to the prompt. :param show_default: shows or hides the default value in the prompt. :param err: if set to true the file defaults to ``stderr`` instead of ``stdout``, the same as with echo. .. versionchanged:: 8.3.1 A space is no longer appended to the prompt. .. versionchanged:: 8.0 Repeat until input is given if ``default`` is ``None``. .. versionadded:: 4.0 Added the ``err`` parameter. Nzy/nzY/nzy/NT)yyes)nnoFzError: invalid inputry) rirWrlowerstriprzr{r rr) rNr[rrvrYrOrIr=rvs rFconfirmrs @ 'BuuU F $$%8&#FFLLNNTTVVEE!8, $ $ $''t # $ L BB k ! !BB  Ub[[BB )** 4 4 4 4   Rgg Is :A!A9colort.ContextManager[t.TextIO]cDddlm}t|}||S)zContext manager. Yields a writable file-like object which can be used as an output pager. .. versionadded:: 8.4.0 :param color: controls if the pager supports ANSI colors or not. The default is autodetection. r)get_pager_filer) _termui_implrr)rrs rFrr-s6-,,,,, !% ( (E > & & &&rHtext_or_generator=cabc.Iterable[str] | t.Callable[[], cabc.Iterable[str]] | strNonectj|rtjd|}n;t |t r|g}n"t tjd|}d|D}t|5}tj |dD]+}| || , ddddS#1swxYwYdS)aThis function takes a text and shows it via an environment specific pager on stdout. .. versionchanged:: 3.0 Added the `color` flag. :param text_or_generator: the text to page, or alternatively, a generator emitting the text to page. :param color: controls if the pager supports ANSI colors or not. The default is autodetection. z"t.Callable[[], cabc.Iterable[str]]zcabc.Iterable[str]c3bK|]*}t|tr|nt|V+dSN)rdr<).0els rF z!echo_via_pager..Xs;IIJr3//tddlm}|at|S)aFetches a single character from the terminal and returns it. This will always return a unicode character and under certain rare circumstances this might return more than one character. The situations which more than one character is returned is when for whatever reason multiple characters end up in the terminal buffer or standard input was not actually a terminal. Note that this will always read from the terminal, even if something is piped into the standard input. Note for Windows: in rare cases when typing non-ASCII characters, this function might wait for a second character and then return both at once. This is because certain Unicode characters look like special-key markers. .. versionadded:: 2.0 :param echo: if set to `True`, the character read will also show up on the terminal. The default is to not show it. Nr)getchar)r$rr&)rr|s rFr&r&ns-,...... D>>rHAbstractContextManager[int]c"ddlm}|S)Nr) raw_terminal)rr))r|s rFr)r)s////// 133JrHinfoc`ttjrttjsdS|t d} |rt |d| t n#ttf$rYnwxYw|rt |dSdS#|rt |wwxYw)a(This command stops execution and waits for the user to press any key to continue. This is similar to the Windows batch "pause" command. If the program is not run through a terminal, this command will instead do nothing. .. versionadded:: 2.0 .. versionadded:: 4.0 Added the `err` parameter. :param info: The message to print before pausing. Defaults to ``"Press any key to continue..."``. :param err: if set to message goes to ``stderr`` instead of ``stdout``, the same as with echo. NzPress any key to continue...FrSry) rrUstdinrrrr&rzr{)r*rOs rFpauser-s #)  F3:$6$6 |/00   * %S ) ) ) )  IIII!8,    D    SMMMMMM  4  SMMMMM s0BA+*B+A?<B>A??BB-)r;r<r=r<r>r<)rIr<r>r<)rMrrNr<rOrPr>r<)FNTN)rNr<rXr<rYrZr[r\r]rPr^r_r>r<)r[rjr>rj) NFFNNrpTFT)rNr<r[r\rqrPrrrZr^rsrtrurvr<rYrZrOrPr]rPr>rj)FFrpTF)rNr<r[rrrPrvr<rYrPrOrPr>rPr)rrr>r)rrrrr>r)rrrrrrPrrPrrrrPrr<rr<rr<rr<rrrrrrrrr>r)NNNFTNFNrrrrr&NNr)"rrrrrrrrPrrPrrrrPrrrr<rr<rr<rr<rrrrrrrrr>r)r>r)r)rrrrr>r<) NNNNNNNNNNT)rNrjrrrrrrrrrrrrrrrrrrrrr)rPr>r<r~)NNTFN)r;r\rrrTrPrOrPrrrrjr>r)NNFr ) rNr r rr r rrPrr<r>r)NNTr ) rNr<r rr r rrPrr<r>r)NNNTr N)rNrr rr r rrPrr<rrr>r)rNrr rr r rrPrr<rrr>r)FF)rr<rrPr rPr>r)F)rrPr>r<)r>r')NF)r*rrOrPr>r)B __future__rcollections.abcabccabcrrmrrCrUtypingr contextlibrrrr_compatrr r exceptionsr r globalsrtypesrrrutilsrr TYPE_CHECKINGrrTypeVarrinputr__annotations__rrrBrGrLrWrirhrIrrroverloadrrrrrrrr#r$r&r)r-rrHrFr>s"""""""  ------&&&&&& """"""******?*)))))) AIcNN/43333 R 2 R b   B  r  B R RB"BR2b 2!"B# &$#### . % $( $!&+,026#nHnHnHnHnHf! 88888x'''''*     F $8  &(, $@D8 ! *)- $@D8 !\\\\\~ ' ' ' '-----3726! !%~~~~~B    !"& AAAAAD)-  )-  )-04  ,0)-04 77777t33333>,0////< rH