Debian Codegraph @

celery_haystack/utils.py

raw symbols SCIP
1 from django.core.exceptions import ImproperlyConfigured
2 try:
3 from importlib import import_module
4 except ImportError:
5 from django.utils.importlib import import_module
6
7 from .conf import settings
8
9
10 def get_update_task(task_path=None):
11 import_path = task_path or settings.CELERY_HAYSTACK_DEFAULT_TASK
12 module, attr = import_path.rsplit('.', 1)
13 try:
14 mod = import_module(module)
15 except ImportError as e:
16 raise ImproperlyConfigured('Error importing module %s: "%s"' %
17 (module, e))
18 try:
19 task = getattr(mod, attr)
20 except AttributeError:
21 raise ImproperlyConfigured('Module "%s" does not define a "%s" '
22 'class.' % (module, attr))
23 return task