def test_exos_liste(self): # 1) parsing parser = Parser() # BREAKPOINT >>> # import pdb; pdb.set_trace() # <<< BREAKPOINT # doc = parser.parse_from_file("../examples/exosliste.tango.tex") # 2) processing processor = DocumentProcessor(doc) core.register_core_processors(processor) py_ctx = codeactive.PythonContext(dict()) codeactive.register_processors(processor, py_ctx) try: processor.process() except codeactive.CheckPythonFailure: print("CheckPython failed, aborpting ...") return #print("After process = \n" + str(doc)) # 3) generating latex_config = LatexConfiguration() latex_config.document_class = "article" generator = LatexDocumentGenerator(doc, latex_config) generator.generate()
def test_eval_python(self): parser = Parser() doc = parser.parse_from_string(""" \evalPython{{{3+2}}} """) print("Before processing = \n" + str(doc)); process = DocumentProcessor(doc) py_ctx = codeactive.PythonContext(dict()) codeactive.register_processors(process, py_ctx) process.process() print("After processing = \n" + str(doc));
def test_def_python(self): parser = Parser() doc = parser.parse_from_string(""" \defPython[fact]{{{ def fact(n): return 1 if n<=1 else n*fact(n-1) }}} \evalPython{{{3+fact(4)}}} """) #print("Before processing = \n" + str(doc)); process = DocumentProcessor(doc) py_ctx = codeactive.PythonContext(dict()) codeactive.register_processors(process, py_ctx) process.process()
# 2) processing if enable_process_phase: tangoPrintln("Processing phase ...") processor = DocumentProcessor(doc) core.register_core_processors(processor) # support for active python code if args.code_active: tangoPrintln("Enabling active python code processors") py_ctx = codeactive.PythonContext(tangolib.globalvars.TANGO_EVAL_GLOBAL_ENV) codeactive.register_processors(processor, py_ctx) try: processor.process() except codeactive.CheckPythonFailure as e: tangoErrln("CheckPython failed ...") fatal(str(e)) tangoPrintln("==> processing done.") # 3) generating generator = None if enable_generate_phase: