def load_inputs(filename: str) -> list:
"""Load inputs configuration from `filename`."""
if not filename:
filename = _find_config_file("inputs.yaml")
_LOG.debug("loading inputs from %s", filename)
if not os.path.isfile(filename):
_LOG.error("loading inputs file error: '%s' not found", filename)
return None
try:
with open(filename) as fin:
inps = [doc for doc in yaml.load_all(fin)
if doc and doc.get("enable", True)]
_LOG.debug("loading inputs - found %d enabled inputs",
len(inps))
if not inps:
_LOG.error("loading inputs error: no valid/enabled "
"inputs found")
return inps
except IOError as err:
_LOG.error("loading inputs from file %s error: %s", filename,
err)
except yaml.error.YAMLError as err:
_LOG.error("loading inputs from file %s - invalid YAML: %s",
filename, err)
return None
评论列表
文章目录