From acc164568a215c3c5e2363855f712291b2a459e1 Mon Sep 17 00:00:00 2001 From: yo mama Date: Tue, 15 Sep 2015 19:39:59 -0700 Subject: more oop --- Param/Bool/.__init__.py | 0 Param/Bool/__init__.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Param/Bool/.__init__.py create mode 100644 Param/Bool/__init__.py (limited to 'Param/Bool') diff --git a/Param/Bool/.__init__.py b/Param/Bool/.__init__.py new file mode 100644 index 0000000..e69de29 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)) -- cgit v1.2.3-70-g09d2