Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/__init__.py
from .archive import ArchiveInterface | from .archive import ArchiveInterface | ||||
from .postgresql.archive import ArchivePostgreSQL | from .postgresql.archive import ArchivePostgreSQL | ||||
from .postgresql.db_utils import connect | from .postgresql.db_utils import connect | ||||
from .postgresql.provenance import ProvenancePostgreSQL | |||||
from .postgresql_nopath.provenance import ProvenancePostgreSQLNoPath | |||||
from .provenance import ProvenanceInterface | |||||
from .storage.archive import ArchiveStorage | from .storage.archive import ArchiveStorage | ||||
from .provenance import ProvenanceInterface | |||||
def get_archive(cls: str, **kwargs) -> ArchiveInterface: | def get_archive(cls: str, **kwargs) -> ArchiveInterface: | ||||
if cls == "api": | if cls == "api": | ||||
return ArchiveStorage(**kwargs["storage"]) | return ArchiveStorage(**kwargs["storage"]) | ||||
elif cls == "direct": | elif cls == "direct": | ||||
conn = connect(kwargs["db"]) | conn = connect(kwargs["db"]) | ||||
return ArchivePostgreSQL(conn) | return ArchivePostgreSQL(conn) | ||||
else: | else: | ||||
raise NotImplementedError | raise NotImplementedError | ||||
def get_provenance(cls: str, **kwargs) -> ProvenanceInterface: | def get_provenance(cls: str, **kwargs) -> ProvenanceInterface: | ||||
if cls == "local": | if cls == "local": | ||||
conn = connect(kwargs["db"]) | conn = connect(kwargs["db"]) | ||||
if kwargs.get("with_path", False): | if kwargs.get("with_path", False): | ||||
return ProvenancePostgreSQL(conn) | from .postgresql.provenance_with_path import ProvenanceWithPathDB | ||||
return ProvenanceWithPathDB(conn) | |||||
else: | else: | ||||
return ProvenancePostgreSQLNoPath(conn) | from .postgresql.provenance_without_path import ProvenanceWithoutPathDB | ||||
return ProvenanceWithoutPathDB(conn) | |||||
else: | else: | ||||
raise NotImplementedError | raise NotImplementedError |