def add_node(self, name, info):
max_depth, father = 0, None
- for n in [Node(x, self, None) for x in info['depends']]:
+ for d in info['depends']:
+ n = self.get(d) or Node(d, self, None) # lazy creation, do not use default value for get()
if n.depth >= max_depth:
father = n
max_depth = n.depth
later.clear()
current.remove(package)
node = self.add_node(package, info)
- node.data = info
for kind in ('init', 'demo', 'update'):
if package in tools.config[kind] or 'all' in tools.config[kind] or kind in force:
setattr(node, kind, True)
yield module
level += 1
+ def __str__(self):
+ return '\n'.join(str(n) for n in self if n.depth == 0)
class Node(object):
""" One module in the modules dependency graph.
inst = graph[name]
else:
inst = object.__new__(cls)
- inst.name = name
- inst.info = info
graph[name] = inst
return inst
def __init__(self, name, graph, info):
+ self.name = name
self.graph = graph
+ self.info = info or getattr(self, 'info', {})
if not hasattr(self, 'children'):
self.children = []
if not hasattr(self, 'depth'):
self.depth = 0
- self.info = info or {}
+
+ @property
+ def data(self):
+ return self.info
def add_child(self, name, info):
node = Node(name, self.graph, info)