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