diff options
| author | Jordan Cook <jordan.cook@pioneer.com> | 2021-08-20 21:44:56 -0500 |
|---|---|---|
| committer | Jordan Cook <jordan.cook@pioneer.com> | 2021-08-20 22:25:44 -0500 |
| commit | 7b412f6ceebc3b7dc9c02a426a5d30ccf4d32a94 (patch) | |
| tree | dc466cf19d75ae246745ab51d304b7ac6d3f3243 /requests_cache | |
| parent | 358e294213448d212f373fe3c8401fab8b580463 (diff) | |
| download | requests-cache-7b412f6ceebc3b7dc9c02a426a5d30ccf4d32a94.tar.gz | |
Make DynamoDB and MongoDB naming consistent
Diffstat (limited to 'requests_cache')
| -rw-r--r-- | requests_cache/backends/__init__.py | 14 | ||||
| -rw-r--r-- | requests_cache/backends/dynamodb.py | 8 | ||||
| -rw-r--r-- | requests_cache/backends/gridfs.py | 4 | ||||
| -rw-r--r-- | requests_cache/backends/mongodb.py (renamed from requests_cache/backends/mongo.py) | 0 |
4 files changed, 14 insertions, 12 deletions
diff --git a/requests_cache/backends/__init__.py b/requests_cache/backends/__init__.py index 64da2c6..bc48161 100644 --- a/requests_cache/backends/__init__.py +++ b/requests_cache/backends/__init__.py @@ -40,15 +40,15 @@ def get_valid_kwargs(func: Callable, kwargs: Dict, extras: Iterable[str] = None) # Import all backend classes for which dependencies are installed try: - from .dynamodb import DynamoDbCache, DynamoDbDict + from .dynamodb import DynamoCache, DynamoDict except ImportError as e: - DynamoDbCache = DynamoDbDict = get_placeholder_class(e) # type: ignore + DynamoCache = DynamoDict = get_placeholder_class(e) # type: ignore try: from .gridfs import GridFSCache, GridFSPickleDict except ImportError as e: GridFSCache = GridFSPickleDict = get_placeholder_class(e) # type: ignore try: - from .mongo import MongoCache, MongoDict, MongoPickleDict + from .mongodb import MongoCache, MongoDict, MongoPickleDict except ImportError as e: MongoCache = MongoDict = MongoPickleDict = get_placeholder_class(e) # type: ignore try: @@ -69,13 +69,15 @@ except ImportError as e: DbCache = SQLiteCache DbDict = SQLiteDict DbPickeDict = SQLitePickleDict +DynamoDbCache = DynamoCache +DynamoDbDict = DynamoDict BACKEND_CLASSES = { - 'dynamodb': DynamoDbCache, + 'dynamodb': DynamoCache, 'filesystem': FileCache, 'gridfs': GridFSCache, 'memory': BaseCache, - 'mongo': MongoCache, + 'mongodb': MongoCache, 'redis': RedisCache, 'sqlite': SQLiteCache, } @@ -99,7 +101,7 @@ def init_backend(backend: BackendSpecifier = None, *args, **kwargs) -> BaseCache elif not backend: backend = 'sqlite' if BACKEND_CLASSES['sqlite'] else 'memory' - backend = str(backend).lower().replace('mongodb', 'mongo') + backend = str(backend).lower() if backend not in BACKEND_CLASSES: raise ValueError(f'Invalid backend: {backend}. Choose from: {BACKEND_CLASSES.keys()}') diff --git a/requests_cache/backends/dynamodb.py b/requests_cache/backends/dynamodb.py index f7c6bcc..b97952a 100644 --- a/requests_cache/backends/dynamodb.py +++ b/requests_cache/backends/dynamodb.py @@ -35,7 +35,7 @@ from botocore.exceptions import ClientError from . import BaseCache, BaseStorage, get_valid_kwargs -class DynamoDbCache(BaseCache): +class DynamoCache(BaseCache): """DynamoDB cache backend Args: @@ -48,13 +48,13 @@ class DynamoDbCache(BaseCache): def __init__(self, table_name: str = 'http_cache', connection: ServiceResource = None, **kwargs): super().__init__(**kwargs) - self.responses = DynamoDbDict(table_name, 'responses', connection=connection, **kwargs) - self.redirects = DynamoDbDict( + self.responses = DynamoDict(table_name, 'responses', connection=connection, **kwargs) + self.redirects = DynamoDict( table_name, 'redirects', connection=self.responses.connection, **kwargs ) -class DynamoDbDict(BaseStorage): +class DynamoDict(BaseStorage): """A dictionary-like interface for DynamoDB key-value store **Notes:** diff --git a/requests_cache/backends/gridfs.py b/requests_cache/backends/gridfs.py index 4d5a3fa..09aa360 100644 --- a/requests_cache/backends/gridfs.py +++ b/requests_cache/backends/gridfs.py @@ -3,7 +3,7 @@ ../_static/mongodb.png `GridFS <https://docs.mongodb.com/manual/core/gridfs/>`_ is a specification for storing large files -(>16 MB) in MongoDB. See :py:mod:`~requests_cache.backends.mongo` for more general info on MongoDB. +(>16 MB) in MongoDB. See :py:mod:`~requests_cache.backends.mongodb` for more general info on MongoDB. API Reference ^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ from pymongo import MongoClient from . import get_valid_kwargs from .base import BaseCache, BaseStorage -from .mongo import MongoDict +from .mongodb import MongoDict class GridFSCache(BaseCache): diff --git a/requests_cache/backends/mongo.py b/requests_cache/backends/mongodb.py index 0edf754..0edf754 100644 --- a/requests_cache/backends/mongo.py +++ b/requests_cache/backends/mongodb.py |
