summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmar Takhar <amar@rtems.org>2015-06-10 08:29:22 -0400
committerAmar Takhar <amar@rtems.org>2015-12-11 15:16:19 -0500
commit148f01152d662163caa3d3208138733b9afbe093 (patch)
tree104e1b7ce41452232f7a117417d33a4b75ca91e9
parent0233afe707d69144b636d2d4d6452e36c9742c88 (diff)
Add helper function for adding options.
-rwxr-xr-xpy/config/tool.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/py/config/tool.py b/py/config/tool.py
new file mode 100755
index 0000000000..6afa5e8526
--- /dev/null
+++ b/py/config/tool.py
@@ -0,0 +1,17 @@
+import inspect
+
+
+# Collect a list of options from a module.
+# XXX: check to make sure only options are fed to this.
+def get_option_class(module):
+ map = {}
+ skip = ("Option", "Boolean", "String", "StringList", "Integer")
+ for name, obj in inspect.getmembers(module):
+ if inspect.isclass(obj) and name not in skip:
+ if name in map:
+ raise Exception("Duplicate option: %s" % name)
+ map[name] = obj
+
+ return map
+
+