<s> from colorama import Fore , Back , Style <EOL> import string <EOL> class Conversation : <EOL> def __init__ ( self ) : <EOL> self . Fore = Fore <EOL> self . Back = Back <EOL> self . Style = Style <EOL> pass <EOL> def tell ( self , output ) : <EOL> self . write_terminal ( output , Fore . GREEN ) <EOL> def ask ( self , output ) : <EOL> self . write_terminal ( '<STR_LIT>' , Fore . MAGENTA ) <EOL> self . write_terminal ( output , Fore . MAGENTA ) <EOL> self . write_terminal ( '<STR_LIT>' , Fore . MAGENTA ) <EOL> def warn ( self , output ) : <EOL> self . write_terminal ( '<STR_LIT>' , Fore . RED ) <EOL> self . write_terminal ( output , Fore . RED ) <EOL> self . write_terminal ( '<STR_LIT>' , Fore . RED ) <EOL> @ staticmethod <EOL> def write_terminal ( lines , promptcolor ) : <EOL> if isinstance ( lines , basestring ) : <EOL> lines = [ lines ] <EOL> for line in lines : <EOL> print ( promptcolor + '<STR_LIT>' + Fore . RESET + line ) <EOL> pass <EOL> def prompt ( self , question ) : <EOL> self . ask ( question ) <EOL> answer = raw_input ( '<STR_LIT>' ) <EOL> return answer <EOL> def prompt_bool ( self , question ) : <EOL> self . ask ( [ question , '<STR_LIT>' ] ) <EOL> while True : <EOL> answer = raw_input ( '<STR_LIT>' ) <EOL> if '<STR_LIT:y>' in answer . lower ( ) : <EOL> return True <EOL> if '<STR_LIT:n>' in answer . lower ( ) : <EOL> return False <EOL> self . tell ( answer + '<STR_LIT>' ) <EOL> def prompt_options ( self , optionlist ) : <EOL> """<STR_LIT>""" <EOL> optionpicker = { } <EOL> for elem in optionlist : <EOL> selection_string = elem [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> if len ( elem ) > <NUM_LIT:2> : <EOL> selection_string = elem [ <NUM_LIT:2> ] <EOL> prepared_option_string = string . replace ( elem [ <NUM_LIT:0> ] , selection_string , '<STR_LIT:(>' + Style . BRIGHT + selection_string + Style . NORMAL + '<STR_LIT:)>' , <NUM_LIT:1> ) <EOL> if prepared_option_string == elem [ <NUM_LIT:0> ] : <EOL> raise Exception ( "<STR_LIT>" % ( selection_string , elem [ <NUM_LIT:0> ] ) ) <EOL> optionpicker [ selection_string ] = [ prepared_option_string , elem [ <NUM_LIT:1> ] ] <EOL> for value in optionpicker . values ( ) : <EOL> self . tell ( value [ <NUM_LIT:0> ] ) <EOL> while True : <EOL> picked_option = raw_input ( '<STR_LIT>' ) <EOL> if picked_option not in optionpicker : <EOL> self . tell ( picked_option + '<STR_LIT>' ) <EOL> continue <EOL> break <EOL> return optionpicker [ picked_option ] [ <NUM_LIT:1> ] </s>
