MCPcopy Index your code
hub / github.com/Persper/code-analytics / main

Function main

dev_analysis.py:90–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88 c += 3
89
90def main():
91 parser = argparse.ArgumentParser()
92 parser.add_argument('-x', required=True,
93 help='dir of the XML form of source code')
94 parser.add_argument('-s', help='dir of the source code repo')
95 parser.add_argument('-o', required=True, help='output .xmlx file')
96 parser.add_argument('-a', type=float, nargs=3, required=True,
97 help='lowest alpha, highest alpha and \
98 step for iteration')
99 parser.add_argument('-n', type=int, nargs='+',
100 help='(multiple) # of commits to analyze')
101 parser.add_argument('-p', action='store_true',
102 help='run PageRank on the call graph')
103 parser.add_argument('-d', action='store_true',
104 help='run DevRank on the call graph')
105 parser.add_argument('-c', action='store_true',
106 help='run DevRank on the call-commit graph')
107 args = parser.parse_args()
108
109 xml_dir = os.path.expanduser(args.x)
110 if not os.path.isdir(xml_dir):
111 sys.exit('Invalid dir for -x.')
112
113 wb = load_workbook(args.o) if os.path.isfile(args.o) else Workbook()
114 for ws in wb.worksheets:
115 if ws.max_row == 0:
116 wb.remove(ws)
117 graph = None
118 func2file = None
119
120 if args.p:
121 if graph is None:
122 graph, func2file = build_call_graph(xml_dir)
123 ranks_array = pagerank_c(graph, args.a[0], args.a[1], args.a[2])
124 ranks_array = fname_array(ranks_array, func2file)
125 ws = wb.create_sheet('PageRank-C')
126 output(ranks_array, ws, args.a[0], args.a[1], args.a[2])
127 wb.save(args.o)
128 if args.d:
129 if graph is None:
130 graph, func2file = build_call_graph(xml_dir)
131 ranks_array = devrank_c(graph, args.a[0], args.a[1], args.a[2])
132 ranks_array = fname_array(ranks_array, func2file)
133 ws = wb.create_sheet('DevRank-C')
134 output(ranks_array, ws, args.a[0], args.a[1], args.a[2])
135 wb.save(args.o)
136 if args.c:
137 if args.s is None or args.n is None:
138 sys.exit('Specify -s and -n for call-commit graph.')
139 src_dir = os.path.expanduser(args.s)
140 if not os.path.isdir(src_dir):
141 sys.exit('Invalid dir for -s.')
142 if graph is None:
143 graph, func2file = build_call_graph(xml_dir)
144 ccg = CallCommitGraph(src_dir)
145 for n in args.n:
146 ccg.process(rev='v4.10', num_commits=n, into_branches=True)
147 ranks_array = devrank_c2(ccg, args.a[0], args.a[1], args.a[2])

Callers 1

dev_analysis.pyFile · 0.70

Calls 10

CallCommitGraphClass · 0.90
build_call_graphFunction · 0.85
pagerank_cFunction · 0.85
fname_arrayFunction · 0.85
outputFunction · 0.85
devrank_cFunction · 0.85
devrank_c2Function · 0.85
exitMethod · 0.80
saveMethod · 0.45
processMethod · 0.45

Tested by

no test coverage detected