Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/converters.py
# Copyright (C) 2015 The Software Heritage developers | # Copyright (C) 2015-2020 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 General Public License version 3, or any later version | # License: GNU 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 | ||||
import datetime | import datetime | ||||
from typing import Optional, Dict | from typing import Any, Optional, Dict | ||||
from swh.core.utils import encode_with_unescape | from swh.core.utils import encode_with_unescape | ||||
from swh.model import identifiers | from swh.model import identifiers | ||||
from swh.model.identifiers import parse_swhid | from swh.model.identifiers import parse_swhid | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
MetadataAuthority, | MetadataAuthority, | ||||
MetadataAuthorityType, | MetadataAuthorityType, | ||||
MetadataFetcher, | MetadataFetcher, | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | return { | ||||
"extra_headers": revision["extra_headers"], | "extra_headers": revision["extra_headers"], | ||||
"parents": [ | "parents": [ | ||||
{"id": revision["id"], "parent_id": parent, "parent_rank": i,} | {"id": revision["id"], "parent_id": parent, "parent_rank": i,} | ||||
for i, parent in enumerate(revision["parents"]) | for i, parent in enumerate(revision["parents"]) | ||||
], | ], | ||||
} | } | ||||
def db_to_revision(db_revision): | def db_to_revision(db_revision: Dict[str, Any]) -> Dict[str, Any]: | ||||
"""Convert a database representation of a revision to its swh-model | """Convert a database representation of a revision to its swh-model | ||||
representation.""" | representation.""" | ||||
author = db_to_author( | author = db_to_author( | ||||
db_revision["author_fullname"], | db_revision["author_fullname"], | ||||
db_revision["author_name"], | db_revision["author_name"], | ||||
db_revision["author_email"], | db_revision["author_email"], | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 136 Lines • Show Last 20 Lines |