Fix error in Dependencies representation
This mostly only exists for debugging, but it's helpful if it can actually run. Change-Id: Ie29da5e7e58aed54aaaffa4df479fa0d96ce78fe
This commit is contained in:
parent
990bbbbd46
commit
0f47986b65
|
@ -62,16 +62,18 @@ class Dependencies(object):
|
|||
return self
|
||||
|
||||
def __nonzero__(self):
|
||||
'''Test if this node is a leaf (requires nothing)'''
|
||||
'''
|
||||
Return True if this node is not a leaf (it requires other nodes)
|
||||
'''
|
||||
return bool(self.require)
|
||||
|
||||
def stem(self):
|
||||
'''Test if this node is a stem (required by nothing)'''
|
||||
'''Return True if this node is a stem (required by nothing)'''
|
||||
return not bool(self.satisfy)
|
||||
|
||||
def disjoint(self):
|
||||
'''Test if this node is both a lead and a stem'''
|
||||
return self and self.stem()
|
||||
'''Return True if this node is both a leaf and a stem'''
|
||||
return (not self) and self.stem()
|
||||
|
||||
def __len__(self):
|
||||
'''Count the number of keys required by this node'''
|
||||
|
@ -159,11 +161,12 @@ class Dependencies(object):
|
|||
else:
|
||||
for rqd in node:
|
||||
yield (rqr, rqd)
|
||||
return (outgoing_edges(*item) for item in self.deps.iteritems())
|
||||
return itertools.chain.from_iterable(outgoing_edges(*item)
|
||||
for item in self.deps.iteritems())
|
||||
|
||||
def __repr__(self):
|
||||
'''Return a string representation of the object'''
|
||||
return 'Dependencies([%s])' % ', '.join(repr(e) for e in edges)
|
||||
return 'Dependencies([%s])' % ', '.join(repr(e) for e in self._edges())
|
||||
|
||||
def _toposort(self, deps):
|
||||
'''Generate a topological sort of a dependency graph'''
|
||||
|
|
|
@ -48,6 +48,11 @@ class dependenciesTest(unittest.TestCase):
|
|||
'"%s" is not greater than "%s"' % (str(a), str(b)))
|
||||
self._dep_test(reversed, assertGreater, deps)
|
||||
|
||||
def test_repr(self):
|
||||
dp = Dependencies([('1', None), ('2', '3'), ('2', '4')])
|
||||
s = "Dependencies([('1', None), ('2', '3'), ('2', '4')])"
|
||||
self.assertEqual(repr(dp), s)
|
||||
|
||||
def test_single_node(self):
|
||||
d = Dependencies([('only', None)])
|
||||
l = list(iter(d))
|
||||
|
|
Loading…
Reference in New Issue