def renderCFG(self, graphName="defaultCFG_", view=False): graphName = graphName + self.fn_name graph = to_graph(gen_cfg(self.fn_source)) graph.render(graphName, view=view)
def show_cfg(fn, **kwargs): return Source(to_graph(gen_cfg(inspect.getsource(fn)), **kwargs))
from ControlFlow import gen_cfg, to_graph from graphviz import Source cfg = gen_cfg(inspect.getsource(my_function)) graph = to_graph(cfg) Source(graph)