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

Method write

tools/python-3.11.9-amd64/Lib/lzma.py:224–243  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

closeMethod · 0.45

Calls 2

_check_can_writeMethod · 0.80
compressMethod · 0.80

Tested by

no test coverage detected