1 |
Author: zmedico |
2 |
Date: 2008-10-28 20:53:46 +0000 (Tue, 28 Oct 2008) |
3 |
New Revision: 11737 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
Log: |
8 |
Fix graph.get() so that it works as intended, returning the node corresponding |
9 |
to the given key. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/__init__.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/__init__.py 2008-10-28 19:09:53 UTC (rev 11736) |
15 |
+++ main/trunk/pym/portage/__init__.py 2008-10-28 20:53:46 UTC (rev 11737) |
16 |
@@ -353,14 +353,14 @@ |
17 |
relationship to the parent, the relationship is left as hard.""" |
18 |
|
19 |
if node not in self.nodes: |
20 |
- self.nodes[node] = ({}, {}) |
21 |
+ self.nodes[node] = ({}, {}, node) |
22 |
self.order.append(node) |
23 |
|
24 |
if not parent: |
25 |
return |
26 |
|
27 |
if parent not in self.nodes: |
28 |
- self.nodes[parent] = ({}, {}) |
29 |
+ self.nodes[parent] = ({}, {}, parent) |
30 |
self.order.append(parent) |
31 |
|
32 |
if parent in self.nodes[node][1]: |
33 |
@@ -441,7 +441,10 @@ |
34 |
return node in self.nodes |
35 |
|
36 |
def get(self, key, default=None): |
37 |
- return self.nodes.get(key, default) |
38 |
+ node_data = self.nodes.get(key, self) |
39 |
+ if node_data is self: |
40 |
+ return default |
41 |
+ return node_data[2] |
42 |
|
43 |
def all_nodes(self): |
44 |
"""Return a list of all nodes in the graph""" |
45 |
@@ -503,7 +506,7 @@ |
46 |
clone = digraph() |
47 |
clone.nodes = {} |
48 |
for k, v in self.nodes.iteritems(): |
49 |
- clone.nodes[k] = (v[0].copy(), v[1].copy()) |
50 |
+ clone.nodes[k] = (v[0].copy(), v[1].copy(), v[2]) |
51 |
clone.order = self.order[:] |
52 |
return clone |