#NEWLINE# def ask( self , subject = 'perform this action' , careful = False ) : #NEWLINE# #INDENT# '\n        Requests from the user using `raw_input` if `subject` should be\n        performed. When `careful`, the default answer is NO, otherwise YES.\n        Returns the user answer in the form `True` or `False`.\n        ' #NEWLINE# sample = '(y/N)' #NEWLINE# if ( not careful ) : #NEWLINE# #INDENT# sample = '(Y/n)' #NEWLINE# #UNINDENT# prompt = ( 'You really want to %s %s? ' % ( subject , sample ) ) #NEWLINE# try : #NEWLINE# #INDENT# answer = input ( prompt ) . lower ( ) #NEWLINE# if careful : #NEWLINE# #INDENT# return ( careful in ( 'yes' , 'y' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( answer not in ( 'no' , 'n' ) ) #NEWLINE# #UNINDENT# #UNINDENT# except EOFError : #NEWLINE# #INDENT# print ( file = sys . stderr ) #NEWLINE# default = True #NEWLINE# if careful : #NEWLINE# #INDENT# default = False #NEWLINE# #UNINDENT# return default