- GRAYBYTE UNDETECTABLE CODES -

403Webshell
Server IP : 184.154.167.98  /  Your IP : 3.147.73.9
Web Server : Apache
System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
User : puertode ( 1767)
PHP Version : 8.2.26
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/jinja2/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/jinja2/__pycache__/loaders.cpython-36.opt-1.pyc
3

aG�\�C�@sdZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZd	d
�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�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�	iteritemscCs`g}xV|jd�D]H}tj|ks8tjr.tj|ks8|tjkrBt|��q|r|dkr|j|�qW|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�/usr/lib/python3.6/loaders.py�split_template_paths


rc@s2eZdZdZdZdd�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)
    TcCs"|jstd|jj��t|��dS)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 sourceN)�has_source_access�RuntimeError�	__class__�__name__r)�self�environmentrrrr�
get_sourceFszBaseLoader.get_sourcecCstd��dS)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 templatesN)�	TypeError)rrrr�list_templates]szBaseLoader.list_templatesNc
Cs�d}|dkri}|j||�\}}}|j}|dk	rF|j||||�}	|	j}|dkr\|j|||�}|dk	r~|	jdkr~||	_|j|	�|jj||||�S)acLoads 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)rZbytecode_cacheZ
get_bucket�code�compileZ
set_bucket�template_classZ	from_code)
rr�name�globalsr �source�filename�uptodateZbccZbucketrrr�loadcs

zBaseLoader.load)N)	r�
__module__�__qualname__�__doc__rrrrr(rrrrr%src@s*eZdZdZddd�Zdd�Zdd	�Zd
S)�FileSystemLoadera"Loads templates from the file system.  This loader can find templates
    in folders on the file system and is the preferred way to load them.

    The loader takes the path to the templates as string, or if multiple
    locations are wanted a list of them which is then looked up in the
    given order::

    >>> loader = FileSystemLoader('/path/to/templates')
    >>> loader = FileSystemLoader(['/path/to/templates', '/other/path'])

    Per default the template encoding is ``'utf-8'`` which can be changed
    by setting the `encoding` parameter to something else.

    To follow symbolic links, set the *followlinks* parameter to ``True``::

    >>> loader = FileSystemLoader('/path/to/templates', followlinks=True)

    .. versionchanged:: 2.8+
       The *followlinks* parameter was added.
    �utf-8FcCs*t|t�r|g}t|�|_||_||_dS)N)�
isinstancer�list�
searchpath�encoding�followlinks)rr0r1r2rrr�__init__�s


zFileSystemLoader.__init__cs�t|�}xp|jD]f}tj|f|���t��}|dkr6qz|j�j|j�}Wd|j�Xtj	�����fdd�}|�|fSWt
|��dS)Ncs(ytj���kStk
r"dSXdS)NF)r�getmtime�OSErrorr)r&�mtimerrr'�sz-FileSystemLoader.get_source.<locals>.uptodate)rr0r�joinr�read�decoder1�closer4r)rrrrr0�f�contentsr'r)r&r6rr�s

zFileSystemLoader.get_sourcec	Cs�t�}x�|jD]�}tj||jd�}x~|D]v\}}}xj|D]b}tjj||�t|�d�jtjj	�j
tjj	d�}|dd�dkr�|dd�}||kr8|j|�q8Wq(WqWt|�S)N)r2r
�z./)
�setr0�os�walkr2rr7�len�stripr
�replace�add�sorted)	r�foundr0Zwalk_dir�dirpathZdirnames�	filenamesr&rrrrr�s
zFileSystemLoader.list_templatesN)r-F)rr)r*r+r3rrrrrrr,�s
r,c@s*eZdZdZddd�Zdd�Zdd	�Zd
S)�
PackageLoadera,Load templates from python eggs or packages.  It is constructed with
    the name of the python package and the path to the templates in that
    package::

        loader = PackageLoader('mypackage', 'views')

    If the package path is not given, ``'templates'`` is assumed.

    Per default the template encoding is ``'utf-8'`` which can be changed
    by setting the `encoding` parameter to something else.  Due to the nature
    of eggs it's only possible to reload templates if the package was loaded
    from the file system and not a zip file.
    �	templates�utf-8cCsFddlm}m}m}||�}||_|�|_t||�|_||_||_	dS)Nr)�DefaultProvider�ResourceManager�get_provider)
Z
pkg_resourcesrLrMrNr1�managerr.�filesystem_bound�provider�package_path)r�package_namerRr1rLrMrNrQrrrr3�szPackageLoader.__init__cs�t|�}dj|jft|��}|jj|�s2t|��d�}|jrh|jj|j	|��t
j�����fdd�}|jj|j	|�}|j
|j��|fS)Nr
cs(ytj���kStk
r"dSXdS)NF)rr4r5r)r&r6rrr'�sz*PackageLoader.get_source.<locals>.uptodate)rr7rR�tuplerQZhas_resourcerrPZget_resource_filenamerOrr4Zget_resource_stringr9r1)rrrr�pr'r%r)r&r6rr�s
zPackageLoader.get_sourcecsb�j}|dd�dkr$|dd�}n|dkr0d}t|��g�����fdd���|��j��S)Nr=z./r�csTxN�jj|�D]>}|d|}�jj|�r4�|�q�j|�d�jd��qWdS)Nr
)rQZresource_listdirZresource_isdirr�lstrip)rr&�fullname)�_walk�offset�resultsrrrrYs

z+PackageLoader.list_templates.<locals>._walk)rRrA�sort)rrr)rYrZr[rrr�szPackageLoader.list_templatesN)rJrK)rr)r*r+r3rrrrrrrI�s



rIc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�
DictLoaderaLoads a template from a python dict.  It's passed a dict of unicode
    strings bound to template names.  This loader is useful for unittesting:

    >>> loader = DictLoader({'index.html': 'source here'})

    Because auto reloading is rarely useful this is disabled per default.
    cCs
||_dS)N)�mapping)rr^rrrr3szDictLoader.__init__cs6��jkr*�j���d���fdd�fSt���dS)Ncs��jj��kS)N)r^�getr)rr%rrr�<lambda>sz'DictLoader.get_source.<locals>.<lambda>)r^r)rrrr)rr%rrrs

zDictLoader.get_sourcecCs
t|j�S)N)rEr^)rrrrr szDictLoader.list_templatesN)rr)r*r+r3rrrrrrr]sr]c@s eZdZdZdd�Zdd�ZdS)�FunctionLoadera�A loader that is passed a function which does the loading.  The
    function receives the name of the template and has to return either
    an unicode string with the template source, a tuple in the form ``(source,
    filename, uptodatefunc)`` or `None` if the template does not exist.

    >>> def load_template(name):
    ...     if name == 'index.html':
    ...         return '...'
    ...
    >>> loader = FunctionLoader(load_template)

    The `uptodatefunc` is a function that is called if autoreload is enabled
    and has to return `True` if the template is still up to date.  For more
    details have a look at :meth:`BaseLoader.get_source` which has the same
    return value.
    cCs
||_dS)N)�	load_func)rrbrrrr36szFunctionLoader.__init__cCs4|j|�}|dkrt|��nt|t�r0|ddfS|S)N)rbrr.r)rrr�rvrrrr9s



zFunctionLoader.get_sourceN)rr)r*r+r3rrrrrra$srac@s@eZdZdZddd�Zdd�Zdd�Zedd
d��Zdd
�Z	d	S)�PrefixLoaderaA loader that is passed a dict of loaders where each loader is bound
    to a prefix.  The prefix is delimited from the template by a slash per
    default, which can be changed by setting the `delimiter` argument to
    something else::

        loader = PrefixLoader({
            'app1':     PackageLoader('mypackage.app1'),
            'app2':     PackageLoader('mypackage.app2')
        })

    By loading ``'app1/index.html'`` the file from the app1 package is loaded,
    by loading ``'app2/index.html'`` the file from the second.
    r
cCs||_||_dS)N)r^�	delimiter)rr^rerrrr3QszPrefixLoader.__init__cCsJy |j|jd�\}}|j|}Wn ttfk
r@t|��YnX||fS)N�)rrer^�
ValueError�KeyErrorr)rr�prefixr#�loaderrrr�
get_loaderUszPrefixLoader.get_loadercCs<|j|�\}}y|j||�Stk
r6t|��YnXdS)N)rkrr)rrrrjr#rrrr]s
zPrefixLoader.get_sourceNcCs>|j|�\}}y|j|||�Stk
r8t|��YnXdS)N)rkr(r)rrr#r$rjZ
local_namerrrr(fs
zPrefixLoader.loadcCsFg}x<t|j�D].\}}x$|j�D]}|j||j|�q"WqW|S)N)r	r^rrre)r�resultrirjrrrrrps
zPrefixLoader.list_templates)r
)N)
rr)r*r+r3rkrrr(rrrrrrdBs

		rdc@s6eZdZdZdd�Zdd�Zeddd��Zd	d
�ZdS)�ChoiceLoadera�This loader works like the `PrefixLoader` just that no prefix is
    specified.  If a template could not be found by one loader the next one
    is tried.

    >>> loader = ChoiceLoader([
    ...     FileSystemLoader('/path/to/user/templates'),
    ...     FileSystemLoader('/path/to/system/templates')
    ... ])

    This is useful if you want to allow users to override builtin templates
    from a different location.
    cCs
||_dS)N)�loaders)rrnrrrr3�szChoiceLoader.__init__cCs>x0|jD]&}y|j||�Stk
r,YqXqWt|��dS)N)rnrr)rrrrjrrrr�s
zChoiceLoader.get_sourceNcCs@x2|jD](}y|j|||�Stk
r.YqXqWt|��dS)N)rnr(r)rrr#r$rjrrrr(�s
zChoiceLoader.loadcCs,t�}x|jD]}|j|j��qWt|�S)N)r>rn�updaterrE)rrFrjrrrr�szChoiceLoader.list_templates)N)	rr)r*r+r3rrr(rrrrrrmxsrmc@seZdZdZdS)�_TemplateModulez9Like a normal module but with support for weak referencesN)rr)r*r+rrrrrp�srpc@sBeZdZdZdZdd�Zedd��Zedd��Ze	dd
d��Z
d	S)
�ModuleLoadera6This loader loads templates from precompiled templates.

    Example usage:

    >>> loader = ChoiceLoader([
    ...     ModuleLoader('/path/to/compiled/templates'),
    ...     FileSystemLoader('/path/to/templates')
    ... ])

    Templates can be precompiled with :meth:`Environment.compile_templates`.
    Fcs^dt|��t��}t|t�r&|g}nt|�}||_tj|�fdd��tj	�<||_
�|_dS)Nz_jinja2_module_templates_%xcstjj�d�S)N)�sys�modules�pop)�x)rSrrr`�sz'ModuleLoader.__init__.<locals>.<lambda>)�idrpr.rr/�__path__�weakref�proxyrrrs�modulerS)rr�modr)rSrr3�s
zModuleLoader.__init__cCsdt|jd��j�S)NZtmpl_zutf-8)r�encodeZ	hexdigest)r#rrr�get_template_key�szModuleLoader.get_template_keycCstj|�dS)Nz.py)rqr})r#rrr�get_module_filename�sz ModuleLoader.get_module_filenameNcCs�|j|�}d|j|f}t|j|d�}|dkrnyt|dddg�}Wntk
r^t|��YnXtjj	|d�|j
j||j|�S)Nz%s.%s�root)
r}rS�getattrrz�
__import__�ImportErrorrrrrsrtr"Zfrom_module_dict�__dict__)rrr#r$�keyrzr{rrrr(�s
zModuleLoader.load)N)rr)r*r+rr3�staticmethodr}r~rr(rrrrrq�srq)r+r?rrrx�typesrrZhashlibrZjinja2.exceptionsrZjinja2.utilsrrZjinja2._compatrr	r�objectrr,rIr]rardrmrprqrrrr�<module>
s&eCA6)

Youez - 2016 - github.com/yon3zu
LinuXploit