%PDF- %PDF-
Direktori : /snap/core20/2582/usr/lib/python3/dist-packages/jinja2/__pycache__/ |
Current File : //snap/core20/2582/usr/lib/python3/dist-packages/jinja2/__pycache__/loaders.cpython-38.pyc |
U aG�\�C � @ s d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ ddl m Z ddlmZm Z ddlmZmZ d d � ZG dd� de�ZG d d� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZdS )z� jinja2.loaders ~~~~~~~~~~~~~~ Jinja loader classes. :copyright: (c) 2017 by the Jinja Team. :license: BSD, see LICENSE for more details. � N)� ModuleType)�path)�sha1)�TemplateNotFound)�open_if_exists�internalcode)�string_types� iteritemsc C s\ g }| � d�D ]H}tj|ks6tjr,tj|ks6|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 �0/usr/lib/python3/dist-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"