
    AHj!!                     |   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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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Zy)    )Any)Dict)Iterable)Mapping)Optional)Union)
ColorDepth)utils)DEFAULT_KBI_MESSAGE)AVAILABLE_PROMPTS)prompt_by_name)print_formatted_textc                   8     e Zd ZdZddedee   ddf fdZ xZS )PromptParameterExceptionz+Received a prompt with a missing parameter.Nmessageerrorsreturnc                 .    t         |   d| d|       y )NzYou must provide a `z` value)super__init__)selfr   r   	__class__s      J/root/tools/cai/cai_env/lib/python3.12/site-packages/questionary/prompt.pyr   z!PromptParameterException.__init__   s    /y@&I    )N)	__name__
__module____qualname____doc__strr   BaseExceptionr   __classcell__)r   s   @r   r   r      s0    5J JXm-D JPT J Jr   r   NF	questionsanswerspatch_stdout
true_colorkbi_msgkwargsr   c                 Z    	 t        | |||fi |S # t        $ r t        |       i cY S w xY 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'   s         r   promptr,      s9    hYzTVTT g	s    **c           	      t   t        | t              r| g} t        |xs i       }| D ],  }t        |      }d|vrt        d      d|vr|d   dk7  rt        d      |j                         }|j	                  |       |j                  d      }|j                  dd      }|dk(  r|j                  dd      n|j                  d      }	|j                  dd      }
|rt        j                  |d<   |
r't        |d         r	  |d   |      snt        d
      |dk(  r9	 |j                  d      }|j                  dd       t        |fi | |	rd||	<   /|j                  d      }|t        |      r ||      }||d<   ||d<   |rt        |      st        d      t        |j                  d            r |d   |      |d<   t        |      }|s%t        d| ddj                  t                d      t#        t%        j&                  ||            }|rt        |d          |di |}|j)                  |      }||r		  ||      }|||	<   / |S # t        $ r}t        d|	 d	|       |d}~ww xY w# t        $ r}t        d      |d}~ww xY w# t        $ r}t        d|	 d	|       |d}~ww xY w)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  )
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/   r1   	exceptionr   er4   calculated_choicescreate_question_funcmissing_argsquestionanswers                       r   r)   r)   T   s6   f )T"K	7=b!G$ \#/(*622(_V-D-O*622++-'F#++h-,1W,<w{{64('++fBU{{64(%/%:%:GM"/0%2?627;  < !N 
 GA!++i0 KK& 4G4 $!%%i08G#4!(!1);OI& 2F9G$ L  O''	23!;!;G!DGI-e4#$UG ,,,0II6G,H+IL 
 E334H'RS*<?;;'2'2$$\2%$V_F #GDMy\#| NI ! %$5${9+V$%%  A.y9q@A` ! %$9$ @%%.K1 %%%sH   >II:J	I7 I22I7:	JJJ	J7 J22J7)NFF)typingr   r   r   r   r   r   prompt_toolkit.outputr	   questionaryr
   questionary.constantsr   questionary.promptsr   r   questionary.prompts.commonr   r@   r   r   boolr,   r)   r7   r   r   <module>rY      sH         ,  5 1 . ;Jz J ,0&8T#s(^Xgc3h.?%@@A8gc3h'(8 8 	8
 8 8 
#s(^8z ,0	VT#s(^Xgc3h.?%@@AVgc3h'(V V 	V
 V 
#s(^Vr   