diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-10-28 20:53:46 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-10-28 20:53:46 +0000 |
commit | 51bdd5913b5287a6b41ac0fdcd04159fa0514d21 (patch) | |
tree | 62bd79fd110d6d54b4467ea500dd5aa67eccf808 | |
parent | 591d4a65713a5a5c38b1e536a8524f9474a35aa5 (diff) | |
download | portage-51bdd5913b5287a6b41ac0fdcd04159fa0514d21.tar.gz portage-51bdd5913b5287a6b41ac0fdcd04159fa0514d21.tar.bz2 portage-51bdd5913b5287a6b41ac0fdcd04159fa0514d21.zip |
Fix graph.get() so that it works as intended, returning the node corresponding
to the given key.
svn path=/main/trunk/; revision=11737
-rw-r--r-- | pym/portage/__init__.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index b55cebd94..966eec9ac 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -353,14 +353,14 @@ class digraph(object): relationship to the parent, the relationship is left as hard.""" if node not in self.nodes: - self.nodes[node] = ({}, {}) + self.nodes[node] = ({}, {}, node) self.order.append(node) if not parent: return if parent not in self.nodes: - self.nodes[parent] = ({}, {}) + self.nodes[parent] = ({}, {}, parent) self.order.append(parent) if parent in self.nodes[node][1]: @@ -441,7 +441,10 @@ class digraph(object): return node in self.nodes def get(self, key, default=None): - return self.nodes.get(key, default) + node_data = self.nodes.get(key, self) + if node_data is self: + return default + return node_data[2] def all_nodes(self): """Return a list of all nodes in the graph""" @@ -503,7 +506,7 @@ class digraph(object): clone = digraph() clone.nodes = {} for k, v in self.nodes.iteritems(): - clone.nodes[k] = (v[0].copy(), v[1].copy()) + clone.nodes[k] = (v[0].copy(), v[1].copy(), v[2]) clone.order = self.order[:] return clone |