public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r11737 - main/trunk/pym/portage
@ 2008-10-28 20:53 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-10-28 20:53 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2008-10-28 20:53:46 +0000 (Tue, 28 Oct 2008)
New Revision: 11737

Modified:
   main/trunk/pym/portage/__init__.py
Log:
Fix graph.get() so that it works as intended, returning the node corresponding
to the given key.


Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2008-10-28 19:09:53 UTC (rev 11736)
+++ main/trunk/pym/portage/__init__.py	2008-10-28 20:53:46 UTC (rev 11737)
@@ -353,14 +353,14 @@
 		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 @@
 		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 @@
 		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
 




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-10-28 20:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-28 20:53 [gentoo-commits] portage r11737 - main/trunk/pym/portage Zac Medico (zmedico)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox