mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Make configparser imports python3 ready
the ConfigParser module was renamed to configparser in Python3. Use six.moves to import it so that the modules will function on Python3.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import ConfigParser
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
@@ -29,7 +28,9 @@ import inspect
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
from os.path import expanduser
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six.moves import configparser
|
||||
|
||||
AZURE_COMMON_ARGS = dict(
|
||||
profile=dict(type='str'),
|
||||
@@ -299,7 +300,7 @@ class AzureRMModuleBase(object):
|
||||
def _get_profile(self, profile="default"):
|
||||
path = expanduser("~/.azure/credentials")
|
||||
try:
|
||||
config = ConfigParser.ConfigParser()
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path)
|
||||
except Exception as exc:
|
||||
self.fail("Failed to access {0}. Check that the file exists and you have read "
|
||||
|
||||
@@ -36,12 +36,12 @@ except ImportError:
|
||||
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||
pass
|
||||
|
||||
import urllib
|
||||
from ConfigParser import ConfigParser, NoSectionError
|
||||
import os
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.urls import *
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.six.moves import configparser
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
EXO_DNS_BASEURL="https://api.exoscale.ch/dns/v1"
|
||||
|
||||
@@ -115,7 +115,7 @@ class ExoDns(object):
|
||||
raise SystemExit("Config file not found. Tried {0}".format(
|
||||
", ".join(paths)))
|
||||
|
||||
conf = ConfigParser()
|
||||
conf = configparser.ConfigParser()
|
||||
conf.read(paths)
|
||||
return dict(conf.items(ini_group))
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@
|
||||
import os
|
||||
import re
|
||||
import types
|
||||
import ConfigParser
|
||||
|
||||
from ansible.module_utils.six.moves import configparser
|
||||
|
||||
|
||||
class RegistrationBase(object):
|
||||
@@ -59,7 +60,7 @@ class RegistrationBase(object):
|
||||
def update_plugin_conf(self, plugin, enabled=True):
|
||||
plugin_conf = '/etc/yum/pluginconf.d/%s.conf' % plugin
|
||||
if os.path.isfile(plugin_conf):
|
||||
cfg = ConfigParser.ConfigParser()
|
||||
cfg = configparser.ConfigParser()
|
||||
cfg.read([plugin_conf])
|
||||
if enabled:
|
||||
cfg.set('main', 'enabled', 1)
|
||||
@@ -87,7 +88,7 @@ class Rhsm(RegistrationBase):
|
||||
'''
|
||||
|
||||
# Read RHSM defaults ...
|
||||
cp = ConfigParser.ConfigParser()
|
||||
cp = configparser.ConfigParser()
|
||||
cp.read(rhsm_conf)
|
||||
|
||||
# Add support for specifying a default value w/o having to standup some configuration
|
||||
@@ -99,7 +100,7 @@ class Rhsm(RegistrationBase):
|
||||
else:
|
||||
return default
|
||||
|
||||
cp.get_option = types.MethodType(get_option_default, cp, ConfigParser.ConfigParser)
|
||||
cp.get_option = types.MethodType(get_option_default, cp, configparser.ConfigParser)
|
||||
|
||||
return cp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user