§
    ÁôgÏ?  ã                   óÊ   — d Z ddlZddlZddlmZ ddlmZmZmZm	Z	m
Z
mZ ddlmZmZ dZdZ	  ej        e¦  «        Zdd	„Zdd
„Zdd„Zd„ Zd„ Zefd„Z G d„ de¦  «        ZdS )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é
   Tc                 óÚ  — t          | d¬¦  «        }|rdn|�dnd}|dt          |t          ¬¦  «        z  z  }t                               d	t	          |¦  «                             ¦   «         ¦  «         t          ¦   «         D ]ê}t          |d
|d¬¦  «        }|                     ¦   «         dv rt                               d|¦  «          dS |                     ¦   «         dv rt                               d|¦  «          dS |s%|�#t                               d|rdnd¦  «         |c S |rd|z  nd}t                               d|rdnd||t          ¦  «         t          d|rdnd
|¬¦  «         ŒëdS )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           ú^/var/www/html/bac/bac_backend/python/env/lib/python3.11/site-packages/humanfriendly/prompts.pyr   r   6   sÄ  € õL & h°TÐ:Ñ:Ô:€KàÐNˆ7ˆ7¨gÐ.A 7 7Àw€DØ�6Õ/°½OÐLÑLÔLÑLÑL€Kå
‡L‚LÐHÍ*ÐU`ÑJaÔJa×JhÒJhÑJjÔJjÑkÔkÐkÝ‘=”=ð Dð DˆÝ  ¨b¸'ÈÐNÑNÔNˆØ�;Š;‰=Œ=˜LÐ(Ð(Ý�LŠLÐ>ÀÑFÔFÐFØ�4�4Ø�[Š[‰]Œ]˜kÐ)Ð)Ý�LŠLÐ=¸uÑEÔEÐEØ�5�5Øð 	D˜WÐ0Ý�LŠLÐGØ&-Ð;˜˜°8ñ=ô =ð =àˆNˆNˆNð  ðAÐ8¸5Ñ@Ð@Ø%@ð å�LŠLÐAØ&+Ð8˜˜°¸'Ø ¥,ñ0ô 0ð 0õ ÐLØ")Ð1˜3˜3¨r¸7ðDñ Dô Dð Dð Dð%Dð Dó    c           	      óP  ‡— |rdnd}t          | ¦  «        } t          | ¦  «        dk    r)t                               d| d         ¦  «         | d         S | st	          d¦  «        ‚|rdnd                     d                     ˆfd	„t          | d¬
¦  «        D ¦   «         ¦  «        dg¦  «        }t          |d¬¦  «        }t                               dt          t          t          | ¦  «        ¦  «        ¦  «         t          ¦   «         D �]}t          |d|d¬¦  «        }|s!‰�t                               d‰¦  «         ‰c S |                     ¦   «         r[t          |¦  «        dz
  }d|cxk    rt          | ¦  «        k     r/n n,t                               d| |         |¦  «         | |         c S g }| D ]}}	|                     ¦   «         }
|	                     ¦   «         }|
|k    r!t                               d|	¦  «         |	c c S |
|v r(t          |
¦  «        dk    r|                     |	¦  «         Œ~t          |¦  «        dk    r,t                               d|d         |¦  «         |d         c S |rt#          d|t          |¦  «        ¦  «        }n[|                     ¦   «         rt#          dt          |¦  «        ¦  «        }n)|r%|                     ¦   «         st#          d|¦  «        }nd}t                               d|rdnd||t&          ¦  «         t)          d||¦  «         �ŒdS )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

ú
c                 ó:   •— g | ]\  }}d ||fz  |‰k    rdndz   ‘ŒS )z %i. %sz (default choice)r   © )Ú.0ÚiÚchoicer0   s      €r5   ú
<listcomp>z%prompt_for_choice.<locals>.<listcomp>µ   sL   ø€ ð 
ð 
ð 
á��6ð ˜1˜f˜+Ñ%ÀÈ7ÒARÐARÐ*=Ð*=ÐXZÑ[ð
ð 
ð 
r6   )ÚstartzFEnter 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*   r1   r3   r4   ÚindexÚmatchesr>   Úlower_replyÚlower_choicer+   s    `           r5   r   r   x   s�  ø€ ð` Ð#ˆSˆS €Få�7‰mŒm€GÝ
ˆ7�|„|�qÒÐå�ŠÐTÐV]Ð^_ÔV`ÑaÔaÐaØ�qŒzÐØð IåÐGÑHÔHÐHà$Ð.�6�6¨$×4Ò4à�	Š	ð 
ð 
ð 
ð 
å& w°aÐ8Ñ8Ô8ð
ñ 
ô 
ñ 	ô 	ð
 	Qð6ñ ô €Kõ & k¸Ð=Ñ=Ô=€Kå
