提交 708592ca 编写于 作者: C Cleber Rosa

Python 2 leftovers: drop conditional import of ConfigParser

We can now just use the module name as in Python 3 standard library.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 e086cf09
......@@ -13,16 +13,12 @@
# Author: Travis Miller <raphtee@google.com>
"""
Reads the avocado settings from a .ini file (from python ConfigParser).
Reads the avocado settings from a .ini file (with Python's configparser).
"""
import ast
import os
import glob
try:
import ConfigParser
except ImportError:
import configparser as ConfigParser
import configparser
from pkg_resources import resource_filename
from pkg_resources import resource_isdir
......@@ -144,7 +140,7 @@ def convert_value_type(value, value_type):
class Settings(object):
"""
Simple wrapper around ConfigParser, with a key type conversion available.
Simple wrapper around configparser, with a key type conversion available.
"""
no_default = object()
......@@ -155,7 +151,7 @@ class Settings(object):
:param config_path: Path to a config file. Useful for unittesting.
"""
self.config = ConfigParser.ConfigParser()
self.config = configparser.ConfigParser()
self.config_paths = []
self.all_config_paths = []
_source_tree_root = os.path.dirname(os.path.dirname(os.path.dirname(
......@@ -295,9 +291,9 @@ class Settings(object):
"""
try:
val = self.config.get(section, key)
except ConfigParser.NoSectionError:
except configparser.NoSectionError:
return self._handle_no_section(section, default)
except ConfigParser.Error:
except configparser.Error:
return self._handle_no_value(section, key, default)
if not val.strip() and not allow_blank:
......
......@@ -40,6 +40,7 @@ import shutil
import logging
import optparse
import tempfile
import configparser
try:
import yum
......@@ -48,11 +49,6 @@ except ImportError:
else:
HAS_YUM_MODULE = True
try:
import ConfigParser
except ImportError:
import configparser as ConfigParser
from . import process
from . import data_factory
from . import distro
......@@ -403,7 +399,7 @@ class YumBackend(RpmBackend):
base_arguments = '-y'
self.base_command = executable + ' ' + base_arguments
self.repo_file_path = '/etc/yum.repos.d/avocado-managed.repo'
self.cfgparser = ConfigParser.ConfigParser()
self.cfgparser = configparser.ConfigParser()
self.cfgparser.read(self.repo_file_path)
y_cmd = executable + ' --version | head -1'
cmd_result = process.run(y_cmd, ignore_status=True,
......
......@@ -8,7 +8,7 @@ and that's why a configuration system is in place to help with those cases
The Avocado config file format is based on the (informal)
`INI file 'specification' <http://en.wikipedia.org/wiki/INI_file>`__, that is implemented by
Python's :mod:`ConfigParser`. The format is simple and straightforward, composed by `sections`,
Python's :mod:`configparser`. The format is simple and straightforward, composed by `sections`,
that contain a number of `keys` and `values`. Take for example a basic Avocado config file:
.. code-block:: ini
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册