⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.144
Server IP:
157.245.143.252
Server:
Linux www 6.11.0-9-generic #9-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 14 13:19:59 UTC 2024 x86_64
Server Software:
nginx/1.26.0
PHP Version:
8.3.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
jinja2
/
__pycache__
/
View File Name :
loaders.cpython-312.pyc
#e-Z d Z ddlZddlZddlZddlZddlZddlZddl Z ddl mZ ddlm Z ddlmZ ddlmZ ddlmZ dd lmZ ej* rdd lmZ ddlmZ ded ej4 e fdZ G d 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 d e Z$y)!zKAPI and implementations for loading templates from different data sources. N)abc)sha1) import_module) ModuleType )TemplateNotFound)internalcode)Environment)Templatetemplatereturnc ^ g }| j d D ] }t j j |v sSt j j rt j j |v s|t j j k( rt | |s|dk7 s|j | |S )zSplit a path into segments and perform a sanity check. If it detects '..' in the path it will raise a `TemplateNotFound` error. /.)splitospathsepaltseppardirr append)r piecespieces 0/usr/lib/python3/dist-packages/jinja2/loaders.pysplit_template_pathr s} F$GGKK5 277>>U#:&"8,, u|MM% % M c 2 e Zd ZdZdZdddedej eej e ej ej g e f f fdZdej e fdZ e dddd edej ej eej f ddfd Zy ) 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 open(path) as f: source = f.read() return source, path, lambda: mtime == getmtime(path) Tenvironmentr r r c r | j s!t t | j d 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 a string. 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$ cannot provide access to the source)has_source_accessRuntimeErrortype__name__r )selfr r s r get_sourcezBaseLoader.get_sourceJ s= ( %%:&&''KL x((r c t d )zIterates 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) TypeErrorr% s r list_templateszBaseLoader.list_templatesd s GHHr Nnameglobalsr c H d}|i }| j || \ }}}|j }| |j |||| } | j }||j ||| }|$ 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&