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

Method write

Lib/zipfile/__init__.py:1318–1335  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

1316 return True
1317
1318 def write(self, data):
1319 if self.closed:
1320 raise ValueError('I/O operation on closed file.')
1321
1322 # Accept any data that supports the buffer protocol
1323 if isinstance(data, (bytes, bytearray)):
1324 nbytes = len(data)
1325 else:
1326 data = memoryview(data)
1327 nbytes = data.nbytes
1328 self._file_size += nbytes
1329
1330 self._crc = crc32(data, self._crc)
1331 if self._compressor:
1332 data = self._compressor.compress(data)
1333 self._compress_size += len(data)
1334 self._fileobj.write(data)
1335 return nbytes
1336
1337 def close(self):
1338 if self.closed:

Callers

nothing calls this directly

Calls 3

crc32Function · 0.85
compressMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected