Commit e1e8b3e0 authored by Clément Haëck's avatar Clément Haëck
Browse files

Fix boolean conversion in arguments

It would summon `bool()` for conversion, which is always True except
when string is empty.
Now is using configparser.ConfigParser._convert_to_boolean. Much more robust
parent 4056d0dd
......@@ -35,15 +35,22 @@ if not path.isfile(_config_file):
_config.read(_config_file)
_supported_types = {t.__name__: t for t in [int, str, bool, float, type(None)]}
def to_bool(x=None):
if x is None:
return False
return _config._convert_to_boolean(x)
_supported_types = {t.__name__: t for t in [int, str, float, type(None)]}
_supported_types['bool'] = to_bool
DEFAULTS = {}
DEFAULTS_TYPES = {}
for k in _config.options('defaults'):
tp_str, val = _config.get('defaults', k).split(',')
tp = _supported_types[tp_str]
val = val.strip()
if tp_str == 'bool':
val = _config._convert_to_boolean(val)
DEFAULTS[k] = tp(val) if val else tp()
DEFAULTS_TYPES[k] = tp
......
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