mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
optimize booleanifycation
This commit is contained in:
parent
b0786a1845
commit
7ea56e1c79
1 changed files with 3 additions and 1 deletions
|
@ -29,12 +29,14 @@ from ansible.compat.six.moves import configparser
|
||||||
from ansible.parsing.quoting import unquote
|
from ansible.parsing.quoting import unquote
|
||||||
from ansible.errors import AnsibleOptionsError
|
from ansible.errors import AnsibleOptionsError
|
||||||
|
|
||||||
|
BOOL_TRUE = frozenset([ "true", "t", "y", "1", "yes", "on" ])
|
||||||
|
|
||||||
# copied from utils, avoid circular reference fun :)
|
# copied from utils, avoid circular reference fun :)
|
||||||
def mk_boolean(value):
|
def mk_boolean(value):
|
||||||
if value is None:
|
if value is None:
|
||||||
return False
|
return False
|
||||||
val = str(value)
|
val = str(value)
|
||||||
if val.lower() in [ "true", "t", "y", "1", "yes", "on" ]:
|
if val.lower() in BOOL_TRUE:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue