Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/clint/textui/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/clint/textui/__pycache__/prompt.cpython-37.pyc

B

���U��@s�dZddlmZmZddlmZmZddlmZddl	m
Z
ddlmZm
Z
yeWnek
rleZYnXdd
d�Zddd�Zddd�Zd
S)zZ
clint.textui.prompt
~~~~~~~~~~~~~~~~~~~

Module for simple interactive prompts handling

�)�absolute_import�print_function)�match�I�)�puts)�yellow)�RegexValidator�OptionValidator�yFcCs�|dkrd}|dkrdnd}|d|d}xf|s@t|���}nt|�d}|dkrXdStd|t�rt|dkrpdSd	Std
|t�r.|dkr�dSd	Sq.WdS)N)r�nrz[Y/n]z[y/N]� �Tzy(?:es)?Fzn(?:o)?r)�	raw_input�strip�printrr)�prompt�default�batch�	choicebox�input�r�D/opt/alt/python37/lib/python3.7/site-packages/clint/textui/prompt.py�ynsrrNc
Cs�|dkrtd�g}|ddk	r&|d7}|r:|d|d7}xr|sRt|���pN|}nt|�d}yx|D]}||�}qfW|Stk
r�}ztt|j��Wdd}~XYq<Xq<WdS)Nz.+���r
�[z] r)r	rrr�	Exceptionrr�message)rr�
validatorsr�
user_input�	validator�errr�query>s"

r"c
Cs�g}i}t|dt�rxx�|D]V}t|d�|d<t|d�|d<d|krT|d|d<|�|d�|d||d<qWnr|}g}xht|�D]\\}}	i}t|d�|d<t|	�|d<|d|d<|d||d<|�|d�|�|�q�Wt|�g}
|d7}x|D]}|djf|�7}�qW|d7}|�r:|d|d	7}x�|�sVt|����pR|}nt	|�d
}y$x|
D]}
|
|�}||}�qjW|St
k
�r�}ztt|j
��Wdd}~XYnX�q<WdS)aU

    :param prompt:
    :param options:
        this can be either a list of strings, in which case it will be presented like:
        prompt:
            (1) this is the first string
            (2) this is the second string
            (3) this is the third string

            please select 1-3:

        or a list of dictionaries in the format of:
            { { 'selector' : 'this is what the user will enter to select the option'
                'prompt': 'this is the string that will be displayed, this can be omitted if the selector is also a prompt',
                'return': 'this is what is returned to the calling procedure, if omitted, the option selector will be used' }

        so, to replicate the above, the dict could look like:

        [ {'selector':1,'prompt':'this is the first string','return':1},
          {'selector':2,'prompt':'this is the second string','return':2},
          {'selector':3,'prompt':'this is the third string'}

    :param default: should be set to the default selector (if desired)
    :param batch: True/False, will auto-return the default
    :return:
    r�selectorr�returnr�
z[{selector}] {prompt}
rz] rN)�
isinstance�dict�str�append�	enumerater
�formatrrrrrrr)r�optionsrr�validator_list�return_dict�item�options_strings�key�optr�orr r!rrrr,^sN



r,)rF)rNF)NF)�__doc__�
__future__rr�rerr�corer�coloredrrr	r
r�	NameErrorrrr"r,rrrr�<module>	s

%