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; -*-
|
# -*- mode: conf; -*-
|
||||||
|
|
||||||
[MESSAGES CONTROL]
|
[MESSAGES CONTROL]
|
||||||
disable=
|
disable=fixme
|
||||||
fixme,
|
|
||||||
too-many-branches,
|
|
||||||
|
|
|
@ -884,28 +884,7 @@ def get_config_paths( # pylint: disable=too-many-arguments,too-many-positional-
|
||||||
|
|
||||||
# first identify any "primary" config files
|
# first identify any "primary" config files
|
||||||
if files is None:
|
if files is None:
|
||||||
if not env_files_name:
|
files = _get_primary_config_files(appname, env, env_files_name, default_files)
|
||||||
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)
|
|
||||||
|
|
||||||
elif isinstance(files, str):
|
elif isinstance(files, str):
|
||||||
files = [files]
|
files = [files]
|
||||||
else:
|
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
|
# which config file as part of the actual service definition in
|
||||||
# windows, so the service name is used for magic lookup here.
|
# windows, so the service name is used for magic lookup here.
|
||||||
if winsvc:
|
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 = configparser.ConfigParser()
|
||||||
config.read(files)
|
config.read(files)
|
||||||
section = f"{appname}.config"
|
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):
|
if config.has_option(section, option):
|
||||||
# replace file paths with whatever config value says
|
# replace file paths with whatever config value says
|
||||||
files = parse_list(config.get(section, option))
|
files = parse_list(config.get(section, option))
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue