File: base.py

package info (click to toggle)
python-django-storages 1.14.5-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 884 kB
  • sloc: python: 4,448; makefile: 119; sh: 6
file content (24 lines) | stat: -rw-r--r-- 766 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.core.exceptions import ImproperlyConfigured
from django.core.files.storage import Storage


class BaseStorage(Storage):
    def __init__(self, **settings):
        default_settings = self.get_default_settings()

        for name, value in default_settings.items():
            if not hasattr(self, name):
                setattr(self, name, value)

        for name, value in settings.items():
            if name not in default_settings:
                raise ImproperlyConfigured(
                    "Invalid setting '{}' for {}".format(
                        name,
                        self.__class__.__name__,
                    )
                )
            setattr(self, name, value)

    def get_default_settings(self):
        return {}