Add kwargs parameter to sysprep decorator
authorNikos Skalkotos <skalkoto@grnet.gr>
Wed, 10 Jul 2013 07:31:33 +0000 (10:31 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Tue, 30 Jul 2013 13:43:59 +0000 (16:43 +0300)
This can be used to add arbitrary attributes to the function it
decorates

image_creator/os_type/__init__.py

index 855022f..e41c52c 100644 (file)
@@ -68,13 +68,16 @@ def add_prefix(target):
     return wrapper
 
 
-def sysprep(message, enabled=True):
+def sysprep(message, enabled=True, **kwargs):
     """Decorator for system preparation tasks"""
     def wrapper1(func):
         func.sysprep = True
         func.enabled = enabled
         func.executed = False
 
+        for key, val in kwargs.items():
+            setattr(func, key, val)
+
         @wraps(func)
         def wrapper2(self, print_message=True):
             if print_message: