Read all the files and check the CRC. Return None if all files could be read successfully, or the name of the offending file otherwise.
(self)
| 1624 | file=file) |
| 1625 | |
| 1626 | def testzip(self): |
| 1627 | """Read all the files and check the CRC. |
| 1628 | |
| 1629 | Return None if all files could be read successfully, or the name |
| 1630 | of the offending file otherwise.""" |
| 1631 | chunk_size = 2 ** 20 |
| 1632 | for zinfo in self.filelist: |
| 1633 | try: |
| 1634 | # Read by chunks, to avoid an OverflowError or a |
| 1635 | # MemoryError with very large embedded files. |
| 1636 | with self.open(zinfo.filename, "r") as f: |
| 1637 | while f.read(chunk_size): # Check CRC-32 |
| 1638 | pass |
| 1639 | except BadZipFile: |
| 1640 | return zinfo.filename |
| 1641 | |
| 1642 | def getinfo(self, name): |
| 1643 | """Return the instance of ZipInfo given 'name'.""" |