Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def visit_FunctionNode(self, node):
"Create a graphviz graph"
self.graph = pydot.Dot(self.name, graph_type='digraph')
pydot_function = self.create_node(node)
pydot_body = self.visit(node.body)
# Create artificial arguments for brevity
pydot_args = pydot.Node("Arguments (omitted)")
self.add_node(pydot_args)
self.add_edge(pydot_function, pydot_body)
self.add_edge(pydot_function, pydot_args)
return self.graph
def get_node(self, name):
"""Retrieve a node from the graph.
Given a node's name the corresponding Node
instance will be returned.
If one or more nodes exist with that name a list of
Node instances is returned.
An empty list is returned otherwise.
"""
match = list()
if self.obj_dict['nodes'].has_key(name):
match.extend( [ Node( obj_dict = obj_dict ) for obj_dict in self.obj_dict['nodes'][name] ])
return match
def create_node(self, node):
"Create a graphviz node from the miniast node"
label = '"%s"' % self.format_node(node, want_type_info=False)
self.counter += 1
pydot_node = pydot.Node(str(self.counter), label=label)
self.add_node(pydot_node)
return pydot_node
for e in self.obj_dict['nodes'].itervalues():
node_obj_dicts.extend(e)
sgraph_obj_dicts = list()
for sg in self.obj_dict['subgraphs'].itervalues():
sgraph_obj_dicts.extend(sg)
obj_list = [ (obj['sequence'], obj) for obj in (edge_obj_dicts + node_obj_dicts + sgraph_obj_dicts) ]
obj_list.sort()
for idx, obj in obj_list:
if obj['type'] == 'node':
node = Node(obj_dict=obj)
if self.obj_dict.get('suppress_disconnected', False):
if (node.get_name() not in edge_src_set and
node.get_name() not in edge_dst_set):
continue
graph.append( node.to_string()+'\n' )
elif obj['type'] == 'edge':
edge = Edge(obj_dict=obj)
if self.obj_dict.get('simplify', False) and edge in edges_done:
continue
def set_node_defaults(self, **attrs):
self.add_node( Node('node', **attrs) )
def set_graph_defaults(self, **attrs):
self.add_node( Node('graph', **attrs) )