def createModulesGraph(moddb):
graph = pydot.Dot(graph_type='digraph')
nodes = dict()
# add modules as nodes
for mod in moddb.getModules():
tt = ", ".join(mod.provides) + " "
node = pydot.Node(mod.name, tooltip=tt)
nodes[mod.name] = node
graph.add_node(node)
# add directed edges from modules to modules that satisfy at least one dependency
for src in moddb.getModules():
dstmods = moddb.getSolutionCandidates(src)
for dst in dstmods:
tt = ", ".join(dstmods[dst]) + " "
edge = pydot.Edge(src.name, dst.name, tooltip=tt)
graph.add_edge(edge)
# add special directed edges for "modules" inclusion
for src in moddb.getModules():
for dstname in src.modules:
dst = moddb[dstname]
edge = pydot.Edge(src.name, dst.name, color="green")
graph.add_edge(edge)
# add undirected edges for conflicts
for src in moddb.getModules():
conflicts = moddb.getConflictingModules(src)
for dst in conflicts:
if (dst.name < src.name):
tt = ", ".join(conflicts[dst]) + " "
edge = pydot.Edge(src.name, dst.name, color="red", dir="none", tooltip=tt)
graph.add_edge(edge)
graph.write('dependencies.dot')
# TODO rewrite as mako template and drop pydot dependency
评论列表
文章目录