PEP8 cleanups, add missing imports
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
## {{{ http://code.activestate.com/recipes/578272/ (r1)
|
||||
# {{{ http://code.activestate.com/recipes/578272/ (r1)
|
||||
def toposort2(data):
|
||||
"""Dependencies are expressed as a dictionary whose keys are items
|
||||
and whose values are a set of dependent items. Output is a list of
|
||||
sets in topological order. The first set consists of items with no
|
||||
dependences, each subsequent set consists of items that depend upon
|
||||
items in the preceeding sets.
|
||||
and whose values are a set of dependent items. Output is a list of
|
||||
sets in topological order. The first set consists of items with no
|
||||
dependences, each subsequent set consists of items that depend upon
|
||||
items in the preceeding sets.
|
||||
|
||||
>>> print '\\n'.join(repr(sorted(x)) for x in toposort2({
|
||||
... 2: set([11]),
|
||||
... 9: set([11,8]),
|
||||
... 10: set([11,3]),
|
||||
... 11: set([7,5]),
|
||||
... 8: set([7,3]),
|
||||
... }) )
|
||||
[3, 5, 7]
|
||||
[8, 11]
|
||||
[2, 9, 10]
|
||||
>>> print '\\n'.join(repr(sorted(x)) for x in toposort2({
|
||||
... 2: set([11]),
|
||||
... 9: set([11,8]),
|
||||
... 10: set([11,3]),
|
||||
... 11: set([7,5]),
|
||||
... 8: set([7,3]),
|
||||
... }) )
|
||||
[3, 5, 7]
|
||||
[8, 11]
|
||||
[2, 9, 10]
|
||||
|
||||
"""
|
||||
"""
|
||||
|
||||
from functools import reduce
|
||||
|
||||
@@ -39,4 +39,4 @@ items in the preceeding sets.
|
||||
if item not in ordered:
|
||||
data[item] = dep - ordered
|
||||
assert not data, "Cyclic dependencies exist among these items:\n%s" % '\n'.join(repr(x) for x in data.iteritems())
|
||||
## end of http://code.activestate.com/recipes/578272/ }}}
|
||||
# end of http://code.activestate.com/recipes/578272/ }}}
|
||||
|
||||
Reference in New Issue
Block a user