fix: fix 'too-many-locals' for pylint
This commit is contained in:
parent
8e67de4947
commit
d9db40fddc
2 changed files with 21 additions and 16 deletions
|
@ -5,4 +5,3 @@ disable=
|
|||
attribute-defined-outside-init,
|
||||
fixme,
|
||||
too-many-branches,
|
||||
too-many-locals,
|
||||
|
|
|
@ -275,20 +275,8 @@ class WuttaConfig: # pylint: disable=too-many-instance-attributes
|
|||
raise FileNotFoundError(f"could not read required config file: {path}")
|
||||
return
|
||||
|
||||
# load all values into (yet another) temp config
|
||||
temp_config = configparser.RawConfigParser()
|
||||
for section in config.sections():
|
||||
temp_config.add_section(section)
|
||||
# nb. must interpolate most values but *not* for logging formatters
|
||||
raw = section.startswith("formatter_")
|
||||
for option in config.options(section):
|
||||
temp_config.set(section, option, config.get(section, option, raw=raw))
|
||||
|
||||
# re-write as temp file with "final" values
|
||||
fd, temp_path = tempfile.mkstemp(suffix=".ini")
|
||||
os.close(fd)
|
||||
with open(temp_path, "wt", encoding="utf_8") as f:
|
||||
temp_config.write(f)
|
||||
# write config to temp file
|
||||
temp_path = self._write_temp_config_file(config)
|
||||
|
||||
# and finally, load that into our main config
|
||||
config = configuration.config_from_ini(temp_path, read_from_file=True)
|
||||
|
@ -308,6 +296,24 @@ class WuttaConfig: # pylint: disable=too-many-instance-attributes
|
|||
for p in self.parse_list(includes):
|
||||
self._load_ini_configs(p, configs, require=False)
|
||||
|
||||
def _write_temp_config_file(self, config):
|
||||
# load all values into (yet another) temp config
|
||||
temp_config = configparser.RawConfigParser()
|
||||
for section in config.sections():
|
||||
temp_config.add_section(section)
|
||||
# nb. must interpolate most values but *not* for logging formatters
|
||||
raw = section.startswith("formatter_")
|
||||
for option in config.options(section):
|
||||
temp_config.set(section, option, config.get(section, option, raw=raw))
|
||||
|
||||
# re-write as temp file with "final" values
|
||||
fd, temp_path = tempfile.mkstemp(suffix=".ini")
|
||||
os.close(fd)
|
||||
with open(temp_path, "wt", encoding="utf_8") as f:
|
||||
temp_config.write(f)
|
||||
|
||||
return temp_path
|
||||
|
||||
def get_prioritized_files(self):
|
||||
"""
|
||||
Returns list of config files in order of priority.
|
||||
|
@ -942,7 +948,7 @@ def get_config_paths( # pylint: disable=too-many-arguments,too-many-positional-
|
|||
return files
|
||||
|
||||
|
||||
def make_config( # pylint: disable=too-many-arguments,too-many-positional-arguments
|
||||
def make_config( # pylint: disable=too-many-arguments,too-many-positional-arguments,too-many-locals
|
||||
files=None,
|
||||
plus_files=None,
|
||||
appname="wutta",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue