summaryrefslogtreecommitdiff
path: root/Param/Bool
diff options
context:
space:
mode:
authoryo mama <pepper@scannerjammer.com>2015-09-15 19:39:59 -0700
committeryo mama <pepper@scannerjammer.com>2015-09-15 19:39:59 -0700
commitacc164568a215c3c5e2363855f712291b2a459e1 (patch)
treef91454aca1de19dadc61cd892a5b4fa72c7ac32d /Param/Bool
parent7d0116ba389e061bd609cc999f1c993b7344cf55 (diff)
more oop
Diffstat (limited to 'Param/Bool')
-rw-r--r--Param/Bool/.__init__.py0
-rw-r--r--Param/Bool/__init__.py16
2 files changed, 16 insertions, 0 deletions
diff --git a/Param/Bool/.__init__.py b/Param/Bool/.__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Param/Bool/.__init__.py
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))