Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/debian/loader.py
Show All 19 Lines | |||||
from swh.model.hashutil import hash_to_bytes | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.model import ObjectType, Person, Release, Sha1Git, TimestampWithTimezone | from swh.model.model import ObjectType, Person, Release, Sha1Git, TimestampWithTimezone | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
UPLOADERS_SPLIT = re.compile(r"(?<=\>)\s*,\s*") | UPLOADERS_SPLIT = re.compile(r"(?<=\>)\s*,\s*") | ||||
EXTID_TYPE = "dsc-sha256" | EXTID_TYPE = "dsc-sha256" | ||||
EXTID_VERSION = 1 | |||||
class DscCountError(ValueError): | class DscCountError(ValueError): | ||||
"""Raised when an unexpected number of .dsc files is seen""" | """Raised when an unexpected number of .dsc files is seen""" | ||||
pass | pass | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | def extid(self) -> Optional[PartialExtID]: | ||||
] | ] | ||||
if len(dsc_files) != 1: | if len(dsc_files) != 1: | ||||
raise DscCountError( | raise DscCountError( | ||||
f"Expected exactly one .dsc file for package {self.name}, " | f"Expected exactly one .dsc file for package {self.name}, " | ||||
f"got {len(dsc_files)}" | f"got {len(dsc_files)}" | ||||
) | ) | ||||
return (EXTID_TYPE, hash_to_bytes(dsc_files[0].sha256)) | return (EXTID_TYPE, EXTID_VERSION, hash_to_bytes(dsc_files[0].sha256)) | ||||
@attr.s | @attr.s | ||||
class IntrinsicPackageMetadata: | class IntrinsicPackageMetadata: | ||||
"""Metadata extracted from a package's .dsc file.""" | """Metadata extracted from a package's .dsc file.""" | ||||
name = attr.ib(type=str) | name = attr.ib(type=str) | ||||
version = attr.ib(type=str) | version = attr.ib(type=str) | ||||
▲ Show 20 Lines • Show All 356 Lines • Show Last 20 Lines |