summaryrefslogtreecommitdiff
path: root/Param/Bool/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Param/Bool/__init__.py')
-rw-r--r--Param/Bool/__init__.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Param/Bool/__init__.py b/Param/Bool/__init__.py
new file mode 100644
index 0000000..38fa7fa
--- /dev/null
+++ b/Param/Bool/__init__.py
@@ -0,0 +1,16 @@
+from Param import Param
+
+def ParamBool(Param):
+ def __init__(self, value, classname=""):
+ self._classname = classname
+ super(ParamBool).__init__()
+ self.value = self._bool_correct(value)
+ def _bool_correct(self, b):
+ if type(b) == str:
+ if re.match(r'true', b, re.IGNORECASE):
+ return True
+ elif re.match(r'false', b, re.IGNORECASE):
+ return False
+ elif type(b) == bool:
+ return b
+ self.err_warn("Not a bool: %s" % str(b))