mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-07 20:47:16 +00:00
[PR #10873/6cd46654 backport][stable-11] Avoid six in plugin code (#10875)
Avoid six in plugin code (#10873)
Avoid six in plugin code.
(cherry picked from commit 6cd4665412)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
3b207ba0fd
commit
1e01aeacb4
34 changed files with 70 additions and 120 deletions
|
|
@ -223,8 +223,9 @@ _value:
|
|||
type: bool
|
||||
'''
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from ansible.errors import AnsibleFilterError
|
||||
from ansible.module_utils.six.moves.collections_abc import Sequence
|
||||
from ansible_collections.community.general.plugins.plugin_utils.ansible_type import _ansible_type
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,6 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils.six import raise_from
|
||||
|
||||
try:
|
||||
from fqdn import FQDN
|
||||
except ImportError as imp_exc:
|
||||
ANOTHER_LIBRARY_IMPORT_ERROR = imp_exc
|
||||
else:
|
||||
ANOTHER_LIBRARY_IMPORT_ERROR = None
|
||||
|
||||
|
||||
DOCUMENTATION = '''
|
||||
name: fqdn_valid
|
||||
|
|
@ -74,6 +64,15 @@ _value:
|
|||
type: bool
|
||||
'''
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
|
||||
try:
|
||||
from fqdn import FQDN
|
||||
except ImportError as imp_exc:
|
||||
ANOTHER_LIBRARY_IMPORT_ERROR = imp_exc
|
||||
else:
|
||||
ANOTHER_LIBRARY_IMPORT_ERROR = None
|
||||
|
||||
|
||||
def fqdn_valid(name, min_labels=1, allow_underscores=False):
|
||||
"""
|
||||
|
|
@ -83,10 +82,7 @@ def fqdn_valid(name, min_labels=1, allow_underscores=False):
|
|||
"""
|
||||
|
||||
if ANOTHER_LIBRARY_IMPORT_ERROR:
|
||||
raise_from(
|
||||
AnsibleError('Python package fqdn must be installed to use this test.'),
|
||||
ANOTHER_LIBRARY_IMPORT_ERROR
|
||||
)
|
||||
raise AnsibleError('Python package fqdn must be installed to use this test.') from ANOTHER_LIBRARY_IMPORT_ERROR
|
||||
|
||||
fobj = FQDN(name, min_labels=min_labels, allow_underscores=allow_underscores)
|
||||
return (fobj.is_valid)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue