cli.py 文件源码

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

项目:pentagon 作者: reactiveops 项目源码 文件源码
def parse_infile(file):
    """ Parse data structure from file into dictionary for component use """
    with open(file, 'r') as data_file:
        try:
            data = json.load(data_file)
            logging.debug("Data parsed from file {}: {}".format(file, data))
            return data
        except ValueError as json_error:
            pass

        data_file.seek(0)

        try:
            data = yaml.load(data_file)
            logging.debug("Data parsed from file {}: {}".format(file, data))
            return data
        except yaml.YAMLError as yaml_error:
            pass

    logging.error("Unable to parse in file. {} {} ".format(json_error, yaml_error))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号