mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
Remove all usage of ansible.module_utils.six from main branch (#10888)
* Get rid of all six.moves imports. * Get rid of iteritems. * Get rid of *_type(s) aliases. * Replace StringIO import. * Get rid of PY2/PY3 constants. * Get rid of raise_from. * Get rid of python_2_unicode_compatible. * Clean up global six imports. * Remove all usage of ansible.module_utils.six. * Linting. * Fix xml module. * Docs adjustments.
This commit is contained in:
parent
8f8a0e1d7c
commit
a8977afb04
113 changed files with 188 additions and 352 deletions
|
|
@ -361,6 +361,7 @@ import os
|
|||
import re
|
||||
import traceback
|
||||
|
||||
from collections.abc import MutableMapping
|
||||
from io import BytesIO
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
|
||||
|
|
@ -374,8 +375,6 @@ except ImportError:
|
|||
HAS_LXML = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule, json_dict_bytes_to_unicode, missing_required_lib
|
||||
from ansible.module_utils.six import iteritems, string_types
|
||||
from ansible.module_utils.six.moves.collections_abc import MutableMapping
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
|
||||
_IDENT = r"[a-zA-Z-][a-zA-Z0-9_\-\.]*"
|
||||
|
|
@ -746,13 +745,13 @@ def child_to_element(module, child, in_type):
|
|||
except etree.XMLSyntaxError as e:
|
||||
module.fail_json(msg="Error while parsing child element: %s" % e)
|
||||
elif in_type == 'yaml':
|
||||
if isinstance(child, string_types):
|
||||
if isinstance(child, str):
|
||||
return etree.Element(child)
|
||||
elif isinstance(child, MutableMapping):
|
||||
if len(child) > 1:
|
||||
module.fail_json(msg="Can only create children from hashes with one key")
|
||||
|
||||
(key, value) = next(iteritems(child))
|
||||
(key, value) = list(child.items())[0]
|
||||
if isinstance(value, MutableMapping):
|
||||
children = value.pop('_', None)
|
||||
child_value = value.pop('+value', None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue