/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/__pycache__
Edit: /opt/imunify360/venv/lib/python3.11/site-packages/jinja2/__pycache__/loaders.cpython-311.pyc (24911B)
§
¹»CCq£ã óœ — d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
ddl mZ dd l mZ dd
l m
Z
ddlmZ ddlmZ dd
lmZ d„ Z G d„ de¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ de¦ « Z G d„ d e¦ « ZdS )!zKAPI and implementations for loading templates from different data
sources.
é N)Úsha1)Úpath)Ú
ModuleTypeé )Úabc©Úfspath)Ú iteritems)Ústring_types)ÚTemplateNotFound)Úinternalcode)Úopen_if_existsc ó — g }| d¦ « D ]f}t j |v s*t j rt j |v s|t j k rt | ¦ « ‚|r|dk r| |¦ « Œg|S )z‰Split a path into segments and perform a sanity check. If it detects
'..' in the path it will raise a `TemplateNotFound` error.
ú/ú.)Úsplitr ÚsepÚaltsepÚpardirr Úappend)ÚtemplateÚpiecesÚpieces ún/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/jinja2/loaders.pyÚsplit_template_pathr s‹ € ð €FØ—’ Ñ$Ô$ð !ð !ˆåŒH˜ÐÐÝ”ð
Ý $¤¨uÐ 4Ð 4Ø�œÒ#Ð#å" 8Ñ,Ô,Ð,Ø
ð !�u ’|�|Ø�MŠM˜%Ñ Ô Ð øØ€Mó c ó: — e Zd ZdZdZd„ Zd„ Zedd„¦ « ZdS )Ú
BaseLoaderaÍ 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 file(path) as f:
source = f.read().decode('utf-8')
return source, path, lambda: mtime == getmtime(path)
Tc óf — | j st d| j j z ¦ « ‚t |¦ « ‚)aË Get the template source, filename and reload helper for a template.
It's passed the environment and template name and has to return a
tuple in the form ``(source, filename, uptodate)`` or raise a
`TemplateNotFound` error if it can't locate the template.
The source part of the returned tuple must be the source of the
template as unicode string or a ASCII bytestring. The filename should
be the name of the file on the filesystem if it was loaded from there,
otherwise `None`. The filename is used by python for the tracebacks
if no loader extension is used.
The last item in the tuple is the `uptodate` function. If auto
reloading is enabled it's always called to check if the template
changed. No arguments are passed so the function must store the
old state somewhere (for example in a closure). If it returns `False`
the template will be reloaded.
z&%s cannot provide access to the source)Úhas_source_accessÚRuntimeErrorÚ __class__Ú__name__r )ÚselfÚenvironmentr s r Ú
get_sourcezBaseLoader.get_sourceG s> € ð$ Ô%ð ÝØ8¸4¼>Ô;RÑRñô ð
õ ˜xÑ(Ô(Ð(r c ó — t d¦ « ‚)z”Iterates over all templates. If the loader does not support that
it should raise a :exc:`TypeError` which is the default behavior.
z-this loader cannot iterate over all templates)Ú TypeError©r$ s r Úlist_templateszBaseLoader.list_templates_ s € õ ÐGÑHÔHÐHr Nc óH — d}|€i }| ||¦ « \ }}}|j }|�| ||||¦ « } | j }|€| |||¦ « }|�#| j €|| _ | | ¦ « |j ||||¦ « S )ac 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.
N)r&