forms.py 文件源码

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

项目:ava-website 作者: ava-project 项目源码 文件源码
def get_manifest(self, archive):
        try:
            with ZipFile(archive.temporary_file_path()) as plugin:
                print(plugin.namelist())
                prefix = self.get_prefix(plugin)
                prefix = prefix + '/' if len(prefix) else ''
                with plugin.open('{}manifest.json'.format(prefix)) as myfile:
                    manifest = json.loads(myfile.read())
                validate_manifest(manifest)
                return manifest
        except BadZipFile:
            raise ValidationError('Bad .zip format')
        except FileNotFoundError:
            raise ValidationError('Error with upload, please try again')
        except KeyError:
            raise ValidationError('No manifest.json found in archive')
        except json.JSONDecodeError:
            raise ValidationError('Error with manifest.json, bad Json Format')
        except avasdk.exceptions.ValidationError as e:
            raise ValidationError('Error in manifest.json ({})'.format(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号