Changeset View
Changeset View
Standalone View
Standalone View
swh/scrubber/__init__.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 __future__ import annotations | from __future__ import annotations | ||||
| from typing import TYPE_CHECKING | from typing import TYPE_CHECKING | ||||
| if TYPE_CHECKING: | if TYPE_CHECKING: | ||||
| from .db import ScrubberDb | from .db import ScrubberDb | ||||
| def get_scrubber_db(cls: str, **kwargs) -> ScrubberDb: | def get_scrubber_db(cls: str, **kwargs) -> ScrubberDb: | ||||
| if cls != "local": | if cls not in ("local", "postgresql"): | ||||
| raise ValueError(f"Unknown scrubber db class '{cls}', use 'local' instead.") | raise ValueError( | ||||
| f"Unknown scrubber db class '{cls}', use 'postgresql' instead." | |||||
| ) | |||||
| from .db import ScrubberDb | from .db import ScrubberDb | ||||
| return ScrubberDb.connect(kwargs.pop("db"), **kwargs) | return ScrubberDb.connect(kwargs.pop("db"), **kwargs) | ||||
| get_datastore = get_scrubber_db | get_datastore = get_scrubber_db |