def recur(res): if res: for question, callback in res: recur(callback(prompt(question + '\n'))) while True: try: text = prompt(args.input_prompt, history=history, completer=completer) if not text.split(): # skip whitespace input continue recur(finder.parse(text)) except KeyboardInterrupt: finder.do_exit(None) except EOFError: finder.do_exit(None) except NotImplementedError: print("Functionality is not yet implemented... :-(") except ParseError as e: print( "Bad input [{value}], expected format is [{expected}]".format( value=e.value, expected=e.expected)) except AssertionError as e: print("Bad input value: {assertion}".format(assertion=e)) except ValueError as e: print("Bad input value: {message}".format(message=e.args[0])) except Exception as e: print("Unrecognized error:") print("\t" + traceback.format_exc().replace("\n", "\n\t"))