⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.30
Server IP:
45.79.8.107
Server:
Linux localhost 5.15.0-140-generic #150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025 x86_64
Server Software:
nginx/1.18.0
PHP Version:
8.1.2-1ubuntu2.21
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
lib
/
python3
/
dist-packages
/
jinja2
/
__pycache__
/
View File Name :
loaders.cpython-310.pyc
o G؊aX @ sP d Z ddlZddlZddlZddlZddlZddlZddl m Z ddlmZ ddlm Z ddlmZ ddlmZ dd lmZ dd lmZ ejrSddlmZ ddlmZ d edeje fddZG dd dZG dd deZG dd deZG dd deZG dd deZ G dd deZ!G dd deZ"G dd d eZ#G d!d" d"eZ$dS )#zKAPI and implementations for loading templates from different data sources. N)abc)sha1) import_module) ModuleType )TemplateNotFound)internalcode)open_if_exists)Environment)Templatetemplatereturnc C sb g }| dD ]'}tjj|v stjjrtjj|v s|tjjkr#t| |r.|dkr.|| q|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 piecespiece r 0/usr/lib/python3/dist-packages/jinja2/loaders.pysplit_template_path s r c @ s e Zd ZdZdZdddedejeeje ejej g e f f fddZdeje fd d Z e dddded ejejeejf ddfddZdS ) 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 C s" | j s tt| j dt|)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 r r r get_sourceJ s zBaseLoader.get_sourcec C s 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# r r r list_templatesd s zBaseLoader.list_templatesNnameglobalsr c C s d}|du ri }| ||\}}}|j}|dur#|||||} | j}|du r.||||}|dur?| jdu r?|| _|| |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$ bytecode_cache get_bucketcodecompile set_buckettemplate_class from_code) r# r r( r) r, sourcefilenameuptodatebccbucketr r r loadj s zBaseLoader.loadN)r! __module____qualname____doc__r strtTupleOptionalCallableboolr$ Listr' r MutableMappingAnyr6 r r r r r ) s, $ r c @ s e Zd ZdZ ddejeejej ejeejf f dede ddfd d Zddd edejeeej g e f f fddZdeje fddZdS )FileSystemLoadera Load templates from a directory in the file system. The path can be relative or absolute. Relative paths are relative to the current working directory. .. code-block:: python loader = FileSystemLoader("templates") A list of paths can be given. The directories will be searched in order, stopping at the first matching template. .. code-block:: python loader = FileSystemLoader(["/override/templates", "/default/templates"]) :param searchpath: A path, or list of paths, to the directory that contains the templates. :param encoding: Use this encoding to read the text from template files. :param followlinks: Follow symbolic links in the path. .. versionchanged:: 2.8 Added the ``followlinks`` parameter. utf-8F searchpathencodingfollowlinksr Nc C s<