blob: 8ccca007844e7054565ff918c9d1f61ea31a8495 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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))
|