From b29b0ec5f11dd66434cbdfba5287c4777d7f8ac9 Mon Sep 17 00:00:00 2001 From: yo mama Date: Mon, 21 Sep 2015 14:20:13 -0700 Subject: new file structure --- lib/Param/Bool/__init__.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 lib/Param/Bool/__init__.py (limited to 'lib/Param/Bool/__init__.py') diff --git a/lib/Param/Bool/__init__.py b/lib/Param/Bool/__init__.py new file mode 100644 index 0000000..8ccca00 --- /dev/null +++ b/lib/Param/Bool/__init__.py @@ -0,0 +1,18 @@ +from Param import Param +import re +class ParamBool(Param): + def __init__(self, value, classname=""): + super(ParamBool, self).__init__(classname=classname) + if value: + self.value = self._bool_correct(value) + else: + self.value = False + 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