config.py 文件源码

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

项目:Auspex 作者: BBN-Q 项目源码 文件源码
def dump_meas_file(data, filename = "", flatten=False):
    d = Dumper if filename and not flatten else FlatDumper
    d.add_representer(Include, d.include)

    if filename:
        with open(filename+".tmp", 'w+') as fid:

            yaml.dump(data, fid, Dumper=d)
        # Upon success
        move(filename+".tmp", filename)
        with open(filename, 'r') as fid:
            contents = fid.read()
        return contents
    else:
        # dump to an IO stream:
        # note you need to use the FlatDumper for this to work
        out = StringIO()
        yaml.dump(data, out, Dumper=d)
        ret_string = out.getvalue()
        out.close()
        return ret_string
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号