Lines Matching refs:data
102 else: # Assume data was read since the last prepend() call
272 def write(self,data):
281 if isinstance(data, (bytes, bytearray)):
282 length = len(data)
284 # accept any data that supports the buffer protocol
285 data = memoryview(data)
286 length = data.nbytes
289 self.fileobj.write(self.compress.compress(data))
291 self.crc = zlib.crc32(data, self.crc)
306 Reads up to a buffer's worth of data if size is negative."""
408 data = fp.read(n)
409 while len(data) < n:
410 b = fp.read(n - len(data))
414 data += b
415 return data
481 # For certain input data, a single
483 # any data. In this case, retry until we get some data or reach EOF.
504 # Read a chunk of data from the file
525 def _add_read_data(self, data):
526 self._crc = zlib.crc32(data, self._crc)
527 self._stream_size = self._stream_size + len(data)
532 # uncompressed data matches the stored values. Note that the size
539 raise BadGzipFile("Incorrect length of data produced")
576 def compress(data, compresslevel=_COMPRESS_LEVEL_BEST, *, mtime=None):
577 """Compress data in one shot and return the compressed string.
586 return zlib.compress(data, level=compresslevel, wbits=31)
588 trailer = struct.pack("<LL", zlib.crc32(data), (len(data) & 0xffffffff))
590 return (header + zlib.compress(data, level=compresslevel, wbits=-15) +
594 def decompress(data):
600 fp = io.BytesIO(data)
605 # Read all the data except the header
606 decompressed = do.decompress(data[fp.tell():])
614 raise BadGzipFile("Incorrect length of data produced")
616 data = do.unused_data[8:].lstrip(b"\x00")