]> git.decadent.org.uk Git - dak.git/commitdiff
extensions.py: update @replace_dak_function decorator to automatically
authorAnthony Towns <aj@azure.humbug.org.au>
Fri, 21 Mar 2008 13:25:06 +0000 (13:25 +0000)
committerAnthony Towns <aj@azure.humbug.org.au>
Fri, 21 Mar 2008 13:25:06 +0000 (13:25 +0000)
pass the old function as an argument to the new function

config/debian/extensions.py

index 7e418db3231fcf0d64f7eebf1dc23c01205209f1..d586d4d0014f50d17707685681a9cc6cb30757f0 100644 (file)
@@ -6,11 +6,19 @@ replaced_funcs = {}
 replace_funcs = {}
 def replace_dak_function(module,name):
     def x(f):
-        replace_funcs["%s:%s" % (module,name)] = f
+        def myfunc(*a,**kw):
+           global replaced_funcs
+            f(replaced_funcs[name], *a, **kw)
+       myfunc.__name__ = f.__name__
+       myfunc.__doc__ = f.__doc__
+       myfunc.__dict__.update(f.__dict__)
+
+        replace_funcs["%s:%s" % (module,name)] = myfunc
+       return f
     return x
 
 @replace_dak_function("process-unchecked", "check_signed_by_key")
-def check_signed_by_key():
+def check_signed_by_key(oldfn):
     changes = dak_module.changes
     reject = dak_module.reject
 
@@ -21,11 +29,11 @@ def check_signed_by_key():
             reject("Upload blocked due to hijack attempt 2008/03/19")
 
            # NB: 1.15.0, 1.15.2 signed by this key targetted at unstable
-           #     have been made available in the wild, and should not be
+           #     have been made available in the wild, and should remain
            #     blocked until Debian's dpkg has revved past those version
            #     numbers
 
-    replaced_funcs["check_signed_by_key"]()
+    oldfn()
 
 def init(name):
     global replaced_funcs