MCPcopy Index your code
hub / github.com/python/cpython / _writecheck

Method _writecheck

Lib/zipfile/__init__.py:1933–1954  ·  view source on GitHub ↗

Check for errors before writing a file to the archive.

(self, zinfo)

Source from the content-addressed store, hash-verified

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

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