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

Method _read1

tools/python-3.11.9-amd64/Lib/zipfile.py:1022–1056  ·  view source on GitHub ↗
(self, n)

Source from the content-addressed store, hash-verified

1020 return buf
1021
1022 def _read1(self, n):
1023 # Read up to n compressed bytes with at most one read() system call,
1024 # decrypt and decompress them.
1025 if self._eof or n <= 0:
1026 return b''
1027
1028 # Read from file.
1029 if self._compress_type == ZIP_DEFLATED:
1030 ## Handle unconsumed data.
1031 data = self._decompressor.unconsumed_tail
1032 if n > len(data):
1033 data += self._read2(n - len(data))
1034 else:
1035 data = self._read2(n)
1036
1037 if self._compress_type == ZIP_STORED:
1038 self._eof = self._compress_left <= 0
1039 elif self._compress_type == ZIP_DEFLATED:
1040 n = max(n, self.MIN_READ_SIZE)
1041 data = self._decompressor.decompress(data, n)
1042 self._eof = (self._decompressor.eof or
1043 self._compress_left <= 0 and
1044 not self._decompressor.unconsumed_tail)
1045 if self._eof:
1046 data += self._decompressor.flush()
1047 else:
1048 data = self._decompressor.decompress(data)
1049 self._eof = self._decompressor.eof or self._compress_left <= 0
1050
1051 data = data[:self._left]
1052 self._left -= len(data)
1053 if self._left <= 0:
1054 self._eof = True
1055 self._update_crc(data)
1056 return data
1057
1058 def _read2(self, n):
1059 if self._compress_left <= 0:

Callers 2

readMethod · 0.95
read1Method · 0.95

Calls 5

_read2Method · 0.95
_update_crcMethod · 0.95
maxFunction · 0.85
decompressMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected