Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/arch/loader.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 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 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 | ||||
from distutils.version import LooseVersion | from distutils.version import LooseVersion | ||||
from pathlib import Path | from pathlib import Path | ||||
import re | import re | ||||
from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple | from typing import Any, Dict, Iterator, Optional, Sequence, Tuple | ||||
import attr | import attr | ||||
from swh.loader.package.loader import BasePackageInfo, PackageLoader | from swh.loader.package.loader import BasePackageInfo, PackageLoader | ||||
from swh.loader.package.utils import release_name | from swh.loader.package.utils import release_name | ||||
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 | ||||
Show All 34 Lines | |||||
class ArchLoader(PackageLoader[ArchPackageInfo]): | class ArchLoader(PackageLoader[ArchPackageInfo]): | ||||
visit_type = "arch" | visit_type = "arch" | ||||
def __init__( | def __init__( | ||||
self, | self, | ||||
storage: StorageInterface, | storage: StorageInterface, | ||||
url: str, | url: str, | ||||
artifacts: List[Dict[str, Any]], | artifacts: Dict[str, Dict[str, Any]], | ||||
arch_metadata: List[Dict[str, Any]], | arch_metadata: Dict[str, Dict[str, Any]], | ||||
**kwargs, | **kwargs, | ||||
): | ): | ||||
super().__init__(storage=storage, url=url, **kwargs) | super().__init__(storage=storage, url=url, **kwargs) | ||||
self.url = url | self.url = url | ||||
self.artifacts: Dict[str, Dict] = { | self.artifacts = artifacts | ||||
artifact["version"]: artifact for artifact in artifacts | self.arch_metadata = arch_metadata | ||||
} | |||||
self.arch_metadata: Dict[str, Dict] = { | |||||
metadata["version"]: metadata for metadata in arch_metadata | |||||
} | |||||
def get_versions(self) -> Sequence[str]: | def get_versions(self) -> Sequence[str]: | ||||
"""Get all released versions of an Arch Linux package | """Get all released versions of an Arch Linux package | ||||
Returns: | Returns: | ||||
A sequence of versions | A sequence of versions | ||||
Example:: | Example:: | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |