ó
    àÅŸgÏ?  ã                   óÎ   • S r SSKrSSKrSSKJr  SSKJrJrJrJ	r	J
r
Jr  SSKJrJr  SrSr \R"                  " \5      rSS jrSS	 jrSS
 jrS rS r\4S jr " S S\5      rg)a;  
Interactive terminal prompts.

The :mod:`~humanfriendly.prompts` module enables interaction with the user
(operator) by asking for confirmation (:func:`prompt_for_confirmation()`) and
asking to choose from a list of options (:func:`prompt_for_choice()`). It works
by rendering interactive prompts on the terminal.
é    N)Úinteractive_prompt)ÚHIGHLIGHT_COLORÚ
ansi_stripÚ	ansi_wrapÚconnected_to_terminalÚterminal_supports_colorsÚwarning)ÚformatÚconcatenate)	ÚMAX_ATTEMPTSÚTooManyInvalidRepliesÚloggerÚprepare_friendly_promptsÚprepare_prompt_textÚprompt_for_choiceÚprompt_for_confirmationÚprompt_for_inputÚretry_limité
   c                 óŽ  • [        U SS9nU(       a  SOUb  SOSnUS[        U[        S9-  -  n[        R                  S	[	        U5      R                  5       5        [        5        HÜ  n[        US
USS9nUR                  5       S;   a  [        R                  SU5          gUR                  5       S;   a  [        R                  SU5          gU(       d&  Ub#  [        R                  SU(       a  SOS5        Us  $ U(       a  SU-  OSn[        R                  SU(       a  SOSUU[        5        [        SU(       a  SOS
US9  MÞ     g)a€  
Prompt the user for confirmation.

:param question: The text that explains what the user is confirming (a string).
:param default: The default value (a boolean) or :data:`None`.
:param padding: Refer to the documentation of :func:`prompt_for_input()`.
:returns: - If the user enters 'yes' or 'y' then :data:`True` is returned.
          - If the user enters 'no' or 'n' then :data:`False`  is returned.
          - If the user doesn't enter any text or standard input is not
            connected to a terminal (which makes it impossible to prompt
            the user) the value of the keyword argument ``default`` is
            returned (if that value is not :data:`None`).
:raises: - Any exceptions raised by :func:`retry_limit()`.
         - Any exceptions raised by :func:`prompt_for_input()`.

When `default` is :data:`False` and the user doesn't enter any text an
error message is printed and the prompt is repeated:

>>> prompt_for_confirmation("Are you sure?")
 <BLANKLINE>
 Are you sure? [y/n]
 <BLANKLINE>
 Error: Please enter 'yes' or 'no' (there's no default choice).
 <BLANKLINE>
 Are you sure? [y/n]

The same thing happens when the user enters text that isn't recognized:

>>> prompt_for_confirmation("Are you sure?")
 <BLANKLINE>
 Are you sure? [y/n] about what?
 <BLANKLINE>
 Error: Please enter 'yes' or 'no' (the text 'about what?' is not recognized).
 <BLANKLINE>
 Are you sure? [y/n]
T©Úboldz[Y/n]Nz[y/N]z[y/n]z %s )Úcolorz5Requesting interactive confirmation from terminal: %rÚ ©ÚpaddingÚstrip)ÚyÚyesz#Confirmation granted by reply (%r).)ÚnÚnoz"Confirmation denied by reply (%r).Fú,Default choice selected by empty reply (%r).ÚgrantedÚdeniedzthe text '%s' is not recognizedúthere's no default choiceú&Got %s reply (%s), retrying (%i/%i) ..ÚinvalidÚemptyz6{indent}Error: Please enter 'yes' or 'no' ({details}).Ú )ÚindentÚdetails)r   r   r   Údebugr   Úrstripr   r   Úlowerr   r	   )ÚquestionÚdefaultr   Úprompt_textÚhintÚattemptÚreplyr+   s           ÚV/var/www/blue/EV-Temp_rev04/venv/lib/python3.13/site-packages/humanfriendly/prompts.pyr   r   6   s   € ôL & h°TÑ:€Kæ‰7¨gÑ.A¡7Àw€DØ�6Ô/°¼OÑLÑLÑL€Kä
‡L�LÐHÌ*ÐU`ÓJa×JhÑJhÓJjÔkÜ–=ˆÜ  ¨b¸'ÈÑNˆØ�;‰;‹=˜LÓ(Ü�L‰LÐ>ÀÔFÙØ�[‰[‹]˜kÓ)Ü�L‰LÐ=¸uÔEÙÞ˜WÑ0Ü�L‰LÐGÞ&-™°8ô=àŠNö  ð 9¸5Ò@Ø%@ð ä�L‰LÐAÞ&+™°¸'Ø ¤,ô0ô ÐLÞ")™3¨r¸7ôDò% !ó    c                 ó¤  • U(       a  SOSn[        U 5      n [        U 5      S:X  a  [        R                  SU S   5        U S   $ U (       d  [	        S5      eU(       a  SOSR                  SR                  [        U SS	9 VVs/ sH  u  pES
XE4-  XQ:X  a  SOS-   PM     snn5      S/5      n[        USS9n[        R                  S[        [        [        U 5      5      5        [        5        GHÚ  n[        USUSS9nU(       d  Ub  [        R                  SU5        Us  $ UR                  5       (       aF  [        U5      S-
  n	SU	s=::  a  [        U 5      :  a"  O  O[        R                  SX	   U5        X	   s  $ / n
U  Hm  nUR                  5       nUR                  5       nX¼:X  a  [        R                  SU5        Us  s  $ X¼;   d  MK  [        U5      S:”  d  M\  U
R!                  U5        Mo     [        U
5      S:X  a!  [        R                  SU
S   U5        U
S   s  $ U
(       a  [#        SU[        U
5      5      nOVUR                  5       (       a  [#        S[        U5      5      nO+U(       a"  UR%                  5       (       d  [#        SU5      nOSn[        R                  SU(       a  SOSUU[&        5        [)        SX=5        GMÝ     gs  snnf )a~  
Prompt the user to select a choice from a group of options.

:param choices: A sequence of strings with available options.
:param default: The default choice if the user simply presses Enter
                (expected to be a string, defaults to :data:`None`).
:param padding: Refer to the documentation of
                :func:`~humanfriendly.prompts.prompt_for_input()`.
:returns: The string corresponding to the user's choice.
:raises: - :exc:`~exceptions.ValueError` if `choices` is an empty sequence.
         - Any exceptions raised by
           :func:`~humanfriendly.prompts.retry_limit()`.
         - Any exceptions raised by
           :func:`~humanfriendly.prompts.prompt_for_input()`.

When no options are given an exception is raised:

>>> prompt_for_choice([])
Traceback (most recent call last):
  File "humanfriendly/prompts.py", line 148, in prompt_for_choice
    raise ValueError("Can't prompt for choice without any options!")
ValueError: Can't prompt for choice without any options!

If a single option is given the user isn't prompted:

>>> prompt_for_choice(['only one choice'])
'only one choice'

Here's what the actual prompt looks like by default:

>>> prompt_for_choice(['first option', 'second option'])
<BLANKLINE>
  1. first option
  2. second option
<BLANKLINE>
 Enter your choice as a number or unique substring (Control-C aborts): second
<BLANKLINE>
'second option'

If you don't like the whitespace (empty lines and indentation):

>>> prompt_for_choice(['first option', 'second option'], padding=False)
 1. first option
 2. second option
Enter your choice as a number or unique substring (Control-C aborts): first
'first option'
r)   r   é   z=Skipping interactive prompt because there's only option (%r).r   z,Can't prompt for choice without any options!z

Ú
)Ústartz %i. %sz (default choice)zFEnter your choice as a number or unique substring (Control-C aborts): Tr   z=Requesting interactive choice on terminal (options are %s) ..r   Nr"   z+Option (%r) selected by numeric reply (%s).z,Option (%r) selected by reply (exact match).z6Option (%r) selected by reply (substring match on %r).z*text '%s' matches more than one choice: %sznumber %i is not a valid choicez#text '%s' doesn't match any choicesr%   r&   r'   r(   z%sError: Invalid input (%s).)ÚlistÚlenr   r,   Ú
ValueErrorÚjoinÚ	enumerater   r   ÚmapÚreprr   r   ÚisdigitÚintr.   Úappendr
   Úisspacer   r	   )Úchoicesr0   r   r*   ÚiÚchoicer1   r3   r4   ÚindexÚmatchesÚlower_replyÚlower_choicer+   s                 r5   r   r   x   ss  € ö` ‰S €Fä�7‹m€GÜ
ˆ7ƒ|�qÓä�‰ÐTÐV]Ð^_ÑV`ÔaØ�q‰zÐÞäÐGÓHÐHæ$‘6¨$×4Ñ4à�	‰	ä& w°aÒ8ô
á8‘	�ð ˜1˜+Ñ%ÀÓARÑ*=ÐXZÔ[Ù8ò
ó 	ð
 	Qð6ó €Kô & k¸Ñ=€Kä
‡L�LÐPÜœS¤ wÓ/Ó0ô2ä—=ˆÜ  ¨b¸'ÈÑNˆÞ˜Ñ,Ü�L‰LÐGÈÔQØŠNØ�]‰]�_‰_Ü˜“J ‘NˆEØ�EÕ(œC ›LÖ(Ü—‘ÐJÈGÉNÐ\aÔbØ‘~Ò%àˆÛˆFØŸ+™+›-ˆKØ!Ÿ<™<›>ˆLØÓ*ä—‘ÐKÈVÔTØ”ØÕ,´°[Ó1AÀAÕ1Eà—‘˜vÖ&ñ ô ˆw‹<˜1Óä�L‰LÐQÐSZÐ[\ÑS]Ð_dÔeØ˜1‘:Òö Ü Ð!MÈuÔVaÐbiÓVjÓk‘Ø—‘—‘Ü Ð!BÄCÈÃJÓO‘Þ˜uŸ}™}Ÿ™Ü Ð!FÈÓN‘à5�Ü�L‰LÐAÞ&+™°¸'Ø ¤,ô0ô Ð2°F×DòO !ùó
s   ÂKc                 óŒ  • [        5         Sn U(       a  SU -   n U R                  SS5      n  [        U 5      nUc  [        R                  R                  S5        U(       a  [        R                  R                  S5        Ub	  U(       d  U$ UR                  5       $ ! Uc  [        R                  R                  S5        U(       a   [        R                  R                  S5        f f = f! [         aO  n[        U[        5      (       a   Ub  [        R                  SU5        Us SnA$ [        R                  SSS9  e SnAff = f)a   
Prompt the user for input (free form text).

:param question: An explanation of what is expected from the user (a string).
:param default: The return value if the user doesn't enter any text or
                standard input is not connected to a terminal (which
                makes it impossible to prompt the user).
:param padding: Render empty lines before and after the prompt to make it
                stand out from the surrounding text? (a boolean, defaults
                to :data:`True`)
:param strip: Strip leading/trailing whitespace from the user's reply?
:returns: The text entered by the user (a string) or the value of the
          `default` argument.
:raises: - :exc:`~exceptions.KeyboardInterrupt` when the program is
           interrupted_ while the prompt is active, for example
           because the user presses Control-C_.
         - :exc:`~exceptions.EOFError` when reading from `standard input`_
           fails, for example because the user presses Control-D_ or
           because the standard input stream is redirected (only if
           `default` is :data:`None`).

.. _Control-C: https://en.wikipedia.org/wiki/Control-C#In_command-line_environments
.. _Control-D: https://en.wikipedia.org/wiki/End-of-transmission_character#Meaning_in_Unix
.. _interrupted: https://en.wikipedia.org/wiki/Unix_signal#SIGINT
.. _standard input: https://en.wikipedia.org/wiki/Standard_streams#Standard_input_.28stdin.29
Nr9   z
 z6Got EOF from terminal, returning default value (%r) ..z0Interactive prompt was interrupted by exception!T)Úexc_info)r   Úreplacer   ÚsysÚstderrÚwriteÚBaseExceptionÚ
isinstanceÚEOFErrorr   r,   r	   r   )r/   r0   r   r   r4   Úes         r5   r   r   ê   s  € ô6 ÔØ€Eð'æØ˜h‘ˆHØ×'Ñ'¨¨eÓ4ˆHð	'Ü& xÓ0ˆEà‰}ô —
‘
× Ñ  Ô&Þô
 —
‘
× Ñ  Ô&ð Ñ¦5ð ˆà�{‰{‹}ÐøðK ‰}ô —
‘
× Ñ  Ô&Þô
 —
‘
× Ñ  Õ&ð ûô ó 
Ü�aœ×"Ñ" wÑ':ô �L‰LÐQÐSZÔ[Ø�Nô �N‰NÐMÐX\ˆNÑ]Øûð
ús;   ŽC* ­B ¸AC* ÂAC'Ã'C* Ã*
EÃ4/D>Ä#EÄ)D>Ä>Ec                 óŒ   • [        [        R                  5      (       a%  [        U 4S[	        [        R
                  5      0UD6$ U $ )aß  
Wrap a text to be rendered as an interactive prompt in ANSI escape sequences.

:param prompt_text: The text to render on the prompt (a string).
:param options: Any keyword arguments are passed on to :func:`.ansi_wrap()`.
:returns: The resulting prompt text (a string).

ANSI escape sequences are only used when the standard output stream is
connected to a terminal. When the standard input stream is connected to a
terminal any escape sequences are wrapped in "readline hints".
Úreadline_hints)r   rP   Ústdoutr   r   Ústdin)r1   Úoptionss     r5   r   r   8  s?   € ô (¬¯
©
×3Ñ3ô �kÑ^Ô2GÌÏ	É	Ó2RÐ^ÐV]Ñ^ð àðr6   c                  ó.   •  SSK n g! [         a     gf = f)ux  
Make interactive prompts more user friendly.

The prompts presented by :func:`python2:raw_input()` (in Python 2) and
:func:`python3:input()` (in Python 3) are not very user friendly by
default, for example the cursor keys (:kbd:`â†�`, :kbd:`â†‘`, :kbd:`â†’` and
:kbd:`â†“`) and the :kbd:`Home` and :kbd:`End` keys enter characters instead
of performing the action you would expect them to. By simply importing the
:mod:`readline` module these prompts become much friendlier (as mentioned
in the Python standard library documentation).

This function is called by the other functions in this module to enable
user friendly prompts.
r   N)ÚreadlineÚImportError)r]   s    r5   r   r   I  s   € ðÜøÜó áðús   ‚ ‡
“c              #   óˆ   #   • [        U 5       H
  nUS-   v •  M     SnX -  n[        R                  U5        [        U5      e7f)aå  
Allow the user to provide valid input up to `limit` times.

:param limit: The maximum number of attempts (a number,
              defaults to :data:`MAX_ATTEMPTS`).
:returns: A generator of numbers starting from one.
:raises: :exc:`TooManyInvalidReplies` when an interactive prompt
         receives repeated invalid input (:data:`MAX_ATTEMPTS`).

This function returns a generator for interactive prompts that want to
repeat on invalid input without getting stuck in infinite loops.
r8   zTReceived too many invalid replies on interactive prompt, giving up! (tried %i times))Úranger   r	   r   )ÚlimitrG   ÚmsgÚformatted_msgs       r5   r   r   _  sA   é € ô �5Ž\ˆØ�!‰eŒñ à
`€CØ‘K€Mä
‡N�N�=Ô!ä
 Ó
.Ð.ùs   ‚A Ac                   ó   • \ rS rSrSrSrg)r   iv  zLRaised by interactive prompts when they've received too many invalid inputs.© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__re   r6   r5   r   r   v  s   † äVr6   r   )NT)NTT)rj   ÚloggingrP   Úhumanfriendly.compatr   Úhumanfriendly.terminalr   r   r   r   r   r	   Úhumanfriendly.textr
   r   Ú__all__r   Ú	getLoggerrf   r   r   r   r   r   r   r   Ú	Exceptionr   re   r6   r5   Ú<module>rs      s�   ðñó Û 
õ 4÷÷ ÷ 3ð
€ð €Ø Wð 
×	Ò	˜8Ó	$€ô?DôDoEôdKò\ò"ð, #ô /ô.W˜Iõ Wr6   