MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeText-parser / print_result

Function print_result

src/codetext/codetext_cli.py:80–168  ·  view source on GitHub ↗
(res: Dict, file_name: str = "no_name_file")

Source from the content-addressed store, hash-verified

78
79
80def print_result(res: Dict, file_name: str = "no_name_file"):
81 # ======== Print file name ========
82 print("File {name} analyzed:".format(name=file_name))
83 print(50 * "=")
84
85 # ========= Summary =========
86 print("Number of class : {length}".format(length=len(res["class"])))
87 print("Number of function : {length}".format(length=len(res["function"])))
88 print(50 * "-" + "\n")
89
90 # ========= Print class & method =========
91 cls_headers = ["#", "Class", "Arguments"]
92 cls_method_headers = ["#", "Method name", "Paramters",
93 "Type", "Return type", "Throws"]
94 cls_info = []
95 method_info = {}
96 for cls_idx, _cls in enumerate(res["class"]):
97 cls_max_length = max(1, len(_cls["parameters"].keys()))
98 for i in range(cls_max_length):
99 clslist = [""] * len(cls_headers)
100 clslist[0] = cls_idx if i < 1 else ""
101 clslist[1] = _cls["identifier"] if i < 1 else ""
102 if _cls["parameters"].keys():
103 clslist[2] = list(_cls["parameters"].keys())[i]
104 cls_info.append(clslist)
105
106 _method_info = []
107 for idx, method in enumerate(_cls["method"]):
108 max_length = max(1, len(method["parameters"].keys()))
109 for i in range(max_length):
110 sublist = [""] * len(cls_method_headers)
111 sublist[0] = idx if i < 1 else ""
112 sublist[1] = method["identifier"] if i < 1 else ""
113 if method["parameters"].keys():
114 sublist[2] = list(method["parameters"].keys())[i]
115 sublist[3] = list(method["parameters"].values())[i]
116 sublist[4] = (
117 method["return_type"]
118 if i <= 1 and method["return_type"] != "<not_specific>"
119 else ""
120 )
121 sublist[5] = (
122 method["throws"]
123 if i <= 1 and "throws" in method.keys()
124 else ""
125 )
126 _method_info.append(sublist)
127
128 method_info[file_name] = [_cls["identifier"], _method_info]
129
130 if cls_info:
131 print("Class summary:")
132 print(tabulate(cls_info, headers=cls_headers, tablefmt="outline"))
133 print("\n")
134
135 for _, info in method_info.items():
136 name, info = info
137 print("Class analyse: {name}".format(name=name))

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected