Commit b21185d9 authored by Gero Müller's avatar Gero Müller
Browse files

fix vispa.config for bool

parent 7ba3c672
...@@ -89,6 +89,12 @@ class VispaConfigParser(cp.SafeConfigParser): ...@@ -89,6 +89,12 @@ class VispaConfigParser(cp.SafeConfigParser):
# try to cast according to 'default' # try to cast according to 'default'
if default is None: if default is None:
return value return value
# boolean
if isinstance(default, bool):
if value == 'True':
return True
elif value == 'False':
return False
# int # int
if isinstance(default, int): if isinstance(default, int):
return int(value) return int(value)
...@@ -99,7 +105,7 @@ class VispaConfigParser(cp.SafeConfigParser): ...@@ -99,7 +105,7 @@ class VispaConfigParser(cp.SafeConfigParser):
if isinstance(default, str): if isinstance(default, str):
return str(value) return str(value)
# list # list
elif isinstance(default, list): if isinstance(default, list):
l = [] l = []
g = tokenize.generate_tokens(StringIO(value).readline) g = tokenize.generate_tokens(StringIO(value).readline)
for toknum, tokval, _, _, _ in g: for toknum, tokval, _, _, _ in g:
...@@ -110,20 +116,13 @@ class VispaConfigParser(cp.SafeConfigParser): ...@@ -110,20 +116,13 @@ class VispaConfigParser(cp.SafeConfigParser):
return l return l
# tuple # tuple
elif isinstance(default, tuple): if isinstance(default, tuple):
if len(value): if len(value):
return tuple(value.split(',')) return tuple(value.split(','))
else: else:
return () return ()
# boolean
elif isinstance(default, bool):
if value == 'True':
return True
elif value == 'False':
return False
# TODO: dict # TODO: dict
else: return value
return value
else: else:
return default return default
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment