Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/__init__.py
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | elif cls == "mongodb": | ||||
from pymongo import MongoClient | from pymongo import MongoClient | ||||
from .mongo.backend import ProvenanceStorageMongoDb | from .mongo.backend import ProvenanceStorageMongoDb | ||||
dbname = kwargs["db"].pop("dbname") | dbname = kwargs["db"].pop("dbname") | ||||
db = MongoClient(**kwargs["db"]).get_database(dbname) | db = MongoClient(**kwargs["db"]).get_database(dbname) | ||||
return ProvenanceStorageMongoDb(db) | return ProvenanceStorageMongoDb(db) | ||||
elif cls == "remote": | elif cls in ["remote", "rpcapi"]: | ||||
from .api.client import RemoteProvenanceStorage | from .api.client import ProvenanceStorageRPCClient | ||||
storage = RemoteProvenanceStorage(**kwargs) | if cls == "remote": | ||||
assert isinstance(storage, ProvenanceStorageInterface) | warnings.warn( | ||||
return storage | '"remote" class is deprecated for provenance storage, please ' | ||||
'use "rpcapi" class instead.', | |||||
DeprecationWarning, | |||||
) | |||||
rpc_storage = ProvenanceStorageRPCClient(**kwargs) | |||||
if TYPE_CHECKING: | |||||
assert isinstance(rpc_storage, ProvenanceStorageInterface) | |||||
return rpc_storage | |||||
else: | |||||
raise ValueError | raise ValueError |