From 51bdd5913b5287a6b41ac0fdcd04159fa0514d21 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 28 Oct 2008 20:53:46 +0000 Subject: [PATCH] Fix graph.get() so that it works as intended, returning the node corresponding to the given key. svn path=/main/trunk/; revision=11737 --- pym/portage/__init__.py | 11 +++++++---- 1 file 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 -- 2.26.2