MCPcopy Create free account
hub / github.com/pyload/pyload / load

Method load

module/lib/jinja2/loaders.py:102–137  ·  view source on GitHub ↗

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 n

(self, environment, name, globals=None)

Source from the content-addressed store, hash-verified

100
101 @internalcode
102 def load(self, environment, name, globals=None):
103 """Loads a template. This method looks up the template in the cache
104 or loads one by calling :meth:`get_source`. Subclasses should not
105 override this method as loaders working on collections of other
106 loaders (such as :class:`PrefixLoader` or :class:`ChoiceLoader`)
107 will not call this method but `get_source` directly.
108 """
109 code = None
110 if globals is None:
111 globals = {}
112
113 # first we try to get the source for this template together
114 # with the filename and the uptodate function.
115 source, filename, uptodate = self.get_source(environment, name)
116
117 # try to load the code from the bytecode cache if there is a
118 # bytecode cache configured.
119 bcc = environment.bytecode_cache
120 if bcc is not None:
121 bucket = bcc.get_bucket(environment, name, filename, source)
122 code = bucket.code
123
124 # if we don't have code so far (not cached, no longer up to
125 # date) etc. we compile the template
126 if code is None:
127 code = environment.compile(source, name, filename)
128
129 # if the bytecode cache is available and the bucket doesn't
130 # have a code so far, we give the bucket the new code and put
131 # it back to the bytecode cache.
132 if bcc is not None and bucket.code is None:
133 bucket.code = code
134 bcc.set_bucket(bucket)
135
136 return environment.template_class.from_code(environment, code,
137 globals, uptodate)
138
139
140class FileSystemLoader(BaseLoader):

Callers 2

_load_templateMethod · 0.45
load_bytecodeMethod · 0.45

Calls 5

get_sourceMethod · 0.95
get_bucketMethod · 0.80
compileMethod · 0.80
set_bucketMethod · 0.80
from_codeMethod · 0.80

Tested by

no test coverage detected