Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/package/loader.py
Show All 26 Lines | from swh.model.model import ( | ||||
TargetType, | TargetType, | ||||
Snapshot, | Snapshot, | ||||
Origin, | Origin, | ||||
OriginVisit, | OriginVisit, | ||||
OriginVisitStatus, | OriginVisitStatus, | ||||
) | ) | ||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
from swh.storage.utils import now | from swh.storage.utils import now | ||||
from swh.storage.algos.snapshot import snapshot_get_all_branches | from swh.storage.algos.snapshot import snapshot_get_latest | ||||
from swh.loader.package.utils import download | from swh.loader.package.utils import download | ||||
logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||
class PackageLoader: | class PackageLoader: | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | def get_default_version(self) -> str: | ||||
Returns: | Returns: | ||||
Latest version | Latest version | ||||
""" | """ | ||||
return "" | return "" | ||||
def last_snapshot(self) -> Optional[Snapshot]: | def last_snapshot(self) -> Optional[Snapshot]: | ||||
"""Retrieve the last snapshot | """Retrieve the last snapshot out of the last visit. | ||||
""" | """ | ||||
snapshot = None | return snapshot_get_latest(self.storage, self.url) | ||||
visit = self.storage.origin_visit_get_latest(self.url, require_snapshot=True) | |||||
snapshot_id = None if not visit else visit.get("snapshot") | |||||
if snapshot_id is not None: | |||||
snapshot_dict = snapshot_get_all_branches(self.storage, snapshot_id) | |||||
if snapshot_dict: | |||||
snapshot = Snapshot.from_dict(snapshot_dict) | |||||
return snapshot | |||||
def known_artifacts(self, snapshot: Optional[Snapshot]) -> Dict[Sha1Git, BaseModel]: | def known_artifacts(self, snapshot: Optional[Snapshot]) -> Dict[Sha1Git, BaseModel]: | ||||
"""Retrieve the known releases/artifact for the origin. | """Retrieve the known releases/artifact for the origin. | ||||
Args | Args | ||||
snapshot: snapshot for the visit | snapshot: snapshot for the visit | ||||
Returns: | Returns: | ||||
▲ Show 20 Lines • Show All 367 Lines • Show Last 20 Lines |