// eliminate duplicate prereqs if there is more then one
// empty ordering
for (node, prereqs) in iteritems(ords):
ords[node] = list(OrderedSet(prereqs))
return ords
def check_integrity(self):
After Change
assert isinstance(self._features, list)
all_orderings = []
for feature in self._features:
if hasattr(feature, "orderings"):
orderings = feature.orderings(self)
if not isinstance(orderings, OrderedDict):
raise TypeError("Non-deterministic return value from " +
str(feature.orderings) +
". Nondeterministic object is " +
str(orderings))
if len(orderings) > 0:
all_orderings.append(orderings)
for node, prereqs in iteritems(orderings):
if not isinstance(prereqs, (list, OrderedSet)):
raise TypeError(
"prereqs must be a type with a "
"deterministic iteration order, or toposort "
" will be non-deterministic.")
if len(all_orderings) == 1:
// If there is only 1 ordering, we reuse it directly.
return all_orderings[0]
else:
// If there is more than 1 ordering, combine them.
ords = OrderedDict()
for orderings in all_orderings:
for node, prereqs in iteritems(orderings):
ords.setdefault(node, []).extend(prereqs)
return ords
def check_integrity(self):