Write a bytes object to the file. Returns the number of uncompressed bytes written, which is always the length of data in bytes. Note that due to buffering, the file on disk may not reflect the data written until close() is called.
(self, data)
| 230 | return self._buffer.readline(size) |
| 231 | |
| 232 | def write(self, data): |
| 233 | """Write a bytes object to the file. |
| 234 | |
| 235 | Returns the number of uncompressed bytes written, which is |
| 236 | always the length of data in bytes. Note that due to buffering, |
| 237 | the file on disk may not reflect the data written until close() |
| 238 | is called. |
| 239 | """ |
| 240 | self._check_can_write() |
| 241 | if isinstance(data, (bytes, bytearray)): |
| 242 | length = len(data) |
| 243 | else: |
| 244 | # accept any data that supports the buffer protocol |
| 245 | data = memoryview(data) |
| 246 | length = data.nbytes |
| 247 | |
| 248 | compressed = self._compressor.compress(data) |
| 249 | self._fp.write(compressed) |
| 250 | self._pos += length |
| 251 | return length |
| 252 | |
| 253 | def seek(self, offset, whence=io.SEEK_SET): |
| 254 | """Change the file position. |
no test coverage detected