def load_template_source(name, dirs=[]):
  app = apputil.get_current_app()
  if not app:
    logging.info("No app found while loading template %s" % name)
    raise TemplateDoesNotExist("No app: " + name)
  if app in APP_REMAP:
    app = APP_REMAP[app]
  # We can import the app, and then find it in sys.modules,
  # thereby, in cases of "a.b.c", finding the whole thing, and not
  # just "a".
  __import__(app)
  app_module = sys.modules[app]
  app_dir = os.path.dirname(app_module.__file__)
  default_dir = os.path.join(app_dir, 'templates')

  return app_directories.load_template_source(name, [default_dir])
dataset/ETHPy150Open cloudera/hue/desktop/core/src/desktop/lib/template_loader.py/load_template_source/original