MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _writecheck

Method _writecheck

tools/python-3.11.9-amd64/Lib/zipfile.py:1760–1781  ·  view source on GitHub ↗

Check for errors before writing a file to the archive.

(self, zinfo)

Source from the content-addressed store, hash-verified

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):

Callers 2

_open_to_writeMethod · 0.95
mkdirMethod · 0.95

Calls 3

_check_compressionFunction · 0.85
LargeZipFileClass · 0.85
warnMethod · 0.45

Tested by

no test coverage detected