Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

compat.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. try:
  2. import importlib
  3. except ImportError:
  4. from django.utils import importlib
  5. try:
  6. from logging.config import dictConfig # Python >= 2.7
  7. except ImportError:
  8. from django.utils.log import dictConfig # Django <= 1.9
  9. import sys
  10. PY2 = sys.version_info[0] == 2
  11. PY3 = sys.version_info[0] == 3
  12. if PY3:
  13. string_types = str
  14. text_type = str
  15. else:
  16. string_types = basestring
  17. text_type = unicode
  18. try:
  19. from django.core.cache import caches # Django >= 1.7
  20. def get_cache(name):
  21. return caches[name]
  22. except ImportError:
  23. from django.core.cache import get_cache
  24. try:
  25. from django.utils.encoding import smart_text # For Django >= 1.5
  26. except ImportError:
  27. from django.utils.encoding import smart_unicode as smart_text
  28. # Django 1.4 doesn't have ``import_string`` or ``import_by_path``
  29. def import_attribute(name):
  30. """Return an attribute from a dotted path name (e.g. "path.to.func")."""
  31. module_name, attribute = name.rsplit('.', 1)
  32. module = importlib.import_module(module_name)
  33. return getattr(module, attribute)