Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r9979 - main/trunk/pym/_emerge
Date: Sat, 26 Apr 2008 03:55:45
Message-Id: E1JpbVm-00077Z-UK@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-04-26 03:55:41 +0000 (Sat, 26 Apr 2008)
3 New Revision: 9979
4
5 Modified:
6 main/trunk/pym/_emerge/__init__.py
7 Log:
8 * Add a Blocker class to use instead of tuples.
9 * Fix the Task constructor to properly traverse __slots__ of all inherited
10 classes.
11
12
13 Modified: main/trunk/pym/_emerge/__init__.py
14 ===================================================================
15 --- main/trunk/pym/_emerge/__init__.py 2008-04-26 01:10:52 UTC (rev 9978)
16 +++ main/trunk/pym/_emerge/__init__.py 2008-04-26 03:55:41 UTC (rev 9979)
17 @@ -1209,11 +1209,18 @@
18 __slots__ = ("__weakref__", "_hash_key",)
19
20 def __init__(self, **kwargs):
21 - for myattr in self.__slots__:
22 - if myattr == "__weakref__":
23 + classes = [self.__class__]
24 + while classes:
25 + c = classes.pop()
26 + if c is Task:
27 continue
28 - myvalue = kwargs.get(myattr, None)
29 - setattr(self, myattr, myvalue)
30 + classes.extend(c.__bases__)
31 + slots = getattr(c, "__slots__", None)
32 + if not slots:
33 + continue
34 + for myattr in slots:
35 + myvalue = kwargs.get(myattr, None)
36 + setattr(self, myattr, myvalue)
37
38 def _get_hash_key(self):
39 try:
40 @@ -1245,6 +1252,17 @@
41 def __str__(self):
42 return str(self._get_hash_key())
43
44 +class Blocker(Task):
45 + __slots__ = ("root", "atom")
46 +
47 + def _get_hash_key(self):
48 + try:
49 + return self._hash_key
50 + except AttributeError:
51 + self._hash_key = \
52 + ("blocks", self.root, self.atom)
53 + return self._hash_key
54 +
55 class Package(Task):
56 __slots__ = ("built", "cpv", "depth",
57 "installed", "metadata", "root", "onlydeps", "type_name",
58 @@ -1285,6 +1303,7 @@
59 return False
60
61 class Uninstall(Package):
62 + __slots__ = ()
63 def _get_hash_key(self):
64 try:
65 return self._hash_key
66 @@ -1871,7 +1890,7 @@
67 # The blocker applies to the root where
68 # the parent is or will be installed.
69 self.blocker_parents.setdefault(
70 - ("blocks", dep.parent.root, dep.atom), set()).add(
71 + Blocker(atom=dep.atom, root=dep.parent.root), set()).add(
72 dep.parent)
73 return 1
74 dep_pkg, existing_node = self._select_package(dep.root, dep.atom,
75
76 --
77 gentoo-commits@l.g.o mailing list