___ankihub.py 文件源码

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

项目:AnkiHub 作者: dayjaby 项目源码 文件源码
def installZipFile(data, fname):
    base = os.path.join(defaultBase(),'addons')
    if fname.endswith(".py"):
        path = os.path.join(base, fname)
        open(path, "wb").write(data)
        return True
    # .zip file
    try:
        z = zipfile.ZipFile(io.BytesIO(data))
    except zipfile.BadZipfile:
        return False
    for n in z.namelist():
        if n.endswith("/"):
            # folder; ignore
            continue
        # write
        z.extract(n, base)
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号