mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Update module_utils.six to latest (#22855)
* Update module_utils.six to latest We've been held back on the version of six we could use on the module side to 1.4.x because of python-2.4 compatibility. Now that our minimum is Python-2.6, we can update to the latest version of six in module_utils and get rid of the second copy in lib/ansible/compat.
This commit is contained in:
@@ -406,7 +406,11 @@ class ModuleDepFinder(ast.NodeVisitor):
|
||||
self.generic_visit(node)
|
||||
|
||||
def visit_ImportFrom(self, node):
|
||||
if node.module.startswith('ansible.module_utils'):
|
||||
# Specialcase: six is a special case because of its
|
||||
# import logic
|
||||
if node.names[0].name == '_six':
|
||||
self.submodules.add(('_six',))
|
||||
elif node.module.startswith('ansible.module_utils'):
|
||||
where_from = node.module[self.IMPORT_PREFIX_SIZE:]
|
||||
if where_from:
|
||||
# from ansible.module_utils.MODULE1[.MODULEn] import IDENTIFIER [as asname]
|
||||
@@ -484,6 +488,12 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf):
|
||||
module_info = imp.find_module('six', module_utils_paths)
|
||||
py_module_name = ('six',)
|
||||
idx = 0
|
||||
elif py_module_name[0] == '_six':
|
||||
# Special case the python six library because it messes up the
|
||||
# import process in an incompatible way
|
||||
module_info = imp.find_module('_six', [os.path.join(p, 'six') for p in module_utils_paths])
|
||||
py_module_name = ('six', '_six')
|
||||
idx = 0
|
||||
else:
|
||||
# Check whether either the last or the second to last identifier is
|
||||
# a module name
|
||||
@@ -499,7 +509,7 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf):
|
||||
|
||||
# Could not find the module. Construct a helpful error message.
|
||||
if module_info is None:
|
||||
msg = ['Could not find imported module support code for %s. Looked for' % name]
|
||||
msg = ['Could not find imported module support code for %s. Looked for' % (name,)]
|
||||
if idx == 2:
|
||||
msg.append('either %s.py or %s.py' % (py_module_name[-1], py_module_name[-2]))
|
||||
else:
|
||||
|
||||
@@ -21,14 +21,14 @@ __metaclass__ = type
|
||||
|
||||
import fnmatch
|
||||
|
||||
from ansible.compat.six import iteritems
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils.six import cmp
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.playbook.block import Block
|
||||
from ansible.playbook.task import Task
|
||||
from ansible.playbook.role_include import IncludeRole
|
||||
|
||||
|
||||
boolean = C.mk_boolean
|
||||
|
||||
__all__ = ['PlayIterator']
|
||||
|
||||
@@ -24,11 +24,10 @@ import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from ansible.compat.six import iteritems, string_types, binary_type
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable, AnsibleConnectionFailure
|
||||
from ansible.executor.task_result import TaskResult
|
||||
from ansible.module_utils.six import iteritems, string_types, binary_type
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.playbook.conditional import Conditional
|
||||
from ansible.playbook.task import Task
|
||||
@@ -44,6 +43,7 @@ except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
|
||||
__all__ = ['TaskExecutor']
|
||||
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ import os
|
||||
import tempfile
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.compat.six import string_types
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.executor.play_iterator import PlayIterator
|
||||
from ansible.executor.stats import AggregateStats
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.playbook.block import Block
|
||||
from ansible.playbook.play_context import PlayContext
|
||||
@@ -44,6 +44,7 @@ except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
|
||||
__all__ = ['TaskQueueManager']
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user