|
|
@ -32,8 +32,6 @@ from ansible.module_utils.common.text.converters import to_native, to_text
|
|
|
|
from ansible.parsing.splitter import parse_kv
|
|
|
|
from ansible.parsing.splitter import parse_kv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ADDITIONAL_PY2_KEYWORDS = frozenset(("True", "False", "None"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_MAXSIZE = 2 ** 32
|
|
|
|
_MAXSIZE = 2 ** 32
|
|
|
|
cur_id = 0
|
|
|
|
cur_id = 0
|
|
|
|
node_mac = ("%012x" % uuid.getnode())[:12]
|
|
|
|
node_mac = ("%012x" % uuid.getnode())[:12]
|
|
|
@ -237,7 +235,22 @@ def load_options_vars(version):
|
|
|
|
return load_options_vars.options_vars
|
|
|
|
return load_options_vars.options_vars
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _isidentifier_PY3(ident):
|
|
|
|
def isidentifier(ident):
|
|
|
|
|
|
|
|
"""Determine if string is valid identifier.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The purpose of this function is to be used to validate any variables created in
|
|
|
|
|
|
|
|
a play to be valid Python identifiers and to not conflict with Python keywords
|
|
|
|
|
|
|
|
to prevent unexpected behavior. Since Python 2 and Python 3 differ in what
|
|
|
|
|
|
|
|
a valid identifier is, this function unifies the validation so playbooks are
|
|
|
|
|
|
|
|
portable between the two. The following changes were made:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* disallow non-ascii characters (Python 3 allows for them as opposed to Python 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:arg ident: A text string of identifier to check. Note: It is callers
|
|
|
|
|
|
|
|
responsibility to convert ident to text if it is not already.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Originally posted at https://stackoverflow.com/a/29586366
|
|
|
|
|
|
|
|
"""
|
|
|
|
if not isinstance(ident, string_types):
|
|
|
|
if not isinstance(ident, string_types):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
@ -251,25 +264,3 @@ def _isidentifier_PY3(ident):
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isidentifier = _isidentifier_PY3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isidentifier.__doc__ = """Determine if string is valid identifier.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The purpose of this function is to be used to validate any variables created in
|
|
|
|
|
|
|
|
a play to be valid Python identifiers and to not conflict with Python keywords
|
|
|
|
|
|
|
|
to prevent unexpected behavior. Since Python 2 and Python 3 differ in what
|
|
|
|
|
|
|
|
a valid identifier is, this function unifies the validation so playbooks are
|
|
|
|
|
|
|
|
portable between the two. The following changes were made:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* disallow non-ascii characters (Python 3 allows for them as opposed to Python 2)
|
|
|
|
|
|
|
|
* True, False and None are reserved keywords (these are reserved keywords
|
|
|
|
|
|
|
|
on Python 3 as opposed to Python 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:arg ident: A text string of identifier to check. Note: It is callers
|
|
|
|
|
|
|
|
responsibility to convert ident to text if it is not already.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Originally posted at http://stackoverflow.com/a/29586366
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|