files.py 文件源码

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

项目:argschema 作者: AllenInstitute 项目源码 文件源码
def validate_outpath(path):
    try:
        with tempfile.NamedTemporaryFile(mode='w', dir=path) as tfile:
            tfile.write('0')
            tfile.close()

    except Exception as e:
        if isinstance(e, OSError):
            if e.errno == errno.ENOENT:
                raise mm.ValidationError(
                    "%s is not in a directory that exists" % path)
            elif e.errno == errno.EACCES:
                raise mm.ValidationError(
                    "%s does not appear you can write to path" % path)
            else:
                raise mm.ValidationError(
                    "Unknown OSError: {}".format(e.message))
        else:
            raise mm.ValidationError(
                "Unknown Exception: {}".format(e.message))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号