MCPcopy Index your code
hub / github.com/Tencent/CodeAnalysis / ByteCodeParser

Class ByteCodeParser

client/tool/util/loong/bcparser.py:23–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21
22
23class ByteCodeParser(object):
24 def __init__(self, source_dir, db_dir=None):
25 self.project_root = source_dir
26 if db_dir and os.path.exists(db_dir):
27 if os.path.isdir(db_dir):
28 self.bc_db = os.path.join(db_dir, "codedog_bc.db")
29 else:
30 self.bc_db = db_dir
31 else:
32 self.bc_db = os.path.join(source_dir, "codedog_bc.db")
33
34 def get_tool(self):
35 tool_home = os.environ["LOONG_HOME"]
36 tool_path = os.path.join(tool_home, "bin", settings.PLATFORMS[sys.platform], "APIFinder2")
37 if settings.PLATFORMS[sys.platform] == "windows":
38 tool_path = f"{tool_path}.exe"
39 return tool_path
40
41 def parser(self, need_field=False):
42 tool_path = self.get_tool()
43 args = [
44 "path=%s" % self.project_root,
45 "useapi=true",
46 "out=%s" % self.bc_db,
47 ]
48 if need_field:
49 logger.info("use field mode parser.")
50 args.append("field=true")
51 apifinder_cmd = __lu__().format_cmd(tool_path, args)
52
53 try:
54 spc = SubProcController(apifinder_cmd, stdout_line_callback=subprocc_log, stderr_line_callback=subprocc_log)
55 if need_field:
56 spc.wait(60 * 60)
57 else:
58 spc.wait(20 * 60)
59 except ProcessExecuteTimeoutError:
60 logger.info("apifinder timeout.")
61
62
63if __name__ == "__main__":

Callers 2

analyzeMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected