swh:1:snp:eb70f1f85391e4b077c211bec36af0061c4bf937
Raw File
Tip revision: 30f7883afc7a1ee064b17d726505a1212b92a6b3 authored by Antoine R. Dumont (@ardumont) on 07 October 2016, 17:08:34 UTC
Open language_mimetype_{missing,add} endpoints
Tip revision: 30f7883
__init__.py
from . import storage

Storage = storage.Storage


def get_storage(storage_class, storage_args):
    """
    Get a storage object of class `storage_class` with arguments
    `storage_args`.

    Args:
        storage_class: one of 'remote_storage', 'local_storage'
        storage_args: the arguments to pass to the storage class
    Returns:
        an instance of swh.storage.Storage (either local or remote)
    Raises:
        ValueError if passed an unknown storage_class.
    """

    if storage_class == 'remote_storage':
        from .api.client import RemoteStorage as Storage
    elif storage_class == 'local_storage':
        from .storage import Storage
    else:
        raise ValueError('Unknown storage class `%s`' % storage_class)

    return Storage(*storage_args)
back to top