Uname : Linux serv1.rebootns.com 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64
Soft : LiteSpeed
Ip : 139.99.125.122
Port : 443
~
/
usr
/
lib
/
python3.9
/
site-packages
/
jinja2
/
__pycache__
[ HOME ]
Exec
Submit
File Name : loaders.cpython-39.pyc
a �`E � @ s0 d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddl m Z ddl mZ dd l mZ dd l m Z ddlmZ ddlmZ dd lmZ dd� ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG d 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 C s\ g }| � d�D ]H}tj|v s6tjr,tj|v s6|tjkr@t| ��q|r|dkr|�|� q|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�piecesZpiece� r �2/usr/lib/python3.9/site-packages/jinja2/loaders.py�split_template_path s ���� r c @ s2 e Zd ZdZdZdd� Zdd� Zed dd ��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 C s"