Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/debian/loader.py
# Copyright (C) 2017-2019 The Software Heritage developers | # Copyright (C) 2017-2021 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 email.utils | import email.utils | ||||
import logging | import logging | ||||
from os import path | from os import path | ||||
import re | import re | ||||
Show All 19 Lines | |||||
from swh.loader.package.utils import download, release_name | from swh.loader.package.utils import download, release_name | ||||
from swh.model.model import ( | from swh.model.model import ( | ||||
Person, | Person, | ||||
Revision, | Revision, | ||||
RevisionType, | RevisionType, | ||||
Sha1Git, | Sha1Git, | ||||
TimestampWithTimezone, | TimestampWithTimezone, | ||||
) | ) | ||||
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*") | ||||
@attr.s | @attr.s | ||||
class DebianFileMetadata: | class DebianFileMetadata: | ||||
md5sum = attr.ib(type=str) | md5sum = attr.ib(type=str) | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
class DebianLoader(PackageLoader[DebianPackageInfo]): | class DebianLoader(PackageLoader[DebianPackageInfo]): | ||||
"""Load debian origins into swh archive. | """Load debian origins into swh archive. | ||||
""" | """ | ||||
visit_type = "deb" | visit_type = "deb" | ||||
def __init__(self, url: str, date: str, packages: Mapping[str, Any]): | def __init__( | ||||
self, | |||||
storage: StorageInterface, | |||||
url: str, | |||||
date: str, | |||||
packages: Mapping[str, Any], | |||||
max_content_size: Optional[int] = None, | |||||
): | |||||
"""Debian Loader implementation. | """Debian Loader implementation. | ||||
Args: | Args: | ||||
url: Origin url (e.g. deb://Debian/packages/cicero) | url: Origin url (e.g. deb://Debian/packages/cicero) | ||||
date: Ignored | date: Ignored | ||||
packages: versioned packages and associated artifacts, example:: | packages: versioned packages and associated artifacts, example:: | ||||
{ | { | ||||
Show All 23 Lines | ): | ||||
'uri': 'http://d.d.o/cicero_0.7.2.orig.tar.gz', | 'uri': 'http://d.d.o/cicero_0.7.2.orig.tar.gz', | ||||
} | } | ||||
}, | }, | ||||
}, | }, | ||||
# ... | # ... | ||||
} | } | ||||
""" | """ | ||||
super().__init__(url=url) | super().__init__(storage=storage, url=url, max_content_size=max_content_size) | ||||
self.packages = packages | self.packages = packages | ||||
def get_versions(self) -> Sequence[str]: | def get_versions(self) -> Sequence[str]: | ||||
"""Returns the keys of the packages input (e.g. | """Returns the keys of the packages input (e.g. | ||||
stretch/contrib/0.7.2-3, etc...) | stretch/contrib/0.7.2-3, etc...) | ||||
""" | """ | ||||
return list(self.packages.keys()) | return list(self.packages.keys()) | ||||
▲ Show 20 Lines • Show All 331 Lines • Show Last 20 Lines |