def compile_dot(self, tmpdir, file_src, file_target, format, transitive_reduction=True, unflatten=True): """ tred: computes transitive reduction, meaning if App.dpr imports Lib.pas and Module.pas, and Module.pas itself imports Lib.pas, the edge from App.dpr to Lib.pas is eliminated """ (dotbin, tredbin, unflattenbin) = io.find_dot_tools() if transitive_reduction: ret, output = io.invoke([tredbin, file_src], cwd=tmpdir) if not ret: open(os.path.join(tmpdir, file_src), 'w').write(output) if unflatten: ret, output = io.invoke([unflattenbin, file_src], cwd=tmpdir) if not ret: open(os.path.join(tmpdir, file_src), 'w').write(output) io.invoke([dotbin, '-T%s' % format, file_src, '-o', file_target], cwd=tmpdir)
def main(args): prog = args.pop(0) # try to locate prog on same path as sys.argv[0] if not os.path.exists(prog): path = os.path.dirname(os.path.abspath(sys.argv[0])) prog = os.path.join(path, prog) if not os.path.exists(prog): io.write_result('Not found: %s' % os.path.basename(prog), error=True) return fp = io.get_tmpfile(os.path.basename(prog) + '.profile') args = ['python', '-m', 'cProfile', '-o', fp, prog] + args io.invoke(args) strip_dirs(fp) output(fp)
def exec_txl(cls, txlprog, filepath, txlargs=None): directory, filename = os.path.split(filepath) directory = directory and directory or "." txlbin = DelphiCompiler.get_txl_binary(relative_to=directory) grammar_path = DelphiCompiler.get_txl_grammar_path(relative_to=directory) txlprog = os.path.join(grammar_path, txlprog) if not io.platform_is_linux(): txlprog = io.path_cygwin_to_win(txlprog) txlargs = txlargs and txlargs or [] return io.invoke([txlbin] + txlargs + [txlprog, filename], cwd=directory, return_all=True)
def show_dot(self, tred=True): format = 'pdf' file_src = io.get_tmpfile(self.delphifile.filename) file_target = io.get_tmpfile('%s.%s' % (self.delphifile.filename, format)) # split up tmpdir = os.path.dirname(file_src) file_src = os.path.basename(file_src) file_target = os.path.basename(file_target) self.write_dot(tmpdir, file_src) self.compile_dot(tmpdir, file_src, file_target, format, transitive_reduction=tred) try: reader = io.find_pdf_reader() io.invoke([reader, file_target], cwd=tmpdir) except: import traceback traceback.print_exc() finally: os.unlink(os.path.join(tmpdir, file_src)) os.unlink(os.path.join(tmpdir, file_target))