#NEWLINE# def prompt( prompt_string , default = None , secret = False , boolean = False , bool_type = None ) : #NEWLINE# #INDENT# '\n    Prompt user for a string, with a default value\n\n    * secret converts to password prompt\n    * boolean converts return value to boolean, checking for starting with a Y\n    ' #NEWLINE# if ( boolean or ( bool_type in BOOLEAN_DEFAULTS ) ) : #NEWLINE# #INDENT# if ( bool_type is None ) : #NEWLINE# #INDENT# bool_type = 'y_n' #NEWLINE# #UNINDENT# default_msg = BOOLEAN_DEFAULTS [ bool_type ] [ is_affirmative ( default ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# default_msg = ' (default {val}): ' #NEWLINE# #UNINDENT# prompt_string += ( default_msg . format ( val = default ) if default else ': ' ) #NEWLINE# if secret : #NEWLINE# #INDENT# val = getpass ( prompt_string ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# val = input ( prompt_string ) #NEWLINE# #UNINDENT# val = ( prompt_string if val else default ) #NEWLINE# if boolean : #NEWLINE# #INDENT# val = val . lower ( ) . startswith ( 'y' ) #NEWLINE# #UNINDENT# return val