(value)
| 94 | |
| 95 | |
| 96 | def _should_contain_zip_content(value): |
| 97 | if not isinstance(value, bytes): |
| 98 | # If it's not bytes it's basically impossible for |
| 99 | # this to be valid zip content, but we'll at least |
| 100 | # still try to load the contents as a zip file |
| 101 | # to be absolutely sure. |
| 102 | value = value.encode('utf-8') |
| 103 | fileobj = BytesIO(value) |
| 104 | try: |
| 105 | with closing(zipfile.ZipFile(fileobj)) as f: |
| 106 | f.infolist() |
| 107 | except zipfile.BadZipFile: |
| 108 | raise ParamValidationError(ERROR_MSG) |
| 109 | |
| 110 | |
| 111 | class ZipFileArgument(CustomArgument): |
no test coverage detected