8f(,6ddlmZmZmZmZmZmZmZmZddl m Z ddl m Z ddl mZmZedZedZGdd eZGd d eZGd d eeZGddeeZGddeeZGddeeZGddeeZedkrddlm Z e!ddr e!ddZ"e"dkre"dkrn e d0e de" e!d d!Z#e$e#dkrn e d"3e d#e#e!d$gd%&Z%e d'e%d)Se d(d)Sd)S)*)AnyGenericListOptionalTextIOTypeVarUnionoverload) get_console)Console)TextTextType PromptType DefaultTypeceZdZdZdS) PromptErrorz/Exception base class for prompt related errors.N)__name__ __module__ __qualname____doc__w/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich/prompt.pyrr s9999rrc.eZdZdZdeddfdZdefdZdS)InvalidResponsezException to indicate a response was invalid. Raise this within process_response() to indicate an error and provide an error message. Args: message (Union[str, Text]): Error message. messagereturnNc||_dSNr)selfrs r__init__zInvalidResponse.__init__s  rc|jSr r!r"s r__rich__zInvalidResponse.__rich__s |r)rrrrrr#r&rrrrrs[T(rrceZdZUdZeZeed<dZdZ dZ dZ e e eed< d)dd dd d d d ed e edede e edededdfdZee d)dd dd d ddd ed e edede e edededede edeeeffdZee d)dd dd d ddd ed e edede e ededede edefdZe d)dd dd d dddd ed e edede e edededede edefdZdedefdZdedefdZe d*d ed edede edef dZdedefdZdedefd Zded!e ddfd"Z!d+d#Z"edd$de edefd%Z#edd$dede edeeeffd&Z#ddd'dede edefd(Z#dS), PromptBaseaAsk the user for input until a valid response is received. This is the base class, see one of the concrete classes for examples. Args: prompt (TextType, optional): Prompt text. Defaults to "". console (Console, optional): A Console instance or None to use global console. Defaults to None. password (bool, optional): Enable password input. Defaults to False. choices (List[str], optional): A list of valid choices. Defaults to None. show_default (bool, optional): Show default in prompt. Defaults to True. show_choices (bool, optional): Show choices in prompt. Defaults to True. response_typez*[prompt.invalid]Please enter a valid valuezA[prompt.invalid.choice]Please select one of the available optionsz: NchoicesFTconsolepasswordr* show_default show_choicespromptr-r.r/r0rc|p t|_t|trt j|dn||_||_|||_||_ ||_ dS)Nr1style) r r- isinstancestrr from_markupr1r.r*r/r0)r"r1r-r.r*r/r0s rr#zPromptBase.__init__5ss/+-- &#&& D V8 4 4 4 4 !  "DL((r)r-r.r*r/r0streamdefaultr8cdSr r) clsr1r-r.r*r/r0r9r8s raskzPromptBase.askKs  rcdSr r)r;r1r-r.r*r/r0r8s rr<zPromptBase.ask[s  r.)r-r.r*r/r0r9r8c>|||||||} | ||S)aShortcut to construct and run a prompt loop and return the result. Example: >>> filename = Prompt.ask("Enter a filename") Args: prompt (TextType, optional): Prompt text. Defaults to "". console (Console, optional): A Console instance or None to use global console. Defaults to None. password (bool, optional): Enable password input. Defaults to False. choices (List[str], optional): A list of valid choices. Defaults to None. show_default (bool, optional): Show default in prompt. Defaults to True. show_choices (bool, optional): Show choices in prompt. Defaults to True. stream (TextIO, optional): Optional text file open for reading to get input. Defaults to None. r,r9r8r) r;r1r-r.r*r/r0r9r8_prompts rr<zPromptBase.askjsC6# %%    wwv6666rc*td|ddS)zTurn the supplied default in to a Text instance. Args: default (DefaultType): Default value. Returns: Text: Text containing rendering of default value. ()prompt.default)r)r"r9s rrender_defaultzPromptBase.render_defaultsNNNN$4555rc|j}d|_|jrR|jrKd|j}d|d}|d||d|dkrb|jr[t|t|j fr?|d| |}||||j |S)zMake prompt text. Args: default (DefaultType): Default value. Returns: Text: Text to display in prompt. r+/[] zprompt.choices.) r1copyendr0r*joinappendr/r5r6r)rE prompt_suffix)r"r9r1_choicesr*_defaults r make_promptzPromptBase.make_prompts!!##   5 5xx --H%(oooG MM#    MM'#3 4 4 4 sNN! 7S$*<$=>>  MM#   **733H MM( # # # d())) rc2||||S)zGet input from user. Args: console (Console): Console instance. prompt (TextType): Prompt text. password (bool): Enable password entry. Returns: str: String from user. )r.r8)input)r;r-r1r.r8s r get_inputzPromptBase.get_inputs$}}Vhv}FFFrvaluecJ|jJ||jvS)zCheck value is in the list of valid choices. Args: value (str): Value entered by user. Returns: bool: True if choice was valid, otherwise False. )r*stripr"rVs r check_choicezPromptBase.check_choices'|'''{{}} ,,rc|} ||}n"#t$rt|jwxYw|j)||st|j|S)aProcess response from user, convert to prompt type. Args: value (str): String typed by user. Raises: InvalidResponse: If ``value`` is invalid. Returns: PromptType: The value to be returned from ask method. )rXr) ValueErrorrvalidate_error_messager*rZillegal_choice_message)r"rV return_values rprocess_responsezPromptBase.process_responses  ?'+'9'9%'@'@LL ? ? ?!$"=>> > ? < #D,=,=e,D,D #!$"=>> >s ,A errorc:|j|dS)zCalled to handle validation error. Args: value (str): String entered by user. error (InvalidResponse): Exception instance the initiated the error. N)r-print)r"rVras ron_validate_errorzPromptBase.on_validate_errors  5!!!!!rcdS)z,Hook to display something before the prompt.Nrr%s r pre_promptzPromptBase.pre_promptsrr8cdSr r)r"r8s r__call__zPromptBase.__call__s rcdSr r)r"r9r8s rrizPromptBase.__call__s  rr?cB |||}||j||j|}|dkr|dkr|S ||}|S#t $r }|||Yd}~d}~wwxYw)zRun the prompt loop. Args: default (Any, optional): Optional default value. Returns: PromptType: Processed value. Trgr+.N)rfrRrUr-r.r`rrd)r"r9r8r1rVr_ras rrizPromptBase.__call__s $ OO   %%g..FNN4<vNVVE{{w#~~ $#44U;; $# #   &&ue444 sA44 B>BB)r+r )rN)$rrrrr6r)type__annotations__r]r^rOr*rrrr boolr# classmethodr rrr rr<rrrErRrUrZr`rrdrfrirrrr(r(s  M4IKM#'GXd3i ''')&*'+!!))))'" )  ) $s)$ ))) )))),   &*'+!!#'      '"    $s)$            {J& '    X[     &*'+!!#'      '"    $s)$              X[  "7&*'+!!#'"7"7"7"7'" "7  "7 $s)$ "7"7"7"7 "7 "7"7"7["7H 6k 6d 6 6 6 6;4> $( GGGG G  G GGG[G& -# -$ - - - -cj."s"?"t"""";;;;59   (6"2 j   X BF   % /7/? z;& '   X *-$$$3$hv6F$RU$$$$$$rr(ceZdZdZeZdS)PromptzbA prompt that returns a str. Example: >>> name = Prompt.ask("Enter your name") N)rrrrr6r)rrrrqrqsMMMrrqceZdZdZeZdZdS) IntPromptzA prompt that returns an integer. Example: >>> burrito_count = IntPrompt.ask("How many burritos do you want to order") z3[prompt.invalid]Please enter a valid integer numberN)rrrrintr)r]rrrrsrs*s'MRrrsceZdZdZeZdZdS) FloatPromptzyA prompt that returns a float. Example: >>> temperature = FloatPrompt.ask("Enter desired temperature") z%[prompt.invalid]Please enter a numberN)rrrrfloatr)r]rrrrvrv6s'MDrrvcZeZdZUdZeZdZddgZee e d<de de fdZ d e defd Zd S) ConfirmzuA yes / no confirmation prompt. Example: >>> if Confirm.ask("Continue"): run_job() z#[prompt.invalid]Please enter Y or Nynr*r9rcP|j\}}t|rd|dnd|ddS)z8Render the default as (y) or (n) rather than True/False.rBrCrDr3)r*r)r"r9yesnos rrEzConfirm.render_defaultOs:,R'8JJJJJy2yyy@PQQQQrrVc|}||jvrt|j||jdkS)zConvert choices to a bool.r)rXlowerr*rr]rYs rr`zConfirm.process_responseTsJ ##%%  $ $!$"=>> > Q''rN)rrrrrnr)r]r*rr6rmrrrEr`rrrryryBsMBsGT#Y###RkRdRRRR (c(d((((((rry__main__)rczRun [i]prompt[/i] tests?T)r9z6:rocket: Enter a number between [b]1[/b] and [b]10[/b] z=:pile_of_poo: [prompt.invalid]Number must be between 1 and 10znumber=z=Please enter a password [cyan](must be at least 5 characters))r.z"[prompt.invalid]password too shortz password=z Enter a fruit)appleorangepear)r*zfruit=z[b]OK :loudly_crying_face:N)&typingrrrrrrr r r+r r-r textrrrr Exceptionrrr(r6rqrtrsrwrvrnryrpip._vendor.richrcr<resultr.lenfruitrrrrs]QQQQQQQQQQQQQQQQQQQQ W\ " " gm$$ :::::):::     k   }$}$}$}$}$$}$}$}$@     Z_    S S S S S 3 S S S E E E E E*U# E E E(((((j(((4 z&&&&&&{{-t{<<, S]]HRS#F{{v|| EQ R R R  S    !!! 8zzO"Hs8}}!! E6 7 7 7 8 &(&&''' ?4O4O4O PP  u  !!!!! *+++++7r