mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Migrate basestring to a python3 compatible type (#17199)
This commit is contained in:
parent
a695e18615
commit
a22909c226
28 changed files with 137 additions and 101 deletions
|
@ -122,6 +122,7 @@ import os
|
|||
|
||||
from jinja2.exceptions import UndefinedError
|
||||
|
||||
from ansible.compat.six import string_types
|
||||
from ansible.errors import AnsibleFileNotFound, AnsibleLookupError, AnsibleUndefinedVariable
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.boolean import boolean
|
||||
|
@ -146,14 +147,14 @@ class LookupModule(LookupBase):
|
|||
skip = boolean(term.get('skip', False))
|
||||
|
||||
filelist = files
|
||||
if isinstance(files, basestring):
|
||||
if isinstance(files, string_types):
|
||||
files = files.replace(',', ' ')
|
||||
files = files.replace(';', ' ')
|
||||
filelist = files.split(' ')
|
||||
|
||||
pathlist = paths
|
||||
if paths:
|
||||
if isinstance(paths, basestring):
|
||||
if isinstance(paths, string_types):
|
||||
paths = paths.replace(',', ' ')
|
||||
paths = paths.replace(':', ' ')
|
||||
paths = paths.replace(';', ' ')
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.six import string_types
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.listify import listify_lookup_plugin_terms
|
||||
|
@ -44,7 +45,7 @@ class LookupModule(LookupBase):
|
|||
# ignore undefined items
|
||||
break
|
||||
|
||||
if isinstance(term, basestring):
|
||||
if isinstance(term, string_types):
|
||||
# convert a variable to a list
|
||||
term2 = listify_lookup_plugin_terms(term, templar=self._templar, loader=self._loader)
|
||||
# but avoid converting a plain string to a list of one string
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.six import string_types
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
from ansible.utils.listify import listify_lookup_plugin_terms
|
||||
|
@ -41,7 +42,7 @@ class LookupModule(LookupBase):
|
|||
_raise_terms_error()
|
||||
|
||||
# first term should be a list (or dict), second a string holding the subkey
|
||||
if not isinstance(terms[0], (list, dict)) or not isinstance(terms[1], basestring):
|
||||
if not isinstance(terms[0], (list, dict)) or not isinstance(terms[1], string_types):
|
||||
_raise_terms_error("first a dict or a list, second a string pointing to the subkey")
|
||||
subelements = terms[1].split(".")
|
||||
|
||||
|
@ -59,7 +60,7 @@ class LookupModule(LookupBase):
|
|||
flags = {}
|
||||
if len(terms) == 3:
|
||||
flags = terms[2]
|
||||
if not isinstance(flags, dict) and not all([isinstance(key, basestring) and key in FLAGS for key in flags]):
|
||||
if not isinstance(flags, dict) and not all([isinstance(key, string_types) and key in FLAGS for key in flags]):
|
||||
_raise_terms_error("the optional third item must be a dict with flags %s" % FLAGS)
|
||||
|
||||
# build_items
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue