files.py 文件源码

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

项目:argschema 作者: AllenInstitute 项目源码 文件源码
def _validate(self, value):
        if not os.path.isdir(value):
            try:
                os.makedirs(value)
                if self.mode is not None:
                    os.chmod(value, self.mode)
            except OSError as e:
                if e.errno == os.errno.EEXIST:
                    pass
                else:
                    raise mm.ValidationError(
                        "{} is not a directory and you cannot create it".format(
                            value)
                    )
        if self.mode is not None:
            try:
                assert((os.stat(value).st_mode & 0o777) == self.mode)
            except:
                raise mm.ValidationError(
                    "{} does not have the mode  ({}) that was specified ".format(
                        value, self.mode)
                )
        # use outputfile to test that a file in this location is a valid path
        validate_outpath(value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号