summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/classutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/classutils.py')
-rw-r--r--meta/lib/oe/classutils.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/meta/lib/oe/classutils.py b/meta/lib/oe/classutils.py
index 58188fdd6e..e7856c86f2 100644
--- a/meta/lib/oe/classutils.py
+++ b/meta/lib/oe/classutils.py
@@ -1,4 +1,11 @@
1class ClassRegistry(type): 1
2class ClassRegistryMeta(type):
3 """Give each ClassRegistry their own registry"""
4 def __init__(cls, name, bases, attrs):
5 cls.registry = {}
6 type.__init__(cls, name, bases, attrs)
7
8class ClassRegistry(type, metaclass=ClassRegistryMeta):
2 """Maintain a registry of classes, indexed by name. 9 """Maintain a registry of classes, indexed by name.
3 10
4Note that this implementation requires that the names be unique, as it uses 11Note that this implementation requires that the names be unique, as it uses
@@ -12,12 +19,6 @@ Subclasses of ClassRegistry may define an 'implemented' property to exert
12control over whether the class will be added to the registry (e.g. to keep 19control over whether the class will be added to the registry (e.g. to keep
13abstract base classes out of the registry).""" 20abstract base classes out of the registry)."""
14 priority = 0 21 priority = 0
15 class __metaclass__(type):
16 """Give each ClassRegistry their own registry"""
17 def __init__(cls, name, bases, attrs):
18 cls.registry = {}
19 type.__init__(cls, name, bases, attrs)
20
21 def __init__(cls, name, bases, attrs): 22 def __init__(cls, name, bases, attrs):
22 super(ClassRegistry, cls).__init__(name, bases, attrs) 23 super(ClassRegistry, cls).__init__(name, bases, attrs)
23 try: 24 try:
@@ -34,7 +35,7 @@ abstract base classes out of the registry)."""
34 35
35 @classmethod 36 @classmethod
36 def prioritized(tcls): 37 def prioritized(tcls):
37 return sorted(tcls.registry.values(), 38 return sorted(list(tcls.registry.values()),
38 key=lambda v: v.priority, reverse=True) 39 key=lambda v: v.priority, reverse=True)
39 40
40 def unregister(cls): 41 def unregister(cls):