fix: fix 'too-many-branches' for pylint
This commit is contained in:
parent
957c334d1d
commit
0688ed4dd1
2 changed files with 39 additions and 33 deletions
|
@ -1,6 +1,4 @@
|
|||
# -*- mode: conf; -*-
|
||||
|
||||
[MESSAGES CONTROL]
|
||||
disable=
|
||||
fixme,
|
||||
too-many-branches,
|
||||
disable=fixme
|
||||
|
|
|
@ -884,28 +884,7 @@ def get_config_paths( # pylint: disable=too-many-arguments,too-many-positional-
|
|||
|
||||
# first identify any "primary" config files
|
||||
if files is None:
|
||||
if not env_files_name:
|
||||
env_files_name = f"{appname.upper()}_CONFIG_FILES"
|
||||
|
||||
files = env.get(env_files_name)
|
||||
if files is not None:
|
||||
files = files.split(os.pathsep)
|
||||
|
||||
elif default_files:
|
||||
if callable(default_files):
|
||||
files = default_files(appname) or []
|
||||
elif isinstance(default_files, str):
|
||||
files = [default_files]
|
||||
else:
|
||||
files = list(default_files)
|
||||
files = [path for path in files if os.path.exists(path)]
|
||||
|
||||
else:
|
||||
files = []
|
||||
for path in generic_default_files(appname):
|
||||
if os.path.exists(path):
|
||||
files.append(path)
|
||||
|
||||
files = _get_primary_config_files(appname, env, env_files_name, default_files)
|
||||
elif isinstance(files, str):
|
||||
files = [files]
|
||||
else:
|
||||
|
@ -937,6 +916,36 @@ def get_config_paths( # pylint: disable=too-many-arguments,too-many-positional-
|
|||
# which config file as part of the actual service definition in
|
||||
# windows, so the service name is used for magic lookup here.
|
||||
if winsvc:
|
||||
files = _get_winsvc_config_files(appname, winsvc, files)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
def _get_primary_config_files(appname, env, env_files_name, default_files):
|
||||
if not env_files_name:
|
||||
env_files_name = f"{appname.upper()}_CONFIG_FILES"
|
||||
|
||||
files = env.get(env_files_name)
|
||||
if files is not None:
|
||||
return files.split(os.pathsep)
|
||||
|
||||
if default_files:
|
||||
if callable(default_files):
|
||||
files = default_files(appname) or []
|
||||
elif isinstance(default_files, str):
|
||||
files = [default_files]
|
||||
else:
|
||||
files = list(default_files)
|
||||
return [path for path in files if os.path.exists(path)]
|
||||
|
||||
files = []
|
||||
for path in generic_default_files(appname):
|
||||
if os.path.exists(path):
|
||||
files.append(path)
|
||||
return files
|
||||
|
||||
|
||||
def _get_winsvc_config_files(appname, winsvc, files):
|
||||
config = configparser.ConfigParser()
|
||||
config.read(files)
|
||||
section = f"{appname}.config"
|
||||
|
@ -945,7 +954,6 @@ def get_config_paths( # pylint: disable=too-many-arguments,too-many-positional-
|
|||
if config.has_option(section, option):
|
||||
# replace file paths with whatever config value says
|
||||
files = parse_list(config.get(section, option))
|
||||
|
||||
return files
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue