MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / binary_chunks

Function binary_chunks

src/commoncode/hash.py:246–256  ·  view source on GitHub ↗

Read file at ``location`` as binary and yield bytes of up to ``size`` length in bytes, defaulting to 2**24 bytes, e.g., about 16 MB.

(location, size=FILE_CHUNK_SIZE)

Source from the content-addressed store, hash-verified

244
245
246def binary_chunks(location, size=FILE_CHUNK_SIZE):
247 """
248 Read file at ``location`` as binary and yield bytes of up to ``size`` length in bytes,
249 defaulting to 2**24 bytes, e.g., about 16 MB.
250 """
251 with open(location, "rb") as f:
252 while True:
253 chunk = f.read(size)
254 if not chunk:
255 break
256 yield chunk
257
258
259def md5(location):

Callers 2

checksumFunction · 0.85
multi_checksumsFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected