Check for errors before writing a file to the archive.
(self, zinfo)
| 1931 | return targetpath |
| 1932 | |
| 1933 | def _writecheck(self, zinfo): |
| 1934 | """Check for errors before writing a file to the archive.""" |
| 1935 | if zinfo.filename in self.NameToInfo: |
| 1936 | import warnings |
| 1937 | warnings.warn('Duplicate name: %r' % zinfo.filename, stacklevel=3) |
| 1938 | if self.mode not in ('w', 'x', 'a'): |
| 1939 | raise ValueError("write() requires mode 'w', 'x', or 'a'") |
| 1940 | if not self.fp: |
| 1941 | raise ValueError( |
| 1942 | "Attempt to write ZIP archive that was already closed") |
| 1943 | _check_compression(zinfo.compress_type) |
| 1944 | if not self._allowZip64: |
| 1945 | requires_zip64 = None |
| 1946 | if len(self.filelist) >= ZIP_FILECOUNT_LIMIT: |
| 1947 | requires_zip64 = "Files count" |
| 1948 | elif zinfo.file_size > ZIP64_LIMIT: |
| 1949 | requires_zip64 = "Filesize" |
| 1950 | elif zinfo.header_offset > ZIP64_LIMIT: |
| 1951 | requires_zip64 = "Zipfile size" |
| 1952 | if requires_zip64: |
| 1953 | raise LargeZipFile(requires_zip64 + |
| 1954 | " would require ZIP64 extensions") |
| 1955 | |
| 1956 | def write(self, filename, arcname=None, |
| 1957 | compress_type=None, compresslevel=None): |
no test coverage detected