action: support assigning fields with keyword arguments to the constructor
The basic module has been changed to use the new API.
diff --git a/tools/munger/scripts/action_gen.py b/tools/munger/scripts/action_gen.py
index 116cd7b..2e26144 100644
--- a/tools/munger/scripts/action_gen.py
+++ b/tools/munger/scripts/action_gen.py
@@ -72,10 +72,15 @@
--DOC_INFO--
\"""
- def __init__(self):
+ def __init__(self, **kwargs):
--PARENT_TYPE--.__init__(self)
self.type = --ACTION_NAME--
self.len = self.__len__()
+ for (k, v) in kwargs.items():
+ if hasattr(self, k):
+ setattr(self, k, v)
+ else:
+ raise NameError("field %s does not exist in %s" % (k, self.__class__))
def show(self, prefix=''):
outstr = prefix + "action_--TYPE--\\n"
outstr += --PARENT_TYPE--.show(self, prefix)