config.py 文件源码

python
阅读 78 收藏 0 点赞 0 评论 0

项目:webmon 作者: KarolBedkowski 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号