database_handler.py 文件源码

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

项目:audio-feeder 作者: pganssle 项目源码 文件源码
def save_table(table_loc, table):
    """
    Saves a table of type ``table_type`` to a YAML file ``table_loc``
    """
    table_list = [obj.to_dict_sparse() for obj_id, obj in table.items()]
    table_obj = {
        'db_version': DB_VERSION,
        'data': table_list
    }

    if os.path.exists(table_loc):
        # Cache a backup of this
        shutil.copy2(table_loc, _get_bak_loc(table_loc))

    with open(table_loc, 'w') as yf:
        yaml.dump(table_obj, stream=yf, default_flow_style=False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号