Fix lint.
This commit is contained in:
parent
0e8b42a9d8
commit
1425d306bc
@ -400,7 +400,7 @@ class ConfigManager(QObject):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
cp: The configparser instance to read the values from.
|
cp: The configparser instance to read the values from.
|
||||||
relaxed: Whether to ignore inexistent sections/optons
|
relaxed: Whether to ignore inexistent sections/options.
|
||||||
"""
|
"""
|
||||||
for sectname in cp:
|
for sectname in cp:
|
||||||
if sectname in self.RENAMED_SECTIONS:
|
if sectname in self.RENAMED_SECTIONS:
|
||||||
@ -409,23 +409,33 @@ class ConfigManager(QObject):
|
|||||||
if not relaxed:
|
if not relaxed:
|
||||||
raise configexc.NoSectionError(sectname)
|
raise configexc.NoSectionError(sectname)
|
||||||
for sectname in self.sections:
|
for sectname in self.sections:
|
||||||
real_sectname = self._get_real_sectname(cp, sectname)
|
self._from_cp_section(sectname, cp, relaxed)
|
||||||
if real_sectname is None:
|
|
||||||
continue
|
def _from_cp_section(self, sectname, cp, relaxed):
|
||||||
for k, v in cp[real_sectname].items():
|
"""Read a single section from a configparser instance.
|
||||||
if k.startswith(self.ESCAPE_CHAR):
|
|
||||||
k = k[1:]
|
Args:
|
||||||
if (sectname, k) in self.DELETED_OPTIONS:
|
sectname: The name of the section to read.
|
||||||
continue
|
cp: The configparser instance to read the values from.
|
||||||
elif (sectname, k) in self.RENAMED_OPTIONS:
|
relaxed: Whether to ignore inexistent options.
|
||||||
k = self.RENAMED_OPTIONS[sectname, k]
|
"""
|
||||||
try:
|
real_sectname = self._get_real_sectname(cp, sectname)
|
||||||
self.set('conf', sectname, k, v, validate=False)
|
if real_sectname is None:
|
||||||
except configexc.NoOptionError:
|
return
|
||||||
if relaxed:
|
for k, v in cp[real_sectname].items():
|
||||||
pass
|
if k.startswith(self.ESCAPE_CHAR):
|
||||||
else:
|
k = k[1:]
|
||||||
raise
|
if (sectname, k) in self.DELETED_OPTIONS:
|
||||||
|
return
|
||||||
|
elif (sectname, k) in self.RENAMED_OPTIONS:
|
||||||
|
k = self.RENAMED_OPTIONS[sectname, k]
|
||||||
|
try:
|
||||||
|
self.set('conf', sectname, k, v, validate=False)
|
||||||
|
except configexc.NoOptionError:
|
||||||
|
if relaxed:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
def _validate_all(self):
|
def _validate_all(self):
|
||||||
"""Validate all values set in self._from_cp."""
|
"""Validate all values set in self._from_cp."""
|
||||||
|
@ -149,14 +149,14 @@ class ConfigParserTests(unittest.TestCase):
|
|||||||
self.cp.read_dict({'foo': {'bar': 'baz'}})
|
self.cp.read_dict({'foo': {'bar': 'baz'}})
|
||||||
self.cfg._from_cp(self.cp, relaxed=True)
|
self.cfg._from_cp(self.cp, relaxed=True)
|
||||||
with self.assertRaises(configexc.NoSectionError):
|
with self.assertRaises(configexc.NoSectionError):
|
||||||
self.cfg.get('foo', 'bar')
|
self.cfg.get('foo', 'bar') # pylint: disable=bad-config-call
|
||||||
|
|
||||||
def test_invalid_option_relaxed(self):
|
def test_invalid_option_relaxed(self):
|
||||||
"""Test an invalid option with relaxed=True."""
|
"""Test an invalid option with relaxed=True."""
|
||||||
self.cp.read_dict({'general': {'bar': 'baz'}})
|
self.cp.read_dict({'general': {'bar': 'baz'}})
|
||||||
self.cfg._from_cp(self.cp, relaxed=True)
|
self.cfg._from_cp(self.cp, relaxed=True)
|
||||||
with self.assertRaises(configexc.NoOptionError):
|
with self.assertRaises(configexc.NoOptionError):
|
||||||
self.cfg.get('general', 'bar')
|
self.cfg.get('general', 'bar') # pylint: disable=bad-config-call
|
||||||
|
|
||||||
|
|
||||||
class DefaultConfigTests(unittest.TestCase):
|
class DefaultConfigTests(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user