languages.py 文件源码

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

项目:SuperOcto 作者: mcecchi 项目源码 文件源码
def uploadLanguagePack():
    input_name = "file"
    input_upload_path = input_name + "." + settings().get(["server", "uploads", "pathSuffix"])
    input_upload_name = input_name + "." + settings().get(["server", "uploads", "nameSuffix"])
    if not input_upload_path in request.values or not input_upload_name in request.values:
        return make_response("No file included", 400)

    upload_name = request.values[input_upload_name]
    upload_path = request.values[input_upload_path]

    exts = filter(lambda x: upload_name.lower().endswith(x), (".zip", ".tar.gz", ".tgz", ".tar"))
    if not len(exts):
        return make_response("File doesn't have a valid extension for a language pack archive", 400)

    target_path = settings().getBaseFolder("translations")

    if tarfile.is_tarfile(upload_path):
        _unpack_uploaded_tarball(upload_path, target_path)
    elif zipfile.is_zipfile(upload_path):
        _unpack_uploaded_zipfile(upload_path, target_path)
    else:
        return make_response("Neither zip file nor tarball included", 400)

    return getInstalledLanguagePacks()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号