Changeset View
Changeset View
Standalone View
Standalone View
swh/model/hashutil.py
Show First 20 Lines • Show All 283 Lines • ▼ Show 20 Lines | Args: | ||||
base_algo: the base hashing algorithm used (default: sha1) | base_algo: the base hashing algorithm used (default: sha1) | ||||
Returns: a dict mapping each algorithm to a bytes digest | Returns: a dict mapping each algorithm to a bytes digest | ||||
Raises: | Raises: | ||||
ValueError if the git_type is unexpected. | ValueError if the git_type is unexpected. | ||||
""" | """ | ||||
git_object_types = {"blob", "tree", "commit", "tag", "snapshot"} | git_object_types = { | ||||
"blob", | |||||
"tree", | |||||
"commit", | |||||
"tag", | |||||
"snapshot", | |||||
"raw_extrinsic_metadata", | |||||
} | |||||
if git_type not in git_object_types: | if git_type not in git_object_types: | ||||
raise ValueError( | raise ValueError( | ||||
"Unexpected git object type %s, expected one of %s" | "Unexpected git object type %s, expected one of %s" | ||||
% (git_type, ", ".join(sorted(git_object_types))) | % (git_type, ", ".join(sorted(git_object_types))) | ||||
) | ) | ||||
h = _new_git_hash(base_algo, git_type, len(data)) | h = _new_git_hash(base_algo, git_type, len(data)) | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |