def dump_lino_indent_result(): """ 将 AstHelper#get_lino_indent_dict() 的结果输出到 json 文件. IN: temp/in.py OT: temp/out.json """ from lk_utils.read_and_write_basic import write_json helper = AstAnalyser('../temp/in.py') res = helper.get_lino_indent_dict() write_json(res, '../temp/out.json')
def test(): """ 将 AstHelper 解析结果输出到 json 文件. IN: test.py OT: ast_helper_result.json """ from lk_utils.read_and_write_basic import write_json helper = AstHelper('../../temp/in.py') res = helper.main() write_json(res, '../../temp/out.json')
def dump_asthelper_result(): """ 将 AstHelper 解析结果输出到 json 文件. IN: temp/in.py suggest copied from testflight/test_app_launcher.py OT: temp/out.json backup this file to res/sample/ast_helper_result/{module}.json """ from lk_utils.read_and_write_basic import write_json helper = AstAnalyser('../temp/in.py') res = helper.main() write_json(res, '../temp/out.json')
def main(): ifile = '../../temp/in.py' ofile = 'module_linos_dump.json' ast_ana = AstAnalyser(ifile) ast_tree = ast_ana.main() ast_indents = ast_ana.get_lino_indent_dict() # mod_hlp: module helper mod_hlp = ModuleHelper('../../') mod_hlp.bind_file(ifile) # mod_idx: module index mod_idx = ModuleIndexing(mod_hlp, ast_tree, ast_indents) out = mod_idx.indexing_module_linos() write_json(out, ofile)
def show(self, runtime_module): """ IN: self.tile_view: dict. {module: [call1, call2, ...]} e.g. res/sample/pycallchain_tile_view.json OT: self.cascade_view: dict. {runtime_module: {module1: {module11: {... }, module12: {...}, ...}}} e.g. res/sample/pycallchain_cascade_view.json """ node = self.cascade_view.setdefault(runtime_module, {}) calls = self.tile_view.get(runtime_module) self.recurse(node, calls) lk.logt('[D3619]', self.stacks) # lk.logt('[I3316]', self.cascade_view) # TEST output from lk_utils.read_and_write_basic import write_json write_json(self.cascade_view, '../temp/out.json') write_json(self.tile_view, '../temp/out2.json')
def main(): """ 将 AstHelper 解析结果 (ast_tree) 输出到 ast_analyser_dump.json 文件. IN: temp/in.py OT: tests/debug/ast_analyser_dump.json """ ifile = '../../temp/in.py' ofile = 'ast_analyser_dump.json' analyser = AstAnalyser(ifile) ast_tree = analyser.main() ast_indents = analyser.get_lino_indent_dict() out = ast_tree for lino, ast_data in ast_tree.items(): indent = ast_indents[lino] out[lino].insert(0, indent) write_json(out, ofile)