%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/rich/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/rich/__pycache__/prompt.cpython-312.pyc

�

"T�e,���ddlmZmZmZmZmZmZmZmZddl	m
Z
ddlmZddl
mZmZed�Zed�ZGd�d	e�ZGd
�de�ZGd�d
ee�ZGd�dee�ZGd�dee�ZGd�dee�ZGd�dee�Zedk(r�ddlm Z ejCdd��r�	ejCdd��Z"e"dk\re"dkrn	e d��'e de"���	ejCd d�!�Z#e$e#�dk\rn	e d"��(e d#e#���ejCd$gd%��&�Z%e d'e%���y)e d(�y)y))*�)�Any�Generic�List�Optional�TextIO�TypeVar�Union�overload�)�get_console)�Console)�Text�TextType�
PromptType�DefaultTypec��eZdZdZy)�PromptErrorz/Exception base class for prompt related errors.N)�__name__�
__module__�__qualname__�__doc__���-/usr/lib/python3/dist-packages/rich/prompt.pyrrs��9rrc�,�eZdZdZdeddfd�Zdefd�Zy)�InvalidResponsez�Exception 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.
    �message�returnNc��||_y�N�r)�selfrs  r�__init__zInvalidResponse.__init__s	����rc��|jSr r!�r"s r�__rich__zInvalidResponse.__rich__s���|�|�r)rrrrrr#r&rrrrrs&������T���(�rrc���eZdZUdZeZeed<dZdZ	dZ
dZee
eed<	d(dddd	d	d
�dedeed
edee
edededdfd�Zee	d(dddd	d	dd�dedeed
edee
ededededeedeeeffd���Zee	d(dddd	d	dd�dedeed
edee
edededeedefd���Ze	d(dddd	d	ddd�dedeed
edee
ededededeedefd��Zdedefd�Zdedefd�Ze	d)deded
edeedef
d��Zdedefd�Zdedefd�Zded e ddfd!�Z!d*d"�Z"edd#�deedefd$��Z#edd#�dedeedeeeffd%��Z#ddd&�dedeedefd'�Z#y)+�
PromptBasea�Ask 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: N�choicesFT��console�passwordr*�show_default�show_choices�promptr,r-r.r/rc���|xs
t�|_t|t�rt	j
|d��n||_||_|�||_||_	||_
y)Nr0��style)rr,�
isinstance�strr�from_markupr0r-r*r.r/)r"r0r,r-r*r.r/s       rr#zPromptBase.__init__5s`���/�+�-����&�#�&�
���V�8�4��	
��
!��
���"�D�L�(���(��r)r,r-r*r.r/�stream�defaultr7c��yr r)	�clsr0r,r-r*r.r/r8r7s	         r�askzPromptBase.askKs��	rc��yr r)r:r0r,r-r*r.r/r7s        rr;zPromptBase.ask[s��	r.)r,r-r*r.r/r8r7c�2�|||||||��}	|	||��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+�r8r7r)
r:r0r,r-r*r.r/r8r7�_prompts
          rr;zPromptBase.askjs/��6�����%�%�

���w�v�6�6rc�"�td|�d�d�S)z�Turn 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"r8s  r�render_defaultzPromptBase.render_default�s���a��y��N�$4�5�5rc��|jj�}d|_|jrP|jrDdj|j�}d|�d�}|j
d�|j
|d�|dk7r[|jrOt|t|jf�r3|j
d�|j|�}|j
|�|j
|j�|S)z�Make prompt text.

        Args:
            default (DefaultType): Default value.

        Returns:
            Text: Text to display in prompt.
        ��/�[�]� zprompt.choices.)
r0�copy�endr/r*�join�appendr.r4r5r)rD�
prompt_suffix)r"r8r0�_choicesr*�_defaults      r�make_promptzPromptBase.make_prompt�s������!�!�#����
��������x�x����-�H��(��1�o�G��M�M�#���M�M�'�#3�4�
�s�N��!�!��7�S�$�*<�*<�$=�>��M�M�#���*�*�7�3�H��M�M�(�#��
�
�d�(�(�)��
rc�*�|j|||��S)z�Get input from user.

        Args:
            console (Console): Console instance.
            prompt (TextType): Prompt text.
            password (bool): Enable password entry.

        Returns:
            str: String from user.
        )r-r7)�input)r:r,r0r-r7s     r�	get_inputzPromptBase.get_input�s��$�}�}�V�h�v�}�F�Fr�valuec�V�|j�J�|j�|jvS)z�Check 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*�strip�r"rVs  r�check_choicezPromptBase.check_choice�s)���|�|�'�'�'��{�{�}����,�,rc���|j�}	|j|�}|j
�&|j
|�st|j��|S#t$rt|j��wxYw)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)�
ValueErrorr�validate_error_messager*rZ�illegal_choice_message)r"rV�return_values   r�process_responsezPromptBase.process_response�sv�����
��	?�'+�'9�'9�%�'@�L��<�<�#�D�,=�,=�e�,D�!�$�"=�"=�>�>����
�	?�!�$�"=�"=�>�>�	?�s�A�A6�errorc�:�|jj|�y)z�Called to handle validation error.

        Args:
            value (str): String entered by user.
            error (InvalidResponse): Exception instance the initiated the error.
        N)r,�print)r"rVras   r�on_validate_errorzPromptBase.on_validate_error�s��	
