class_docstr: Baseclass for all loaders.  Subclass this and override `get_source` to
  implement a custom loading mechanism.  The environment provides a
  `get_template` method that calls the loader's `load` method to get the
  :class:`Template` object.
  
  A very basic example for a loader that looks up templates on the file
  system could look like this::
  
      from jinja2 import BaseLoader, TemplateNotFound
      from os.path import join, exists, getmtime
  
      class MyLoader(BaseLoader):
  
          def __init__(self, path):
              self.path = path
  
          def get_source(self, environment, template):
              path = join(self.path, template)
              if not exists(path):
                  raise TemplateNotFound(template)
              mtime = getmtime(path)
              with open(path) as f:
                  source = f.read()
              return source, path, lambda: mtime == getmtime(path)
class_docstr_tok: ["Baseclass","for","all","loaders",".","Subclass","this","and","override","`","get_source","`","to","implement","a","custom","loading","mechanism",".","The","environment","provides","a","`","get_template","`","method","that","calls","the","loader","'s","`","load","`","method","to","get","the",":","class",":","`","Template","`","object",".","A","very","basic","example","for","a","loader","that","looks","up","templates","on","the","file","system","could","look","like","this",":",":","from","jinja2","import","BaseLoader",",","TemplateNotFound","from","os.path","import","join",",","exists",",","getmtime","class","MyLoader","(","BaseLoader",")",":","def","__init__","(","self",",","path",")",":","self.path","=","path","def","get_source","(","self",",","environment",",","template",")",":","path","=","join","(","self.path",",","template",")","if","not","exists","(","path",")",":","raise","TemplateNotFound","(","template",")","mtime","=","getmtime","(","path",")","with","open","(","path",")","as","f",":","source","=","f.read","(",")","return","source",",","path",",","lambda",":","mtime","==","getmtime","(","path",")"]
docstr: Loads a template.  This method looks up the template in the cache
  or loads one by calling :meth:`get_source`.  Subclasses should not
  override this method as loaders working on collections of other
  loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`)
  will not call this method but `get_source` directly.
docstr_tok: ["Loads","a","template",".","This","method","looks","up","the","template","in","the","cache","or","loads","one","by","calling",":","meth",":","`","get_source","`",".","Subclasses","should","not","override","this","method","as","loaders","working","on","collections","of","other","loaders","(","such","as",":","class",":","`","PrefixLoader","`","or",":","class",":","`","ChoiceLoader","`",")","will","not","call","this","method","but","`","get_source","`","directly","."]
code: def load(
      self,
      environment: "Environment",
      name: str,
      globals: t.Optional[t.MutableMapping[str, t.Any]] = None,
  ) -> "Template":
      """Loads a template.  This method looks up the template in the cache
      or loads one by calling :meth:`get_source`.  Subclasses should not
      override this method as loaders working on collections of other
      loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`)
      will not call this method but `get_source` directly.
      """
      code = None
      if globals is None:
          globals = {}
  
      # first we try to get the source for this template together
      # with the filename and the uptodate function.
      source, filename, uptodate = self.get_source(environment, name)
  
      # try to load the code from the bytecode cache if there is a
      # bytecode cache configured.
      bcc = environment.bytecode_cache
      if bcc is not None:
          bucket = bcc.get_bucket(environment, name, filename, source)
          code = bucket.code
  
      # if we don't have code so far (not cached, no longer up to
      # date) etc. we compile the template
      if code is None:
          code = environment.compile(source, name, filename)
  
      # if the bytecode cache is available and the bucket doesn't
      # have a code so far, we give the bucket the new code and put
      # it back to the bytecode cache.
      if bcc is not None and bucket.code is None:
          bucket.code = code
          bcc.set_bucket(bucket)
  
      return environment.template_class.from_code(
          environment, code, globals, uptodate
      )
  
imports: import importlib.util
  import os
  import posixpath
  import sys
  import pkgutil
  import typing
  import weakref
  import zipimport
  from collections import abc
  from hashlib import sha1
  from importlib import import_module
  from types import ModuleType
  from .exceptions import TemplateNotFound
  from .utils import internalcode
  from .utils import open_if_exists
  import __res
label_desc: Use image node_id 3 for calling the BaseLoader obj's underlying member method code with example usage: obj.load(environment, name, globals) and returns: environment