#NEWLINE# def prompt_bool( name , default = False , yes_choices = None , no_choices = None ) : #NEWLINE# #INDENT# "Return user input from command line and converts to boolean value.\n\n    :param name: prompt text\n    :param default: default value if no input provided.\n    :param yes_choices: default 'y', 'yes', '1', 'on', 'true', 't'\n    :param no_choices: default 'n', 'no', '0', 'off', 'false', 'f'\n    :rtype: bool\n\n    " #NEWLINE# yes_choices = ( yes_choices or ( 'y' , 'yes' , '1' , 'on' , 'true' , 't' ) ) #NEWLINE# no_choices = ( no_choices or ( 'n' , 'no' , '0' , 'off' , 'false' , 'f' ) ) #NEWLINE# if ( default is None ) : #NEWLINE# #INDENT# prompt_choice = 'y/n' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( default is True ) : #NEWLINE# #INDENT# prompt_choice = 'Y/n' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# prompt_choice = 'y/N' #NEWLINE# #UNINDENT# #UNINDENT# prompt = ( name + ( ' [%s]' % prompt_choice ) ) #NEWLINE# prompt += ( ( name . endswith ( '?' ) and ' ' ) or ': ' ) #NEWLINE# while True : #NEWLINE# #INDENT# rv = input ( prompt ) #NEWLINE# if ( not rv ) : #NEWLINE# #INDENT# return default #NEWLINE# #UNINDENT# if ( rv . lower ( ) in yes_choices ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( rv . lower ( ) in no_choices ) : #NEWLINE# #INDENT# return False