Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/algos/origin.py
# Copyright (C) 2019-2020 The Software Heritage developers | # Copyright (C) 2019-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 | ||||
from typing import Optional, Iterable, Iterator, Tuple | from typing import Iterator, List, Optional, Tuple | ||||
from swh.model.model import Origin, OriginVisit, OriginVisitStatus | from swh.model.model import Origin, OriginVisit, OriginVisitStatus | ||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
def iter_origins( | def iter_origins( | ||||
storage: StorageInterface, | storage: StorageInterface, | ||||
origin_from: int = 1, | origin_from: int = 1, | ||||
Show All 30 Lines | while True: | ||||
if origin_to and start > origin_to: | if origin_to and start > origin_to: | ||||
break | break | ||||
def origin_get_latest_visit_status( | def origin_get_latest_visit_status( | ||||
storage: StorageInterface, | storage: StorageInterface, | ||||
origin_url: str, | origin_url: str, | ||||
type: Optional[str] = None, | type: Optional[str] = None, | ||||
allowed_statuses: Optional[Iterable[str]] = None, | allowed_statuses: Optional[List[str]] = None, | ||||
require_snapshot: bool = False, | require_snapshot: bool = False, | ||||
) -> Optional[Tuple[OriginVisit, OriginVisitStatus]]: | ) -> Optional[Tuple[OriginVisit, OriginVisitStatus]]: | ||||
"""Get the latest origin visit (and status) of an origin. Optionally, a combination of | """Get the latest origin visit (and status) of an origin. Optionally, a combination of | ||||
criteria can be provided, origin type, allowed statuses or if a visit has a | criteria can be provided, origin type, allowed statuses or if a visit has a | ||||
snapshot. | snapshot. | ||||
If no visit matching the criteria is found, returns None. Otherwise, returns a tuple | If no visit matching the criteria is found, returns None. Otherwise, returns a tuple | ||||
of origin visit, origin visit status. | of origin visit, origin visit status. | ||||
Show All 35 Lines |