Use ConfigParser instead of SafeConfigParser in Python 3

The SafeConfigParser class has been renamed to ConfigParser in Python
3.2 [1]. The alias SafeConfigParser maybe removed in future versions of
Python 3. Use ConfigParser instead of SafeConfigParser in Python 3

This patch also fix code to pass E305 expected 2 blank lines after
class or function definition

[1] http://bugs.python.org/issue10627

Change-Id: I2fb67aa276f8895b9e16fea3440565218adbf426
Closes-Bug: #1618666
This commit is contained in:
Luong Anh Tuan 2016-11-28 09:14:14 +07:00
parent af90c22808
commit 91c43fc342
10 changed files with 14 additions and 6 deletions

View File

@ -205,6 +205,7 @@ class BLOCK_NAMES(object):
supplementary_private_use_area_a = "Supplementary Private Use Area-A"
supplementary_private_use_area_b = "Supplementary Private Use Area-B"
_unicode_planes = (
(0x0, 0xffff, PLANE_NAMES.basic_multilingual_plane),
(0x10000, 0x1ffff, PLANE_NAMES.supplementary_multilingual_plane),

View File

@ -21,7 +21,7 @@ import textwrap
import getpass
import shutil
from subprocess import Popen, PIPE
from six.moves.configparser import SafeConfigParser
from six.moves import configparser
import cafe
from cafe.engine.config import EngineConfig
@ -479,7 +479,7 @@ class EngineConfigManager(object):
@staticmethod
def read_config_file(path):
config = SafeConfigParser()
config = configparser.ConfigParser()
cfp = open(path, 'r')
config.readfp(cfp)
cfp.close()
@ -530,7 +530,7 @@ class EngineConfigManager(object):
@classmethod
def generate_default_engine_config(cls):
config = SafeConfigParser()
config = configparser.ConfigParser()
config.add_section('OPENCAFE_ENGINE')
config.set(
'OPENCAFE_ENGINE', 'config_directory',

View File

@ -107,5 +107,6 @@ def print_mug(base_dir):
print(brew)
print("-" * len(brew))
if __name__ == '__main__':
entry_point()

View File

@ -105,5 +105,6 @@ def print_mug(base_dir):
print(brew)
print("-" * len(brew))
if __name__ == '__main__':
entry_point()

View File

@ -323,7 +323,7 @@ class BrewFile(object):
raise RunFileNotFoundError(msg)
# TODO: Add checks for duplicate sections among multiple files
cfg = configparser.SafeConfigParser()
cfg = configparser.ConfigParser()
cfg.read(f)
# Check for incomplete sections, excluding reserved
@ -342,6 +342,6 @@ class BrewFile(object):
raise RunFileIncompleteBrewError(msg)
# config files are valid, return aggregate config parser object
cfg = configparser.SafeConfigParser()
cfg = configparser.ConfigParser()
cfg.read(files)
return cfg

View File

@ -68,6 +68,7 @@ def _get_path_from_env(os_env_var):
" environment variable.".format(os_env_var))
raise exception
# Standard format to for flat key/value data sources
CONFIG_KEY = 'CAFE_{section_name}_{key}'
@ -142,7 +143,7 @@ class ConfigParserDataSource(DataSource):
cafe_env_var = {key: value for key, value in os.environ.iteritems()
if key.startswith('CAFE_')}
self._data_source = configparser.SafeConfigParser(
self._data_source = configparser.ConfigParser(
defaults=cafe_env_var)
self._section_name = section_name

View File

@ -29,6 +29,7 @@ class Tox(TestCommand):
errno = tox.cmdline(self.test_args)
sys.exit(errno)
setup(
name='cafe_http_plugin',
version='0.0.1',

View File

@ -29,6 +29,7 @@ class Tox(TestCommand):
errno = tox.cmdline(self.test_args)
sys.exit(errno)
setup(
name='cafe_rsyslog_plugin',
version='0.0.1',

View File

@ -29,6 +29,7 @@ class Tox(TestCommand):
errno = tox.cmdline(self.test_args)
sys.exit(errno)
setup(
name='cafe_soap_plugin',
version='0.0.1',

View File

@ -36,6 +36,7 @@ class Tox(TestCommand):
errno = tox.cmdline(self.test_args)
sys.exit(errno)
# Package the plugin cache as package data
plugins = []
dir_path = os.path.join('cafe', 'plugins')