diff options
author | Mike Frysinger <vapier@google.com> | 2016-09-26 11:41:16 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2019-06-14 22:55:42 -0400 |
commit | 0ac3ce453a2d2311d3a4abda794ea4c83b196ad3 (patch) | |
tree | 265feb57408e95625680da931745395336527041 /rh/config.py | |
parent | 8359b72c029aceb39df191130b4edf8d07c82c54 (diff) | |
download | repohooks-0ac3ce453a2d2311d3a4abda794ea4c83b196ad3.tar.gz |
support py2 & py3
This makes the code execute properly under both Python 2 and Python 3.
We double up the unittests so that we don't actively break either.
We switch the unittests over to run under Python 3 by default too in
preparation for the future
Bug: 28298984
Test: unittests still pass
Change-Id: Ic67b441f98f902fe8ea3d276b0f4fca9c7cf9f25
Diffstat (limited to 'rh/config.py')
-rw-r--r-- | rh/config.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/rh/config.py b/rh/config.py index 61f2ef0..44cb826 100644 --- a/rh/config.py +++ b/rh/config.py @@ -17,7 +17,6 @@ from __future__ import print_function -import ConfigParser import functools import os import shlex @@ -31,6 +30,7 @@ del _path # pylint: disable=wrong-import-position import rh.hooks import rh.shell +from rh.sixish import configparser class Error(Exception): @@ -41,7 +41,7 @@ class ValidationError(Error): """Config file has unknown sections/keys or other values.""" -class RawConfigParser(ConfigParser.RawConfigParser): +class RawConfigParser(configparser.RawConfigParser): """Like RawConfigParser but with some default helpers.""" @staticmethod @@ -61,8 +61,8 @@ class RawConfigParser(ConfigParser.RawConfigParser): """ cnt = self._check_args('options', 2, 3, args) try: - return ConfigParser.RawConfigParser.options(self, section) - except ConfigParser.NoSectionError: + return configparser.RawConfigParser.options(self, section) + except configparser.NoSectionError: if cnt == 1: return args[0] raise @@ -71,8 +71,8 @@ class RawConfigParser(ConfigParser.RawConfigParser): """Return the value for |option| in |section| (with default |args|).""" cnt = self._check_args('get', 3, 4, args) try: - return ConfigParser.RawConfigParser.get(self, section, option) - except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): + return configparser.RawConfigParser.get(self, section, option) + except (configparser.NoSectionError, configparser.NoOptionError): if cnt == 1: return args[0] raise @@ -81,8 +81,8 @@ class RawConfigParser(ConfigParser.RawConfigParser): """Return a list of (key, value) tuples for the options in |section|.""" cnt = self._check_args('items', 2, 3, args) try: - return ConfigParser.RawConfigParser.items(self, section) - except ConfigParser.NoSectionError: + return configparser.RawConfigParser.items(self, section) + except configparser.NoSectionError: if cnt == 1: return args[0] raise @@ -121,7 +121,7 @@ class PreSubmitConfig(object): self.paths.append(path) try: config.read(path) - except ConfigParser.ParsingError as e: + except configparser.ParsingError as e: raise ValidationError('%s: %s' % (path, e)) self.paths = [] |