diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-12-07 17:27:21 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-12-07 17:27:21 +0000 |
commit | 6f5f86ad4a1f0e208eed93c751f1b71d7cb55c17 (patch) | |
tree | 0a6ff07e252347131e737e9f5a82ccab7a6deb09 /lib/sqlalchemy/topological.py | |
parent | 7bf90e2f4dc211423a409a747a2392922ed7a9c7 (diff) | |
download | sqlalchemy-6f5f86ad4a1f0e208eed93c751f1b71d7cb55c17.tar.gz |
a little refinement to topological options, more to come
Diffstat (limited to 'lib/sqlalchemy/topological.py')
-rw-r--r-- | lib/sqlalchemy/topological.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/sqlalchemy/topological.py b/lib/sqlalchemy/topological.py index ccded5d47..258c3bf74 100644 --- a/lib/sqlalchemy/topological.py +++ b/lib/sqlalchemy/topological.py @@ -143,7 +143,7 @@ class QueueDependencySorter(object): self.tuples = tuples self.allitems = allitems - def sort(self, allow_self_cycles=True, allow_all_cycles=False, create_tree=True): + def sort(self, allow_cycles=False, ignore_self_cycles=False, create_tree=True): (tuples, allitems) = (self.tuples, self.allitems) #print "\n---------------------------------\n" #print repr([t for t in tuples]) @@ -159,12 +159,12 @@ class QueueDependencySorter(object): for t in tuples: if t[0] is t[1]: - if allow_self_cycles: + if allow_cycles: n = nodes[id(t[0])] n.cycles = util.Set([n]) - continue - else: + elif not ignore_self_cycles: raise CircularDependencyError("Self-referential dependency detected " + repr(t)) + continue childnode = nodes[id(t[1])] parentnode = nodes[id(t[0])] edges.add((parentnode, childnode)) @@ -179,7 +179,7 @@ class QueueDependencySorter(object): if not queue: # edges remain but no edgeless nodes to remove; this indicates # a cycle - if allow_all_cycles: + if allow_cycles: for cycle in self._find_cycles(edges): lead = cycle[0][0] lead.cycles = util.Set() @@ -207,6 +207,8 @@ class QueueDependencySorter(object): queue.append(childnode) if create_tree: return self._create_batched_tree(output) + elif allow_cycles: + return output else: return [n.item for n in output] |