Skip to content

Commit

Permalink
Replace ConfigParser with configparser
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rst0git authored and crobinso committed Feb 6, 2018
1 parent 40c6787 commit 810ee09
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tests/test_urls.py
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions virtcli/cliconfig.py
Expand Up @@ -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")
Expand All @@ -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


Expand Down
14 changes: 7 additions & 7 deletions virtinst/urlfetcher.py
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -601,7 +601,7 @@ def acquireKernel(self, guest):
try:
kernelpath = self._getTreeinfoMedia("kernel")
initrdpath = self._getTreeinfoMedia("initrd")
except ConfigParser.NoSectionError:
except configparser.NoSectionError:
pass

if not kernelpath or not initrdpath:
Expand Down Expand Up @@ -737,15 +737,15 @@ def isValidStore(self):
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":
Expand Down

0 comments on commit 810ee09

Please sign in to comment.