Changeset View
Changeset View
Standalone View
Standalone View
swh/provenance/__init__.py
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | def get_provenance_storage(cls: str, **kwargs) -> ProvenanceStorageInterface: | ||||
elif cls == "rabbitmq": | elif cls == "rabbitmq": | ||||
from .api.client import ProvenanceStorageRabbitMQClient | from .api.client import ProvenanceStorageRabbitMQClient | ||||
rmq_storage = ProvenanceStorageRabbitMQClient(**kwargs) | rmq_storage = ProvenanceStorageRabbitMQClient(**kwargs) | ||||
if TYPE_CHECKING: | if TYPE_CHECKING: | ||||
assert isinstance(rmq_storage, ProvenanceStorageInterface) | assert isinstance(rmq_storage, ProvenanceStorageInterface) | ||||
return rmq_storage | return rmq_storage | ||||
elif cls in ["remote", "rpcapi"]: | |||||
from .api.client import ProvenanceStorageRPCClient | |||||
if cls == "remote": | |||||
warnings.warn( | |||||
'"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 | |||||
raise ValueError | raise ValueError |