MCPcopy Index your code
hub / github.com/python/cpython / _read1

Method _read1

Lib/zipfile/__init__.py:1154–1188  ·  view source on GitHub ↗
(self, n)

Source from the content-addressed store, hash-verified

1152 return buf
1153
1154 def _read1(self, n):
1155 # Read up to n compressed bytes with at most one read() system call,
1156 # decrypt and decompress them.
1157 if self._eof or n <= 0:
1158 return b''
1159
1160 # Read from file.
1161 if self._compress_type == ZIP_DEFLATED:
1162 ## Handle unconsumed data.
1163 data = self._decompressor.unconsumed_tail
1164 if n > len(data):
1165 data += self._read2(n - len(data))
1166 else:
1167 data = self._read2(n)
1168
1169 if self._compress_type == ZIP_STORED:
1170 self._eof = self._compress_left <= 0
1171 elif self._compress_type == ZIP_DEFLATED:
1172 n = max(n, self.MIN_READ_SIZE)
1173 data = self._decompressor.decompress(data, n)
1174 self._eof = (self._decompressor.eof or
1175 self._compress_left <= 0 and
1176 not self._decompressor.unconsumed_tail)
1177 if self._eof:
1178 data += self._decompressor.flush()
1179 else:
1180 data = self._decompressor.decompress(data)
1181 self._eof = self._decompressor.eof or self._compress_left <= 0
1182
1183 data = data[:self._left]
1184 self._left -= len(data)
1185 if self._left <= 0:
1186 self._eof = True
1187 self._update_crc(data)
1188 return data
1189
1190 def _read2(self, n):
1191 if self._compress_left <= 0:

Callers 2

readMethod · 0.95
read1Method · 0.95

Calls 4

_read2Method · 0.95
_update_crcMethod · 0.95
decompressMethod · 0.80
flushMethod · 0.45

Tested by

no test coverage detected