MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / write_file

Function write_file

code2flow/engine.py:231–265  ·  view source on GitHub ↗

Write a dot file that can be read by graphviz :param outfile File: :param nodes list[Node]: functions :param edges list[Edge]: function calls :param groups list[Group]: classes and files :param hide_legend bool: :rtype: None

(outfile, nodes, edges, groups, hide_legend=False,
               no_grouping=False, as_json=False)

Source from the content-addressed store, hash-verified

229
230
231def write_file(outfile, nodes, edges, groups, hide_legend=False,
232 no_grouping=False, as_json=False):
233 '''
234 Write a dot file that can be read by graphviz
235
236 :param outfile File:
237 :param nodes list[Node]: functions
238 :param edges list[Edge]: function calls
239 :param groups list[Group]: classes and files
240 :param hide_legend bool:
241 :rtype: None
242 '''
243
244 if as_json:
245 content = generate_json(nodes, edges)
246 outfile.write(content)
247 return
248
249 splines = "polyline" if len(edges) >= 500 else "ortho"
250
251 content = "digraph G {\n"
252 content += "concentrate=true;\n"
253 content += f'splines="{splines}";\n'
254 content += 'rankdir="LR";\n'
255 if not hide_legend:
256 content += LEGEND
257 for node in nodes:
258 content += node.to_dot() + ';\n'
259 for edge in edges:
260 content += edge.to_dot() + ';\n'
261 if not no_grouping:
262 for group in groups:
263 content += group.to_dot()
264 content += '}\n'
265 outfile.write(content)
266
267
268def determine_language(individual_files):

Callers 1

code2flowFunction · 0.85

Calls 2

generate_jsonFunction · 0.85
to_dotMethod · 0.45

Tested by

no test coverage detected