runapp.py 文件源码

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

项目:chemworkflows 作者: avirshup 项目源码 文件源码
def process_input_file(inputfile):
    """ Figure out whether we're being passed a file, a description of a file, or just raw JSON
    """
    try:
        jsraw = _get_json(inputfile)
    except ValueError:
        pass
    else:
        print jsraw
        inputjson = json.loads(jsraw)
        return inputjson

    ext = inputfile.split('.')[-1]
    if ext in ('js', 'json', 'yml', 'yaml'):
        with open(inputfile, 'r') as infile:
            inputjson = yaml.load(infile)
    else:
        with open(inputfile, 'r') as infile:
            inputjson = {'filename': inputfile,
                         'content': infile.read()}
    return inputjson
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号