Do a topological sort on the dependency graph dict.
(graph)
| 125 | |
| 126 | |
| 127 | def find_order(graph): |
| 128 | ''' |
| 129 | Do a topological sort on the dependency graph dict. |
| 130 | ''' |
| 131 | while graph: |
| 132 | # Find all items without a parent |
| 133 | leftmost = [name for name, dep in graph.items() if not dep] |
| 134 | if not leftmost: |
| 135 | raise ValueError('Dependency cycle detected! %s' % graph) |
| 136 | # If there is more than one, sort them for predictable order |
| 137 | leftmost.sort() |
| 138 | for result in leftmost: |
| 139 | # Yield and remove them from the graph |
| 140 | yield result |
| 141 | graph.pop(result) |
| 142 | for bset in graph.values(): |
| 143 | bset.discard(result) |
| 144 | |
| 145 | |
| 146 | def obvious_conflict_checker(ctx, name_tuples, blacklist=None): |
no outgoing calls
no test coverage detected