def _execute_script(self, witch_code): """Given a pile of script revision code, this function prepends the (witch) macro definition and then reads and evals the combined code.""" with_header = '{}\n{}'.format(WITCH_HEADER, witch_code) buff = io.StringIO(with_header) stop = False result = None wi = WitchInterpreter(self) while not stop: try: tree = hy.read(buff) witch_ast = hy_compile(tree, '__main__') wi.evaluate_ast(witch_ast) except EOFError: stop = True return wi.script_engine
def _execute_script(self, witch_code): """Given a pile of script revision code, this function prepends the (witch) macro definition and then reads and evals the combined code.""" script_text = self.script_revision.code with_header = '{}\n{}'.format(WITCH_HEADER, script_text) buff = io.StringIO(with_header) stop = False result = None while not stop: try: tree = hy.read(buff) result = hy.eval(tree, namespace={'ScriptEngine': ScriptEngine}) except EOFError: stop = True return result