‡L‚LÐPÝ�S¥ wÑ/Ô/Ñ0Ô0ñ2ô 2ð 2å‘=”=ð 'Eñ 'EˆÝ  ¨b¸'ÈÐNÑNÔNˆØð 	&˜Ð,Ý�LŠLÐGÈÑQÔQÐQØˆNˆNˆNØ�]Š]‰_Œ_ð 	&Ý˜‘J”J ‘NˆEØ�EÐ(Ð(Ò(Ð(�C ™LœLÒ(Ð(Ð(Ð(Ð(Ý—’ÐJÈGÐTYÌNÐ\aÑbÔbÐbØ˜u”~Ð%Ð%Ð%àˆØð 		'ð 		'ˆFØŸ+š+™-œ-ˆKØ!Ÿ<š<™>œ>ˆLØ˜lÒ*Ð*å—’ÐKÈVÑTÔTÐTØ�����Ø Ð,Ð,µ°[Ñ1AÔ1AÀAÒ1EÐ1Eà—’˜vÑ&Ô&Ð&øÝˆw‰<Œ<˜1ÒÐå�LŠLÐQÐSZÐ[\ÔS]Ð_dÑeÔeÐeØ˜1”:ÐÐÐð ð 6Ý Ð!MÈuÕVaÐbiÑVjÔVjÑkÔk��Ø—’‘”ð 6Ý Ð!BÅCÈÁJÄJÑOÔO��Øð 6˜uŸ}š}™œð 6Ý Ð!FÈÑNÔN��à5�Ý�LŠLÐAØ&+Ð8˜˜°¸'Ø ¥,ñ0ô 0ð 0õ Ð2°F¸GÑDÔDÐDÑDðO'Eð 'Er6   c                 óš  — t          ¦   «          d}	 |rd| z   } |                      dd¦  «        } 	 t          | ¦  «        }|€t          j                             d¦  «         |rt          j                             d¦  «         nH# |€t          j                             d¦  «         |r t          j                             d¦  «         w w xY wnh# t          $ r[}t          |t          ¦  «        r$|�"t           
                    d|¦  «         |cY d}~S t                               dd¬¦  «         ‚ d}~ww xY w|�|s|S |                     ¦   «         S )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   ê   sz  € õ6 ÑÔÐØ€Eð'àð 	5Ø˜h‘ˆHØ×'Ò'¨¨eÑ4Ô4ˆHð	'Ý& xÑ0Ô0ˆEàˆ}õ ”
× Ò  Ñ&Ô&Ð&Øð 'õ
 ”
× Ò  Ñ&Ô&Ð&øøð' ˆ}õ ”
× Ò  Ñ&Ô&Ð&Øð 'õ
 ”
× Ò  Ñ&Ô&Ð&Ð&ð'øøøøøõ ð 
ð 
ð 
Ý�a�Ñ"Ô"ð 		 wÐ':õ �LŠLÐQÐSZÑ[Ô[Ð[ØˆNˆNˆNˆNˆNˆNõ �NŠNÐMÐX\ˆNÑ]Ô]Ð]Øøøøøð
øøøð Ð 5Ðð ˆà�{Š{‰}Œ}Ðs;   ’C °B ¿AC ÂACÃC Ã
D0Ã3D+ÄD0ÄD+Ä+D0c                 ó„   — t          t          j        ¦  «        r&t          | fdt	          t          j        ¦  «        i|¤Žn| S )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   rT   Ústdoutr   r   Ústdin)r1   Úoptionss     r5   r   r   8  sD   € õ (­¬
Ñ3Ô3ð�I�kÐ^Ð^Õ2GÍÌ	Ñ2RÔ2RÐ^ÐV]Ð^Ð^Ð^àðr6   c                  ó2   — 	 ddl } dS # t          $ r Y dS w xY w)u¤  
    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)ra   s    r5   r   r   I  s6   € ðØˆˆˆˆˆøÝð ð ð àˆˆðøøøs   ‚ ˆ
•c              #   ó˜   K  — t          | ¦  «        D ]	}|dz   V — Œ
d}|| z  }t                               |¦  «         t          |¦  «        ‚)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   )Úlimitr=   ÚmsgÚformatted_msgs       r5   r   r   _  sZ   è è € õ �5‰\Œ\ð ð ˆØ�!‰eˆˆˆˆØ
`€CØ˜%‘K€Må
‡N‚N�=Ñ!Ô!Ð!å
 Ñ
.Ô
.Ð.r6   c                   ó   — e Zd ZdZdS )r   zLRaised by interactive prompts when they've received too many invalid inputs.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r;   r6   r5   r   r   v  s   € € € € € àVÐVÐVÐVr6   r   )NT)NTT)rl   ÚloggingrT   Úhumanfriendly.compatr   Úhumanfriendly.terminalr   r   r   r   r   r	   Úhumanfriendly.textr
   r   Ú__all__r   Ú	getLoggerri   r   r   r   r   r   r   r   Ú	Exceptionr   r;   r6   r5   ú<module>rt      sŠ  ððð ð €€€Ø 
€
€
€
ð 4Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 3Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2Ð 2ð
€ð €Ø Wð 
ˆÔ	˜8Ñ	$Ô	$€ð?Dð ?Dð ?Dð ?DðDoEð oEð oEð oEðdKð Kð Kð Kð\ð ð ð"ð ð ð, #ð /ð /ð /ð /ð.Wð Wð Wð Wð W˜Iñ Wô Wð Wð Wð Wr6   