�����5�!rc��y)z,Hook to display something before the prompt.Nrr%s r�
pre_promptzPromptBase.pre_prompt�s�r�r7c��yr r)r"r7s  r�__call__zPromptBase.__call__�s��rc��yr r)r"r8r7s   rrizPromptBase.__call__s��	rr>c�(�	|j�|j|�}|j|j||j|��}|dk(r|dk7r|S	|j|�}|S#t$r}|j||�Yd}~��d}~wwxYw)z�Run the prompt loop.

        Args:
            default (Any, optional): Optional default value.

        Returns:
            PromptType: Processed value.
        rgrF.N)rfrRrUr,r-r`rrd)r"r8r7r0rVr_ras       rrizPromptBase.__call__s�����O�O���%�%�g�.�F��N�N�4�<�<�����v�N�V�E���{�w�#�~���
$�#�4�4�U�;��
$�#��	#�
��&�&�u�e�4���
�s�A,�,	B�5B�B)rFr )rN)$rrrrr5r)�type�__annotations__r]r^rOr*rrrr
�boolr#�classmethodr
rrr	rr;rrrDrRrUrZr`rrdrfrirrrr(r(s���
��M�4��I��K���M�#'�G�X�d�3�i�
 �'��)�&*��'+�!�!�)��)��'�"�	)�
�)��$�s�)�$�
)��)��)�
�)�,�
���&*��'+�!�!�#'�����'�"�	�
���$�s�)�$�
��������� ��
�{�J�&�	'������
���&*��'+�!�!�#'�����'�"�	�
���$�s�)�$�
������� ��
�������"7�&*��'+�!�!��#'�"7��"7��'�"�	"7�
�"7��$�s�)�$�
"7��"7��"7��"7��� �"7�

�"7��"7�H	6�k�	6�d�	6��;��4��>�$(�G��G��G��	G�
�� �G�

�
G��G�&
-�#�
-�$�
-��c��j��."�s�"�?�"�t�"�;��59��(�6�"2��j�����BF��%��/7��/?��	�z�;�&�	'����
*-��$�3�$�h�v�6F�$�RU�$rr(c��eZdZdZeZy)�PromptzbA prompt that returns a str.

    Example:
        >>> name = Prompt.ask("Enter your name")


    N)rrrrr5r)rrrrqrqs����Mrrqc��eZdZdZeZdZy)�	IntPromptz�A 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)rrrr�intr)r]rrrrsrs*s����M�R�rrsc��eZdZdZeZdZy)�FloatPromptzyA prompt that returns a float.

    Example:
        >>> temperature = FloatPrompt.ask("Enter desired temperature")

    z%[prompt.invalid]Please enter a numberN)rrrr�floatr)r]rrrrvrv6s����M�D�rrvc�R�eZdZUdZeZdZddgZee	e
d<dedefd�Z
d	e	defd
�Zy)�ConfirmzuA yes / no confirmation prompt.

    Example:
        >>> if Confirm.ask("Continue"):
                run_job()

    z#[prompt.invalid]Please enter Y or N�y�nr*r8rc�^�|j\}}t|rd|�d�d��Sd|�d�d��S)z8Render the default as (y) or (n) rather than True/False.rArBrCr2)r*r)r"r8�yes�nos    rrDzConfirm.render_defaultOs:���,�,���R��'�a��u�A�J�@P�Q�Q��2�$�a�y�@P�Q�QrrVc��|j�j�}||jvrt|j��||jdk(S)zConvert choices to a bool.r)rX�lowerr*rr]rYs  rr`zConfirm.process_responseTsF�����
�#�#�%������$�!�$�"=�"=�>�>�����Q��'�'rN)rrrrrnr)r]r*rr5rmrrrDr`rrrryryBsO����M�B���s��G�T�#�Y�#�R�k�R�d�R�
(�c�(�d�(rry�__main__)rczRun [i]prompt[/i] tests?T)r8z6: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)�apple�orange�pear)r*zfruit=z[b]OK :loudly_crying_face:N)&�typingrrrrrrr	r
rFrr,r
�textrrrr�	Exceptionrrr(r5rqrtrsrwrvrnryr�richrcr;�resultr-�len�fruitrrr�<module>r�s���Q�Q�Q��� �
�\�
"�
��m�$��:�)�:��k��}$���$�}$�@	�Z��_�	�	S�
�3��	S�	E�*�U�#�	E�(�j���(�4�z����{�{�-�t�{�<���]�]�H�RS�#��F���{�v��|���Q�R�
�	���x� �!���z�z�O��"��H��8�}��!���6�7��	�	�(��&�'��
�
�?�4O�
�P��
��u�i� �!�	�*�+�7r

Zerion Mini Shell 1.0