mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-19 10:21:30 +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
|
|
@ -135,7 +135,6 @@ import socket
|
|||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin, Cacheable, to_safe_group_name
|
||||
from ansible.module_utils.six import text_type
|
||||
|
||||
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
|
||||
|
||||
|
|
@ -264,7 +263,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
|||
self.cobbler = xmlrpc_client.Server(self.cobbler_url, allow_none=True)
|
||||
self.token = None
|
||||
if self.get_option('user') is not None:
|
||||
self.token = self.cobbler.login(text_type(self.get_option('user')), text_type(self.get_option('password')))
|
||||
self.token = self.cobbler.login(str(self.get_option('user')), str(self.get_option('password')))
|
||||
|
||||
self.cache_key = self.get_cache_key(path)
|
||||
self.use_cache = cache and self.get_option('cache')
|
||||
|
|
|
|||
|
|
@ -95,11 +95,11 @@ compose:
|
|||
"""
|
||||
|
||||
import json
|
||||
from urllib.error import HTTPError
|
||||
|
||||
from ansible.errors import AnsibleParserError
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable
|
||||
from ansible.module_utils.urls import open_url
|
||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
||||
|
||||
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
|
||||
|
||||
|
|
|
|||
|
|
@ -171,12 +171,12 @@ import json
|
|||
import re
|
||||
import time
|
||||
import os
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
from ansible.module_utils.common.text.converters import to_native, to_text
|
||||
from ansible.module_utils.common.dict_transformations import dict_merge
|
||||
from ansible.module_utils.six import raise_from
|
||||
from ansible.errors import AnsibleError, AnsibleParserError
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
from ansible_collections.community.general.plugins.module_utils.lxd import LXDClient, LXDClientException
|
||||
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
|
||||
|
||||
|
|
@ -1094,9 +1094,7 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
Returns:
|
||||
None"""
|
||||
if IPADDRESS_IMPORT_ERROR:
|
||||
raise_from(
|
||||
AnsibleError('another_library must be installed to use this plugin'),
|
||||
IPADDRESS_IMPORT_ERROR)
|
||||
raise AnsibleError('another_library must be installed to use this plugin') from IPADDRESS_IMPORT_ERROR
|
||||
|
||||
super(InventoryModule, self).parse(inventory, loader, path, cache=False)
|
||||
# Read the inventory YAML file
|
||||
|
|
|
|||
|
|
@ -62,13 +62,13 @@ groups:
|
|||
|
||||
import json
|
||||
from sys import version as python_version
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.module_utils.urls import open_url
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible.module_utils.ansible_release import __version__ as ansible_version
|
||||
from ansible.module_utils.six.moves.urllib.parse import urljoin
|
||||
|
||||
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
|
||||
|
||||
|
|
|
|||
|
|
@ -132,9 +132,8 @@ from ansible_collections.community.general.plugins.module_utils.scaleway import
|
|||
from ansible_collections.community.general.plugins.plugin_utils.unsafe import make_unsafe
|
||||
from ansible.module_utils.urls import open_url
|
||||
from ansible.module_utils.common.text.converters import to_text
|
||||
from ansible.module_utils.six import raise_from
|
||||
|
||||
import ansible.module_utils.six.moves.urllib.parse as urllib_parse
|
||||
import urllib.parse as urllib_parse
|
||||
|
||||
|
||||
def _fetch_information(token, url):
|
||||
|
|
@ -338,7 +337,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
|
|||
|
||||
def parse(self, inventory, loader, path, cache=True):
|
||||
if YAML_IMPORT_ERROR:
|
||||
raise_from(AnsibleError('PyYAML is probably missing'), YAML_IMPORT_ERROR)
|
||||
raise AnsibleError('PyYAML is probably missing') from YAML_IMPORT_ERROR
|
||||
super(InventoryModule, self).parse(inventory, loader, path)
|
||||
self._read_config_data(path=path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue