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

Function get_hasher_instance_by_name

src/commoncode/hash.py:201–210  ·  view source on GitHub ↗

Return a hasher instance for a checksum algorithm ``name`` with a planned ``total_length`` of bytes to hash.

(name, total_length=0)

Source from the content-addressed store, hash-verified

199
200
201def get_hasher_instance_by_name(name, total_length=0):
202 """
203 Return a hasher instance for a checksum algorithm ``name`` with a planned ``total_length`` of
204 bytes to hash.
205 """
206 try:
207 hm = _hashmodules_by_name[name]
208 return hm(total_length=total_length)
209 except KeyError:
210 raise ValueError(f"Unknown checksum algorithm: {name!r}")
211
212
213def get_file_size(location):

Callers 2

checksum_from_chunksFunction · 0.85
multi_checksumsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected