mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-10 06:35:27 +01:00
Fix deprecated six imports for CI compliance
Replace deprecated ansible.module_utils.six imports with Python 3 standard library equivalents to pass pylint sanity checks. plugins/action/synchronize.py: - ansible.module_utils.six.string_types → str - ansible.module_utils.six.moves.shlex_quote → shlex.quote plugins/modules/synchronize.py: - ansible.module_utils.six.moves.shlex_quote → shlex.quote plugins/modules/mount.py: - ansible.module_utils.six.iteritems → dict.items()
This commit is contained in:
parent
dda97be28a
commit
87307a91a2
3 changed files with 11 additions and 6 deletions
|
|
@ -19,10 +19,9 @@ __metaclass__ = type
|
|||
|
||||
import os.path
|
||||
from collections.abc import MutableSequence
|
||||
from shlex import quote as shlex_quote
|
||||
|
||||
from ansible import constants as C
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils.six.moves import shlex_quote
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
from ansible.plugins.action import ActionBase
|
||||
|
|
@ -417,7 +416,7 @@ class ActionModule(ActionBase):
|
|||
# Replicate what we do in the module argumentspec handling for lists
|
||||
if not isinstance(_tmp_args.get('rsync_opts'), MutableSequence):
|
||||
tmp_rsync_opts = _tmp_args.get('rsync_opts', [])
|
||||
if isinstance(tmp_rsync_opts, string_types):
|
||||
if isinstance(tmp_rsync_opts, str):
|
||||
tmp_rsync_opts = tmp_rsync_opts.split(',')
|
||||
elif isinstance(tmp_rsync_opts, (int, float)):
|
||||
tmp_rsync_opts = [to_text(tmp_rsync_opts)]
|
||||
|
|
|
|||
|
|
@ -225,7 +225,6 @@ import platform
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible_collections.ansible.posix.plugins.module_utils.mount import ismount
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.parsing.convert_bool import boolean
|
||||
|
||||
|
|
@ -279,7 +278,7 @@ def _set_mount_save_old(module, args):
|
|||
old_lines = []
|
||||
exists = False
|
||||
changed = False
|
||||
escaped_args = dict([(k, _escape_fstab(v)) for k, v in iteritems(args)])
|
||||
escaped_args = dict([(k, _escape_fstab(v)) for k, v in args.items()])
|
||||
new_line = '%(src)s %(name)s %(fstype)s %(opts)s %(dump)s %(passno)s\n'
|
||||
|
||||
if platform.system() == 'SunOS':
|
||||
|
|
|
|||
|
|
@ -367,9 +367,16 @@ EXAMPLES = r'''
|
|||
import os
|
||||
import errno
|
||||
|
||||
# TODO(Python2): shlex.quote was added in Python 3.3. This module may run on
|
||||
# target hosts with Python 2.7 (e.g., older RHEL systems in CI integration tests).
|
||||
# Remove the try/except fallback to pipes.quote when Python 2 support is dropped.
|
||||
try:
|
||||
from shlex import quote as shlex_quote
|
||||
except ImportError:
|
||||
from pipes import quote as shlex_quote
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.common.text.converters import to_bytes, to_native
|
||||
from ansible.module_utils.six.moves import shlex_quote
|
||||
|
||||
|
||||
client_addr = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue