summaryrefslogtreecommitdiff
path: root/Param/Bool/__init__.py
blob: 38fa7fa8b8f96a14daf7ea87e46226f9e6a4135d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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))