Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/django/core/files/storage/__init__.py: 84%
19 statements
« prev ^ index » next coverage.py v7.0.5, created at 2023-01-17 06:13 +0000
« prev ^ index » next coverage.py v7.0.5, created at 2023-01-17 06:13 +0000
1import warnings
3from django.conf import DEFAULT_STORAGE_ALIAS, settings
4from django.utils.deprecation import RemovedInDjango51Warning
5from django.utils.functional import LazyObject
6from django.utils.module_loading import import_string
8from .base import Storage
9from .filesystem import FileSystemStorage
10from .handler import InvalidStorageError, StorageHandler
11from .memory import InMemoryStorage
13__all__ = (
14 "FileSystemStorage",
15 "InMemoryStorage",
16 "Storage",
17 "DefaultStorage",
18 "default_storage",
19 "get_storage_class",
20 "InvalidStorageError",
21 "StorageHandler",
22 "storages",
23)
25GET_STORAGE_CLASS_DEPRECATED_MSG = (
26 "django.core.files.storage.get_storage_class is deprecated in favor of "
27 "using django.core.files.storage.storages."
28)
31def get_storage_class(import_path=None):
32 warnings.warn(GET_STORAGE_CLASS_DEPRECATED_MSG, RemovedInDjango51Warning)
33 return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
36class DefaultStorage(LazyObject):
37 def _setup(self):
38 self._wrapped = storages[DEFAULT_STORAGE_ALIAS]
41storages = StorageHandler()
42default_storage = DefaultStorage()