HEX
Server: Apache
System: Linux p3plzcpnl506847.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: slfopp7cb1df (5698090)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_vendor/rich/__pycache__/prompt.cpython-38.pyc
U

�{�e',�@s�ddlmZmZmZmZmZmZmZmZddl	m
Z
ddlmZddl
mZmZed�Zed�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
ee�ZGdd�dee�ZGdd�dee�ZGdd�dee�ZGdd�dee�Zedk�r�ddlmZej ddd��r�ej ddd�Z!e!dk�r0e!dk�r0�q<ed��q
ede!���ej d dd!�Z"e#e"�dk�rj�qved"��qJed#e"���ej d$d%d&d'gd(�Z$ed)e$���ned*�d+S),�)�Any�Generic�List�Optional�TextIO�TypeVar�Union�overload�)�get_console)�Console)�Text�TextType�
PromptType�DefaultTypec@seZdZdZdS)�PromptErrorz/Exception base class for prompt related errors.N)�__name__�
__module__�__qualname__�__doc__�rr�;/tmp/pip-unpacked-wheel-_0scjqea/pip/_vendor/rich/prompt.pyrsrc@s.eZdZdZedd�dd�Zed�dd�ZdS)	�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.
    N)�message�returncCs
||_dS�N�r)�selfrrrr�__init__szInvalidResponse.__init__�rcCs|jSrr�rrrr�__rich__szInvalidResponse.__rich__)rrrrrrr!rrrrrsrc@s4eZdZUdZeZeed<dZdZ	dZ
dZee
eed<d3dd	dd
d
d�eeeeee
eeedd�d
d�Zeed4dd	dd
d
dd�eeeeee
eeeeeeeeefd�	dd���Zeed5dd	dd
d
dd�eeeeee
eeeeeed�dd���Zed6dd	dd
d
ddd�eeeeee
eeeeeeed�	dd��Zeed�dd�Zeed�dd�Zed7eeeeeed�dd��Zeed �d!d"�Zeed �d#d$�Zee dd%�d&d'�Z!dd(�d)d*�Z"edd+�eeed,�d-d.��Z#edd+�eeeeeefd/�d0d.��Z#ddd1�eeeed/�d2d.�Z#dS)8�
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�choices�FT��console�passwordr$�show_default�show_choices)�promptr'r(r$r)r*rcCsN|pt�|_t|t�r$tj|dd�n||_||_|dk	r>||_||_	||_
dS)Nr+��style)rr'�
isinstance�strr
Zfrom_markupr+r(r$r)r*)rr+r'r(r$r)r*rrrr5s
��zPromptBase.__init__)r'r(r$r)r*�stream)	r+r'r(r$r)r*�defaultr0rc	CsdSrr)	�clsr+r'r(r$r)r*r1r0rrr�askKszPromptBase.ask)r+r'r(r$r)r*r0rcCsdSrr)r2r+r'r(r$r)r*r0rrrr3[s
.)r'r(r$r)r*r1r0c
Cs |||||||d�}	|	||d�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&�r1r0r)
r2r+r'r(r$r)r*r1r0Z_promptrrrr3js��r1rcCstd|�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
)rr1rrr�render_default�s	zPromptBase.render_defaultcCs�|j��}d|_|jrJ|jrJd�|j�}d|�d�}|�d�|�|d�|dkr�|jr�t|t	|j
f�r�|�d�|�|�}|�|�|�|j�|S)z�Make prompt text.

        Args:
            default (DefaultType): Default value.

        Returns:
            Text: Text to display in prompt.
        r%�/�[�]� zprompt.choices.)
r+�copy�endr*r$�join�appendr)r.r/r#r9�
prompt_suffix)rr1r+Z_choicesr$�_defaultrrr�make_prompt�s$	

���


zPromptBase.make_prompt)r'r+r(r0rcCs|j|||d�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(r0)�input)r2r'r+r(r0rrr�	get_input�szPromptBase.get_input��valuercCs|jdk	st�|��|jkS)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.
        N)r$�AssertionError�strip�rrHrrr�check_choice�s	zPromptBase.check_choicecCsX|��}z|�|�}Wntk
r4t|j��YnX|jdk	rT|�|�sTt|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.
        N)rJr#�
ValueErrorr�validate_error_messager$rL�illegal_choice_message)rrH�return_valuerrr�process_response�s
zPromptBase.process_response)rH�errorrcCs|j�|�dS)z�Called to handle validation error.

        Args:
            value (str): String entered by user.
            error (InvalidResponse): Exception instance the initiated the error.
        N)r'�print)rrHrRrrr�on_validate_error�szPromptBase.on_validate_errorrcCsdS)z,Hook to display something before the prompt.Nrr rrr�
pre_prompt�szPromptBase.pre_prompt�r0)r0rcCsdSrr)rr0rrr�__call__�szPromptBase.__call__)r1r0rcCsdSrr)rr1r0rrrrWsr4c
Cs�|��|�|�}|j|j||j|d�}|dkr<|dkr<|Sz|�|�}Wn6tk
r�}z|�||�WY�qW5d}~XYqX|SqdS)z�Run the prompt loop.

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

        Returns:
            PromptType: Processed value.
        rVr%.N)rUrDrFr'r(rQrrT)rr1r0r+rHrPrRrrrrWs

)r%)r%)r%)r%)N)$rrrrr/r#�type�__annotations__rNrOrBr$rrrr�boolr�classmethodr	rrrrr3rr
r9rDrFrLrQrrTrUrWrrrrr"s�
���
���

���
�
��
�$��	�
�r"c@seZdZdZeZdS)�PromptzbA prompt that returns a str.

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


    N)rrrrr/r#rrrrr\sr\c@seZdZdZeZdZdS)�	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#rNrrrrr]*sr]c@seZdZdZeZdZdS)�FloatPromptzyA prompt that returns a float.

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

    z%[prompt.invalid]Please enter a numberN)rrrr�floatr#rNrrrrr_6sr_c@sNeZdZUdZeZdZddgZee	e
d<eed�dd�Z
e	ed	�d
d�ZdS)
�ConfirmzuA yes / no confirmation prompt.

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

    z#[prompt.invalid]Please enter Y or N�y�nr$r5cCs.|j\}}t|rd|�d�n
d|�d�dd�S)z8Render the default as (y) or (n) rather than True/False.r6r7r8r,)r$r
)rr1�yes�norrrr9Os
zConfirm.render_defaultrGcCs.|����}||jkr t|j��||jdkS)zConvert choices to a bool.r)rJ�lowerr$rrNrKrrrrQTs

zConfirm.process_responseN)rrrrrZr#rNr$rr/rYrr
r9rQrrrrraBs
ra�__main__)rSzRun [i]prompt[/i] tests?T)r1z6: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 fruitZappleZorangeZpear)r$zfruit=z[b]OK :loudly_crying_face:N)%�typingrrrrrrrr	r%rr'r�textr
rrr�	Exceptionrrr"r/r\r^r]r_rZrarZpip._vendor.richrSr3�resultr(�lenZfruitrrrr�<module>sH(
��