[bugfix] re-implement ability of get_bool to return unidentifiable input
This commit is contained in:
parent
5b18e9ab71
commit
6688ef845d
@ -334,7 +334,7 @@ def get_none(value):
|
|||||||
|
|
||||||
def get_bool(value):
|
def get_bool(value):
|
||||||
"""
|
"""
|
||||||
Convert string representations of bools to their true boolean value
|
Convert string representations of bools to their true boolean value. Return value if it cannot be identified as bool.
|
||||||
:param value:
|
:param value:
|
||||||
:type value: str, bool, int, float
|
:type value: str, bool, int, float
|
||||||
:return: true boolean value
|
:return: true boolean value
|
||||||
@ -356,6 +356,8 @@ def get_bool(value):
|
|||||||
False
|
False
|
||||||
>>> get_bool(-0.3)
|
>>> get_bool(-0.3)
|
||||||
False
|
False
|
||||||
|
>>> get_bool(None)
|
||||||
|
None
|
||||||
"""
|
"""
|
||||||
if type(value) is bool:
|
if type(value) is bool:
|
||||||
return value
|
return value
|
||||||
@ -363,10 +365,13 @@ def get_bool(value):
|
|||||||
return True
|
return True
|
||||||
elif value in ['False', 'false']:
|
elif value in ['False', 'false']:
|
||||||
return False
|
return False
|
||||||
elif value > 0. or value > 0:
|
elif isinstance(value, float) or isinstance(value, int):
|
||||||
return True
|
if value > 0. or value > 0:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
return False
|
return value
|
||||||
|
|
||||||
|
|
||||||
def four_digits(year):
|
def four_digits(year):
|
||||||
|
Loading…
Reference in New Issue
Block a user