Check for errors before writing a file to the archive.
(self, zinfo)
| 1758 | return targetpath |
| 1759 | |
| 1760 | def _writecheck(self, zinfo): |
| 1761 | """Check for errors before writing a file to the archive.""" |
| 1762 | if zinfo.filename in self.NameToInfo: |
| 1763 | import warnings |
| 1764 | warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3) |
| 1765 | if self.mode not in ('w', 'x', 'a'): |
| 1766 | raise ValueError("write() requires mode 'w', 'x', or 'a'") |
| 1767 | if not self.fp: |
| 1768 | raise ValueError( |
| 1769 | "Attempt to write ZIP archive that was already closed") |
| 1770 | _check_compression(zinfo.compress_type) |
| 1771 | if not self._allowZip64: |
| 1772 | requires_zip64 = None |
| 1773 | if len(self.filelist) >= ZIP_FILECOUNT_LIMIT: |
| 1774 | requires_zip64 = "Files count" |
| 1775 | elif zinfo.file_size > ZIP64_LIMIT: |
| 1776 | requires_zip64 = "Filesize" |
| 1777 | elif zinfo.header_offset > ZIP64_LIMIT: |
| 1778 | requires_zip64 = "Zipfile size" |
| 1779 | if requires_zip64: |
| 1780 | raise LargeZipFile(requires_zip64 + |
| 1781 | " would require ZIP64 extensions") |
| 1782 | |
| 1783 | def write(self, filename, arcname=None, |
| 1784 | compress_type=None, compresslevel=None): |
no test coverage detected