Implement boolean configs
This commit is contained in:
@@ -83,6 +83,16 @@ def _config_set_in_scope(scope: dict, key: str, value, cfg_type: type) -> str:
|
||||
elif cfg_type == float:
|
||||
scope[key] = float(value)
|
||||
success = True
|
||||
elif cfg_type == bool:
|
||||
value = value.lower()
|
||||
if value in ('true', '1', 'yes', 'y', 'positive', 'enable', 'en'):
|
||||
value = True
|
||||
elif value in ('false', '0', 'no', 'n', 'negative', 'disable', 'dis'):
|
||||
value = False
|
||||
else:
|
||||
return 'Unable to convert given value to a boolean!'
|
||||
scope[key] = value
|
||||
success = True
|
||||
except (TypeError, ValueError):
|
||||
success = False
|
||||
if success:
|
||||
|
||||
Reference in New Issue
Block a user