validatexml.py 文件源码

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

项目:Program 作者: Riverscapes 项目源码 文件源码
def paths(self):
        s3 = boto3.client('s3')

        pathattrib = [a.attrib['path'].strip() for a in self.dom.getroottree().iterfind('//*[@path]')]
        pathnodes = [a.text.strip() for a in self.dom.getroottree().iterfind('//Path')]
        errors = []
        for p in pathattrib+pathnodes:
            if re.match('^([A-Za-z]:|/)', p):
                errors.append("Invalid absolute path detected: '{}'".format(p))
            else:
                # Now make sure the files really exist
                filekey = os.path.join(self.projroot, p.replace("\\","/"))
                try:
                    s3.head_object(Bucket=self.bucket, Key=filekey)
                except ClientError, e:
                    errors.append("File not found on repository: {}".format(filekey))

        if len(errors) > 0:
            self.validators.append(ValidatorResult("Path Checking", "FAIL", errors))
        else:
            self.validators.append(ValidatorResult("Path Checking", "PASS"))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号