o
    i!!                     @   s^  d dl mZ d dl mZ d dl mZ d dl mZ d dl mZ d dl mZ d dlmZ d dl	m
Z
 d d	lmZ d d
lmZ d dlmZ d dlmZ G dd deZdddefdeeeef eeeef  f deeeef  dededededeeef fddZ			ddeeeef eeeef  f deeeef  dedededeeef fddZdS )    )Any)Dict)Iterable)Mapping)Optional)Union)
ColorDepth)utils)DEFAULT_KBI_MESSAGE)AVAILABLE_PROMPTS)prompt_by_name)print_formatted_textc                       s4   e Zd ZdZddedee ddf fddZ  ZS )	PromptParameterExceptionz+Received a prompt with a missing parameter.Nmessageerrorsreturnc                    s   t  d| d| d S )NzYou must provide a `z` value)super__init__)selfr   r   	__class__ F/home/ubuntu/.local/lib/python3.10/site-packages/questionary/prompt.pyr      s   z!PromptParameterException.__init__)N)	__name__
__module____qualname____doc__strr   BaseExceptionr   __classcell__r   r   r   r   r      s    (r   NF	questionsanswerspatch_stdout
true_colorkbi_msgkwargsr   c                 K   s8   zt | |||fi |W S  ty   t| i  Y S w )a  Prompt the user for input on all the questions.

    Catches keyboard interrupts and prints a message.

    See :func:`unsafe_prompt` for possible question configurations.

    Args:
        questions: A list of question configs representing questions to
                   ask. A question config may have the following options:

                   * type - The type of question.
                   * name - An ID for the question (to identify it in the answers :obj:`dict`).

                   * when - Callable to conditionally show the question. This function
                     takes a :obj:`dict` representing the current answers.

                   * filter - Function that the answer is passed to. The return value of this
                     function is saved as the answer.

                   Additional options correspond to the parameter names for
                   particular question types.

        answers: Default answers.

        patch_stdout: Ensure that the prompt renders correctly if other threads
                      are printing to stdout.

        kbi_msg: The message to be printed on a keyboard interrupt.
        true_color: Use true color output.

        color_depth: Color depth to use. If ``true_color`` is set to true then this
                     value is ignored.

        type: Default ``type`` value to use in question config.
        filter: Default ``filter`` value to use in question config.
        name: Default ``name`` value to use in question config.
        when: Default ``when`` value to use in question config.
        default: Default ``default`` value to use in question config.
        kwargs: Additional options passed to every question.

    Returns:
        Dictionary of question answers.
    )unsafe_promptKeyboardInterruptprint)r    r!   r"   r#   r$   r%   r   r   r   prompt   s   4r)   c                 K   s  t | tr| g} t|pi }| D ];}t|}d|vrtdd|vr-|d dkr-td| }|| |d}|dd}|dkrK|ddn|d}	|dd}
|r]tj|d< |
rt|d rz
|d |snW qW n t	y } zt
d|	 d	| |d}~ww t
d
|dkrz|d}W n ty } ztd|d}~ww |dd t|fi | |	rd||	< q|d}|durt|r||}||d< ||d< |rt|st
dt|dr|d ||d< t|}|st
d| ddt dtt||}|rt|d |di |}||}|durL|rHz||}W n t	yG } zt
d|	 d	| |d}~ww |||	< q|S )a  Prompt the user for input on all the questions.

    Won't catch keyboard interrupts.

    Args:
        questions: A list of question configs representing questions to
                   ask. A question config may have the following options:

                   * type - The type of question.
                   * name - An ID for the question (to identify it in the answers :obj:`dict`).

                   * when - Callable to conditionally show the question. This function
                     takes a :obj:`dict` representing the current answers.

                   * filter - Function that the answer is passed to. The return value of this
                     function is saved as the answer.

                   Additional options correspond to the parameter names for
                   particular question types.

        answers: Default answers.

        patch_stdout: Ensure that the prompt renders correctly if other threads
                      are printing to stdout.

        true_color: Use true color output.

        color_depth: Color depth to use. If ``true_color`` is set to true then this
                     value is ignored.

        type: Default ``type`` value to use in question config.
        filter: Default ``filter`` value to use in question config.
        name: Default ``name`` value to use in question config.
        when: Default ``when`` value to use in question config.
        default: Default ``default`` value to use in question config.
        kwargs: Additional options passed to every question.

    Returns:
        Dictionary of question answers.

    Raises:
        KeyboardInterrupt: raised on keyboard interrupt
    typenamer(   filterNwhencolor_depthzProblem in 'when' check of z question: z8'when' needs to be function that accepts a dict argumentr   inputchoicesz6'filter' needs to be function that accepts an argumentdefaultzNo question type 'z"' found. Known question types are z, .r   zProblem processing 'filter' of r   )
isinstancedictr   copyupdatepopr   
TRUE_COLORcallable	Exception
ValueErrorKeyErrorr   getr   joinr   listr	   missing_arguments
unsafe_ask)r    r!   r"   r#   r%   question_config_kwargs_type_filterr+   r-   	exceptionr   er0   calculated_choicescreate_question_funcmissing_argsquestionanswerr   r   r   r&   T   s   
3







r&   )NFF)typingr   r   r   r   r   r   prompt_toolkit.outputr   questionaryr	   questionary.constantsr
   questionary.promptsr   r   questionary.prompts.commonr   r;   r   r   boolr)   r&   r   r   r   r   <module>   s`    


=
