Changeset View
Changeset View
Standalone View
Standalone View
swh/web/common/archive.py
# Copyright (C) 2015-2021 The Software Heritage developers | # Copyright (C) 2015-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 Affero General Public License version 3, or any later version | # License: GNU Affero 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 collections import defaultdict | from collections import defaultdict | ||||
import itertools | import itertools | ||||
import os | import os | ||||
import re | import re | ||||
from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Union | from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Union | ||||
from urllib.parse import urlparse | from urllib.parse import urlparse | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
from swh.model.identifiers import ObjectType, CoreSWHID | from swh.model.identifiers import CoreSWHID, ObjectType | ||||
from swh.model.model import OriginVisit, Revision | from swh.model.model import OriginVisit, Revision | ||||
from swh.storage.algos import diff, revisions_walker | from swh.storage.algos import diff, revisions_walker | ||||
from swh.storage.algos.origin import origin_get_latest_visit_status | from swh.storage.algos.origin import origin_get_latest_visit_status | ||||
from swh.storage.algos.snapshot import snapshot_get_latest, snapshot_resolve_alias | from swh.storage.algos.snapshot import snapshot_get_latest, snapshot_resolve_alias | ||||
from swh.vault.exc import NotFoundExc as VaultNotFoundExc | from swh.vault.exc import NotFoundExc as VaultNotFoundExc | ||||
from swh.web import config | from swh.web import config | ||||
from swh.web.common import converters, query | from swh.web.common import converters, query | ||||
from swh.web.common.exc import NotFoundExc | from swh.web.common.exc import NotFoundExc | ||||
▲ Show 20 Lines • Show All 295 Lines • ▼ Show 20 Lines | ) -> Tuple[List[OriginInfo], Optional[str]]: | ||||
Returns: | Returns: | ||||
list of origin information as dict. | list of origin information as dict. | ||||
""" | """ | ||||
if page_token: | if page_token: | ||||
assert isinstance(page_token, str) | assert isinstance(page_token, str) | ||||
if search: | if search: | ||||
if config.get_config()["search_config"].get("enable_ql") and use_ql: | if use_ql: | ||||
page_result = search.origin_search( | page_result = search.origin_search( | ||||
query=url_pattern, | query=url_pattern, | ||||
page_token=page_token, | page_token=page_token, | ||||
with_visit=with_visit, | with_visit=with_visit, | ||||
visit_types=visit_types, | visit_types=visit_types, | ||||
limit=limit, | limit=limit, | ||||
) | ) | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 1,071 Lines • Show Last 20 Lines |