Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/identifiers.py
# Copyright (C) 2020-2021 The Software Heritage developers | # Copyright (C) 2020-2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Any, Dict, Iterable, List, Optional | from typing import Any, Dict, Iterable, List, Mapping, Optional | ||||
from urllib.parse import quote, unquote | from urllib.parse import quote, unquote | ||||
from typing_extensions import TypedDict | from typing_extensions import TypedDict | ||||
from django.http import QueryDict | from django.http import QueryDict | ||||
from swh.model.exceptions import ValidationError | from swh.model.exceptions import ValidationError | ||||
from swh.model.hashutil import hash_to_bytes, hash_to_hex | from swh.model.hashutil import hash_to_bytes, hash_to_hex | ||||
▲ Show 20 Lines • Show All 254 Lines • ▼ Show 20 Lines | for obj_swhid in swhids: | ||||
swhids_by_type[obj_type].append(hash_to_bytes(obj_id)) | swhids_by_type[obj_type].append(hash_to_bytes(obj_id)) | ||||
return swhids_by_type | return swhids_by_type | ||||
def get_swhids_info( | def get_swhids_info( | ||||
swh_objects: Iterable[SWHObjectInfo], | swh_objects: Iterable[SWHObjectInfo], | ||||
snapshot_context: Optional[SnapshotContext] = None, | snapshot_context: Optional[SnapshotContext] = None, | ||||
extra_context: Optional[Dict[str, Any]] = None, | extra_context: Optional[Mapping[str, Any]] = None, | ||||
) -> List[SWHIDInfo]: | ) -> List[SWHIDInfo]: | ||||
""" | """ | ||||
Returns a list of dict containing info related to SWHIDs of objects. | Returns a list of dict containing info related to SWHIDs of objects. | ||||
Args: | Args: | ||||
swh_objects: an iterable of dict describing archived objects | swh_objects: an iterable of dict describing archived objects | ||||
snapshot_context: optional dict parameter describing the snapshot in | snapshot_context: optional dict parameter describing the snapshot in | ||||
which the objects have been found | which the objects have been found | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |