U e([VR � @ s d dl Z d dlZd dlZddlmZmZmZmZmZm Z m Z mZ ddlm Z ddlmZmZ ddlmZ ddlmZ eZdZd Zd d� Zd2d d�Zd3dd�Zd4dd�Zdd� Zd5dd�Zd6dd�Zd d!� Zd7d"d#�Z d$d%� Z!d8d&d'�Z"d9d)d*�Z#d:d+d,�Z$dZ%d;d-d.�Z&d<d0d1�Z'dS )=� N� )� raw_input� text_type�string_types�isatty� strip_ansi�get_winterm_size�DEFAULT_COLUMNS�WIN)�echo)�Abort� UsageError)�convert_type)�resolve_color_default) ZblackZredZgreenZyellowZblueZmagentaZcyanZwhite�resetz[0mc C s dd l }|� | �S )Nr )�getpass)�promptr � r � /termui.py�hidden_prompt_func s r Fc C s$ | }|d k r|rd||f }|| S )Nz%s [%s]r )�text�suffix�show_default�defaultr r r r � _build_prompt s r �: Tc s� d} � �fdd�} |dkr$t ||�}t| |||�}| |�}|rBqPq2|dk r2|S q2z||�} W n< tk r� } ztd| j � d� W Y �q2W 5 d} ~ X Y nX |s�| S | d�}|r�q�q�||kr�| S td� d� q2dS )a� Prompts a user for input. This is a convenience function that can be used to prompt a user for input later. If the user aborts the input by sending a interrupt signal, this function will catch it and raise a :exc:`Abort` exception. .. versionadded:: 6.0 Added unicode support for cmd.exe on Windows. .. versionadded:: 4.0 Added the `err` parameter. :param text: the text to show for the prompt. :param default: the default value to use if no input happens. If this is not given it will prompt until it's aborted. :param hide_input: if this is set to true then the input value will be hidden. :param confirmation_prompt: asks for confirmation for the value. :param type: the type to use to check the value against. :param value_proc: if this parameter is provided it's a function that is invoked instead of the type conversion to convert a value. :param prompt_suffix: a suffix that should be added to the prompt. :param show_default: shows or hides the default value in the prompt. :param err: if set to true the file defaults to ``stderr`` instead of ``stdout``, the same as with echo. Nc sX �rt p t}zt| d� d� |d�W S ttfk rR �rHtd � d� t� �Y nX d S )NF��nl�err� �r )r �visible_prompt_funcr �KeyboardInterrupt�EOFErrorr )r �f�r � hide_inputr r �prompt_funcC s zprompt.<locals>.prompt_funcz Error: %sr zRepeat for confirmation: z*Error: the two entered values do not match)r r r r �message)r r r&