def generate_ast_tree(dot: str, errors): file_used_by_another = True i = 0 error_file_used_by_another_part_one = "Command '['dot', '-Tpdf', '-O', 'AST_Report_" + str( i) + "']' " error_file_used_by_another_part_two = "returned non-zero exit status 1. " error_file_used_by_another_part_three = "[stderr: b'Error: Could not open \"AST_Report_" + str( i) + ".pdf\" for writing : Permission denied\\r\\n']" error_file_used_by_another = error_file_used_by_another_part_one + error_file_used_by_another_part_two + error_file_used_by_another_part_three while file_used_by_another == True: error_file_used_by_another_part_one = "Command '['dot', '-Tpdf', '-O', 'AST_Report_" + str( i) + "']' " error_file_used_by_another_part_three = "[stderr: b'Error: Could not open \"AST_Report_" + str( i) + ".pdf\" for writing : Permission denied\\r\\n']" error_file_used_by_another = error_file_used_by_another_part_one + error_file_used_by_another_part_two + error_file_used_by_another_part_three try: src = Source(dot) src.render('AST_Report_' + str(i), view=True) file_used_by_another = False except Exception as e: if str(e) == error_file_used_by_another: file_used_by_another = True i += 1 else: file_used_by_another = False errors.append( Error("Unknown", "AST graphic not generated", 0, 0)) print_error("Unknown Error", "AST graphic not generated")
def generate_grammar_report(content_grammar_report_: str): try: file_grammar_report = open("bnf.md", "w") file_grammar_report.write(content_grammar_report_) file_grammar_report.close() generate_grammar_report_view(content_grammar_report_) except Exception as e: print_error("Unknown Error", "Grammar report file not generated")
def compile_C3D_aux(c3d_optimized): global path_c3d try: up() #exec(compile(c3d_optimized, path_c3d, 'exec')) except Exception as e: print_error("UNKNOWN ERROR", "Error running optimized c3d, " + str(e), 2)
def generate_grammar_report_view(content_grammar_report_: str): try: grammar_report_html = "<!DOCTYPE html>\n" grammar_report_html += "<html lang=\"es-ES\">\n" grammar_report_html += " <head>\n" grammar_report_html += " <meta charset=\"utf-8\">" grammar_report_html += " <title>bnf.md</title>\n" grammar_report_html += " </head>\n" grammar_report_html += " <body>\n" grammar_report_split = content_grammar_report_.split("\n") i = 0 while i < len(grammar_report_split): grammar_report_html += " <p>" + grammar_report_split[i] + "</p>" i += 1 grammar_report_html += " </body>" grammar_report_html += "</html>" file_grammar_report_html = open("bnf.md.html", "w") file_grammar_report_html.write(grammar_report_html) file_grammar_report_html.close() webbrowser.open("bnf.md.html", new=2, autoraise=True) except Exception as e: print_error("Unknown Error", "Grammar report view not generated")