Changeset View
Changeset View
Standalone View
Standalone View
swh/model/identifiers.py
Show First 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | ): | ||||||||||
headers.append((key.encode("ascii"), value)) | headers.append((key.encode("ascii"), value)) | ||||||||||
return identifier_to_str( | return identifier_to_str( | ||||||||||
hash_manifest("raw_extrinsic_metadata", headers, metadata["metadata"]) | hash_manifest("raw_extrinsic_metadata", headers, metadata["metadata"]) | ||||||||||
) | ) | ||||||||||
def extid_identifier(extid: Dict[str, Any]) -> str: | |||||||||||
"""Return the intrinsic identifier for an ExtID object. | |||||||||||
An ExtID identifier is a salted sha1 (using the git hashing algorithm with | |||||||||||
the ``extid`` object type) of a manifest following the format: | |||||||||||
``` | |||||||||||
extid_type $StrWithoutSpaces | |||||||||||
vlorentz: and should mention `$StrWithoutSpaces` is ASCII-encoded and something like this quote from the… | |||||||||||
extid $Bytes | |||||||||||
target $CoreSwhid | |||||||||||
``` | |||||||||||
$StrWithoutSpaces is an ASCII string, and may not contain spaces. | |||||||||||
Newlines in $Bytes are escaped as with other git fields, ie. by adding a | |||||||||||
space after them. | |||||||||||
Returns: | |||||||||||
Not Done Inline Actions
vlorentz: | |||||||||||
str: the intrinsic identifier for `extid` | |||||||||||
Not Done Inline Actions
probably vlorentz: probably | |||||||||||
""" | |||||||||||
headers = [ | |||||||||||
(b"extid_type", extid["extid_type"].encode("ascii")), | |||||||||||
(b"extid", extid["extid"]), | |||||||||||
(b"target", str(extid["target"]).encode("ascii")), | |||||||||||
] | |||||||||||
return identifier_to_str(hash_manifest("extid", headers)) | |||||||||||
# type of the "object_type" attribute of the SWHID class; either | # type of the "object_type" attribute of the SWHID class; either | ||||||||||
# ObjectType or ExtendedObjectType | # ObjectType or ExtendedObjectType | ||||||||||
_TObjectType = TypeVar("_TObjectType", ObjectType, ExtendedObjectType) | _TObjectType = TypeVar("_TObjectType", ObjectType, ExtendedObjectType) | ||||||||||
# the SWHID class itself (this is used so that X.from_string() can return X | # the SWHID class itself (this is used so that X.from_string() can return X | ||||||||||
# for all X subclass of _BaseSWHID) | # for all X subclass of _BaseSWHID) | ||||||||||
_TSWHID = TypeVar("_TSWHID", bound="_BaseSWHID") | _TSWHID = TypeVar("_TSWHID", bound="_BaseSWHID") | ||||||||||
▲ Show 20 Lines • Show All 377 Lines • Show Last 20 Lines |
and should mention $StrWithoutSpaces is ASCII-encoded and something like this quote from the raw-ext-meta: