Replace ConfigParser with configparser

The ConfigParser module has been renamed to configparser in
Python 3. [1] Backport of this changes is also available for
Python 2. [2]

[1] https://docs.python.org/2/library/configparser.html
[2] https://pypi.python.org/pypi/configparser/3.2.0r3
This commit is contained in:
Radostin Stoyanov 2017-10-11 12:35:39 +01:00 committed by Cole Robinson
parent 40c678783e
commit 810ee09292
3 changed files with 12 additions and 12 deletions

View File

@ -234,8 +234,8 @@ class URLTests(unittest.TestCase):
def _make_tests():
import ConfigParser
cfg = ConfigParser.ConfigParser()
import configparser
cfg = configparser.ConfigParser()
cfg.read("tests/test_urls.ini")
manualpath = "tests/test_urls_manual.ini"

View File

@ -21,11 +21,11 @@
Configuration variables that can be set at build time
"""
import ConfigParser
import configparser
import os
_cfg = ConfigParser.ConfigParser()
_cfg = configparser.ConfigParser()
_filepath = os.path.abspath(__file__)
_srcdir = os.path.abspath(os.path.join(os.path.dirname(_filepath), ".."))
_cfgpath = os.path.join(os.path.dirname(_filepath), "cli.cfg")
@ -46,7 +46,7 @@ def _get_param(name, default):
return default
try:
return _cfg.get("config", name)
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
except (configparser.NoOptionError, configparser.NoSectionError):
return default

View File

@ -19,7 +19,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
import ConfigParser
import configparser
import ftplib
import io
import logging
@ -393,14 +393,14 @@ def _grabTreeinfo(fetcher):
return None
try:
treeinfo = ConfigParser.SafeConfigParser()
treeinfo = configparser.SafeConfigParser()
treeinfo.read(tmptreeinfo)
finally:
os.unlink(tmptreeinfo)
try:
treeinfo.get("general", "family")
except ConfigParser.NoSectionError:
except configparser.NoSectionError:
logging.debug("Did not find 'family' section in treeinfo")
return None
@ -601,7 +601,7 @@ class Distro(object):
try:
kernelpath = self._getTreeinfoMedia("kernel")
initrdpath = self._getTreeinfoMedia("initrd")
except ConfigParser.NoSectionError:
except configparser.NoSectionError:
pass
if not kernelpath or not initrdpath:
@ -737,15 +737,15 @@ class GenericDistro(Distro):
self._valid_kernel_path = (
self._getTreeinfoMedia("kernel"),
self._getTreeinfoMedia("initrd"))
except (ConfigParser.NoSectionError,
ConfigParser.NoOptionError) as e:
except (configparser.NoSectionError,
configparser.NoOptionError) as e:
logging.debug(e)
if self.treeinfo.has_section(isoSection):
try:
self._valid_iso_path = self.treeinfo.get(isoSection,
"boot.iso")
except ConfigParser.NoOptionError as e:
except configparser.NoOptionError as e:
logging.debug(e)
if self.type == "xen":