[kernel] r10333 - people/waldi/dkt/lib/dkt/hooks

Bastian Blank waldi at alioth.debian.org
Thu Jan 31 11:50:39 UTC 2008


Author: waldi
Date: Thu Jan 31 11:50:38 2008
New Revision: 10333

Log:
* lib/dkt/hooks/interfaces.py: Remove old include.
* lib/dkt/hooks/registry.py: Merge runner.
* lib/dkt/hooks/runner.py: Remove.


Removed:
   people/waldi/dkt/lib/dkt/hooks/runner.py
Modified:
   people/waldi/dkt/lib/dkt/hooks/interfaces.py
   people/waldi/dkt/lib/dkt/hooks/registry.py

Modified: people/waldi/dkt/lib/dkt/hooks/interfaces.py
==============================================================================
--- people/waldi/dkt/lib/dkt/hooks/interfaces.py	(original)
+++ people/waldi/dkt/lib/dkt/hooks/interfaces.py	Thu Jan 31 11:50:38 2008
@@ -1,5 +1,4 @@
 from dkt.interface import Interface, implements
-import runner
 
 class IHook(Interface):
     pass

Modified: people/waldi/dkt/lib/dkt/hooks/registry.py
==============================================================================
--- people/waldi/dkt/lib/dkt/hooks/registry.py	(original)
+++ people/waldi/dkt/lib/dkt/hooks/registry.py	Thu Jan 31 11:50:38 2008
@@ -18,18 +18,38 @@
         i.add(module, interface, object, priority, predecessors, successors)
         self._interfaces[interface] = i
 
-    def run(self, interface, *args, **kw):
-        import interfaces, runner
+    def run(self, interface, func, *args, **kw):
+        import interfaces
+
+        l = self._interfaces[interface].get()
+
         if issubclass(interface, interfaces.IHookRunAll):
-            r = runner.RunAll
+            def runner(*args, **kw):
+                for i in l:
+                    f = getattr(i.object, func)
+                    f(*args, **kw)
+
         elif issubclass(interface, interfaces.IHookRunAllArg):
-            r = runner.RunAllArg
+            def runner(arg1, *args, **kw):
+                for i in l:
+                    f = getattr(i.object, func)
+                    ret = f(arg1, *args, **kw)
+                    if ret is not None:
+                        arg1 = ret
+                return arg1
+
         elif issubclass(interface, interfaces.IHookRunFirst):
-            r = runner.RunFirst
+            def runner(*args, **kw):
+                for i in l:
+                    f = getattr(i.object, func)
+                    ret = f(*args, **kw)
+                    if ret is not None:
+                        return ret
+
         else:
             raise RuntimeError
-        l = [i.object for i in self._interfaces[interface]._modules.itervalues()]
-        return r(l)
+
+        return runner(*args, **kw)
 
 class Hook(object):
     def __init__(self, module, interface, object, priority, predecessors, successors):



More information about the Kernel-svn-changes mailing list