403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.144.84.11
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/mako/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/mako/__pycache__/runtime.cpython-37.pyc
B

�C]�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�=/opt/alt/python37/lib/python3.7/site-packages/mako/runtime.py�__init__s
zContext.__init__cCs0||_|j�|j�}|r,t�dd�|���dS)Nz%Reserved words passed to render(): %sz, )r
Zreserved_names�intersectionr
rZNameConflictError�join)r�tZ
illegal_namesrrr�_set_with_template.szContext._set_with_templatecCs|jjS)z]Return the :class:`.TemplateLookup` associated
        with this :class:`.Context`.

        )r
�lookup)rrrrr7szContext.lookupcCs
|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r)rrrr�kwargs?szContext.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)r)rrrr�
pop_caller[szContext.pop_callercCst|j���S)zAReturn a list of all names established in this :class:`.Context`.)�listr
�keys)rrrrr%aszContext.keyscCs"||jkr|j|Stj|SdS)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	�popr*)rr+rrr�_pop_buffer_and_writerts
zContext._pop_buffer_and_writercCs|��dS)z*push a capturing buffer onto this Context.N)r,)rrrr�_push_buffer}szContext._push_buffercCs
|j��S)z7pop the most recent capturing buffer from this Context.)r	r-)rrrr�_pop_buffer�szContext._pop_bufferNcCs|j�|tj�||��S)z+Return a value from this :class:`.Context`.)r
�getrr&)rr'�defaultrrrr1�szContext.getcCs|jd�|�dS)zSWrite a string to this :class:`.Context` object's
        underlying output buffer.r"N)r	r*)r�stringrrrr*�sz
Context.writecCs|jdjS)z#Return the current writer function.r")r	r*)rrrr�writer�szContext.writercCsJt�t�}|j|_|j��|_|j|_|j|_|j|_|j|_|j	|_	|S)N)
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.


        )r7r
�update)r�dr6rrr�_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)r7r
r-)rr6�xrrr�_clean_inheritance_tokens�sz!Context._clean_inheritance_tokens)N)�__name__�
__module__�__qualname__�__doc__rr�propertyrrr!r#r%r(r,r.r/r0r1r*r4r7r:r>rrrrrs&		
rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rcCs
d|_dS)N)�
nextcaller)rrrrr�szCallerStack.__init__cCs|��S)N)�__bool__)rrrr�__nonzero__�szCallerStack.__nonzero__cCst|�r|��rdpdS)NTF)�len�_get_caller)rrrrrE�szCallerStack.__bool__cCs|dS)Nr"r)rrrrrH�szCallerStack._get_callercCst|��|�S)N)�getattrrH)rr'rrr�__getattr__�szCallerStack.__getattr__cCs|jpd}|�|�d|_|S)N)rDr )r�framerrr�_push_frame�s

zCallerStack._push_framecCs|��|_dS)N)r-rD)rrrr�
_pop_frame�szCallerStack._pop_frameN)
r?r@rArrFrErHrJrLrMrrrrr�src@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.

    cCstd��dS)NrN)�	NameError)rrrr�__str__�szUndefined.__str__cCs|��S)N)rE)rrrrrF�szUndefined.__nonzero__cCsdS)NFr)rrrrrE�szUndefined.__bool__N)r?r@rArBrPrFrErrrrrN�srN�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|_dS)N)�stack)rrrrr�szLoopStack.__init__cCs|�|�|jS)N)�_push�_top)r�iterablerrr�_enter�s
zLoopStack._entercCs|��|jS)N)�_poprU)rrrr�_exitszLoopStack._exitcCs|jr|jdS|SdS)Nr")rS)rrrrrUs
zLoopStack._topcCs
|j��S)N)rSr-)rrrrrXszLoopStack._popcCs&t|�}|jr|jd|_|j�|�S)Nr")�LoopContextrSr;r )rrV�newrrrrTszLoopStack._pushcCst�d��dS)NzNo loop context is established)r�RuntimeException)rr'rrrrJszLoopStack.__getattr__cCs
t|j�S)N)�iterrU)rrrr�__iter__szLoopStack.__iter__N)
r?r@rArBrrWrYrCrUrXrTrJr^rrrrrR�srRc@sreZdZdZdd�Zdd�Zejdd��Ze	dd	��Z
e	d
d��Ze	dd
��Ze	dd��Z
e	dd��Zdd�ZdS)rZa�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�indexr;)rrVrrrr3szLoopContext.__init__ccs(x"|jD]}|V|jd7_qWdS)N�)r_r`)r�irrrr^8szLoopContext.__iter__cCs
t|j�S)N)rGr_)rrrr�__len__=szLoopContext.__len__cCst|�|jdS)Nra)rGr`)rrrr�
reverse_indexAszLoopContext.reverse_indexcCs
|jdkS)Nr)r`)rrrr�firstEszLoopContext.firstcCs|jt|�dkS)Nra)r`rG)rrrr�lastIszLoopContext.lastcCs|jS)N)�odd)rrrr�evenMszLoopContext.evencCst|jd�S)N�)�boolr`)rrrrrgQszLoopContext.oddcGs|std��||jt|�S)z5Cycle through values as the loop progresses.
        z(You must provide values to cycle through)�
ValueErrorr`rG)r�valuesrrr�cycleUszLoopContext.cycleN)r?r@rArBrr^rZmemoized_instancemethodrcrCrdrerfrhrgrmrrrrrZsrZc@seZdZdd�Zdd�ZdS)�_NSAttrcCs
||_dS)N)�_NSAttr__parent)rr;rrrr^sz_NSAttr.__init__cCs:|j}x&|r,t|j|�r$t|j|�S|j}qWt|��dS)N)ro�hasattr�modulerI�inherits�AttributeError)rr'�nsrrrrJas
z_NSAttr.__getattr__N)r?r@rArrJrrrrrn]srnc@s�eZdZdZddd�ZdZdZdZdZdZ	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.

      NTcCs2||_||_||_|dk	r.tdd�|D��|_dS)NcSsg|]}|j|f�qSr)r?)�.0r6rrr�
<listcomp>�sz&Namespace.__init__.<locals>.<listcomp>)�name�contextrr�dict�	callables)rrxryr{rr�
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`

        )rn)rrrr�attr�szNamespace.attrcCsL||f}||jjkr |jj|St||j��||jd�}||jj|<|SdS)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}N)ryr�TemplateNamespacer7�_templateuri)r�urir'rtrrr�
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_templateryr�)rr�rrr�get_template�szNamespace.get_templatecKs|jj|f|�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>``.

        )�cacher1)rr'rrrr�
get_cached�szNamespace.get_cachedcCs|jjS)zReturn the :class:`.Cache` object referenced
        by this :class:`.Namespace` object's
        :class:`.Template`.

        )�templater�)rrrrr�szNamespace.cachecKst|j||jf|�dS)z$Include a file at the given ``uri``.N)�
_include_fileryr�)rr�rrrr�include_fileszNamespace.include_filecCsHxB|D]:}|dkr2x,|��D]\}}|||<qWqt||�||<qWdS)N�*)�	_get_starrI)rr9�l�ident�k�vrrr�	_populates

zNamespace._populateccs*|jr&x|jD]}||j|fVqWdS)N)r{)rr'rrrr�szNamespace._get_starcCsL||jkr|j|}n&|jr*t|j|�}ntd|j|f��t|||�|S)Nz!Namespace '%s' has no member '%s')r{rrrIrsrx�setattr)rr'�valrrrrJ!s
zNamespace.__getattr__)NNTN)r?r@rArBrr{rqr�ry�filenamer�r�rZmemoized_propertyr~r�r�r�rCr�r�r�r�rJrrrrruks*
		!		ruc@sNeZdZdZddd�Zedd��Zedd	��Zed
d��Zdd
�Z	dd�Z
dS)r�z@A :class:`.Namespace` specific to a :class:`.Template` instance.NTc	Cs�||_||_||_|dk	r.tdd�|D��|_|dk	rRt|||�|_|jjj|_	n"|dk	rl||_|jj|_	nt
d��|r�t||j|d�\}	}
dS)NcSsg|]}|j|f�qSr)r?)rvr6rrrrwAsz.TemplateNamespace.__init__.<locals>.<listcomp>z 'template' argument is required.)�self_ns)rxryrrrzr{r�r�rqZ
_template_urir��	TypeError�_populate_self_namespace)rrxryr�rr{rrr|r}Zlclcallable�
lclcontextrrrr2szTemplateNamespace.__init__cCs|jjS)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�rq)rrrrrqQs	zTemplateNamespace.modulecCs|jjS)zhThe path of the filesystem file used for this
        :class:`.Namespace`'s module or template.
        )r�r�)rrrrr�\szTemplateNamespace.filenamecCs|jjS)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�)rrrrr�cs	zTemplateNamespace.uric#sX�jr&x�jD]}|�j|fVqW�fdd�}x �jjjD]}|||�fVq>WdS)Ncs�j�|�}t�|�j�S)N)r��_get_def_callablerrry)r'�	callable_)rrrr1ssz(TemplateNamespace._get_star.<locals>.get)r{r�rqZ_exports)rr'r1r�r)rrr�nszTemplateNamespace._get_starcCst||jkr|j|}nN|j�|�r>|j�|�}t�||j�}n&|jrRt|j|�}nt	d|j
|f��t|||�|S)Nz!Namespace '%s' has no member '%s')r{r�Zhas_defr�rrryrrrIrsrxr�)rr'r�r�rrrrJzs
zTemplateNamespace.__getattr__)NNNNTN)r?r@rArBrrCrqr�r�r�rJrrrrr�.s
r�c@s6eZdZdZddd�Zedd��Zdd	�Zd
d�ZdS)
�ModuleNamespacez;A :class:`.Namespace` specific to a Python module instance.NTc
Csf||_||_||_|dk	r.tdd�|D��|_t|�}x$|�d�dd�D]}	t||	�}qJW||_dS)NcSsg|]}|j|f�qSr)r?)rvr6rrrrw�sz,ModuleNamespace.__init__.<locals>.<listcomp>�.ra)	rxryrrrzr{�
__import__�splitrIrq)
rrxryrqr{rrr|r}�mod�tokenrrrr�s
zModuleNamespace.__init__cCs|jjS)zhThe path of the filesystem file used for this
        :class:`.Namespace`'s module or template.
        )rq�__file__)rrrrr��szModuleNamespace.filenameccsr|jr&x|jD]}||j|fVqWxFt|j�D]8}|ddkr2t|j|�}t|�r2|t�||j�fVq2WdS)Nr�_)r{�dirrqrI�callablerrry)rr'r�rrrr��szModuleNamespace._get_starcCst||jkr|j|}nNt|j|�r>t|j|�}t�||j�}n&|jrRt|j|�}ntd|j	|f��t
|||�|S)Nz!Namespace '%s' has no member '%s')r{rprqrIrrryrrrsrxr�)rr'r�r�rrrrJ�s
zModuleNamespace.__getattr__)NNTN)	r?r@rArBrrCr�r�rJrrrrr��s


r�cs�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�|f|�|�S|j��XdS)N)rrLrM)ry�argsr)�funcrr�wrap_stackframe�s
z(supports_caller.<locals>.wrap_stackframer)r�r�r)r�r�supports_caller�sr�cOs<t|�st�d��|��z|||�Wd|��}X|��S)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))N)r�rr\r/r0�getvalue)ryr�r�rr+rrrr�s
rcs�fdd�}|S)Ncs��fdd�}|S)NcsL��fdd�}y�jdd�|_Wntk
r6YnX�|��f|�|�S)Ncs��f|�|�S)Nr)r��kw)ry�	render_fnrr�y�szB_decorate_toplevel.<locals>.decorate_render.<locals>.go.<locals>.y�)r?r�)ryr�r�r�)�fnr�)ryr�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�r)r�r�_decorate_toplevel�sr�cs��fdd�}|S)Ncs�|����fdd�}|S)Ncs��f|�|�S)Nr)r�r�)ry�decrrr�sz5_decorate_inline.<locals>.decorate_render.<locals>.gor)r�r�)ryr�)r�rr��sz)_decorate_inline.<locals>.decorate_renderr)ryr�r�r)ryr�r�_decorate_inline�sr�cKs�t|||�}t|��|�\}}t||jf|�}|jr~y||f|�Wq�tk
rz|�|t���}|svtj	t
���Yq�Xn||f|�dS)zPlocate the template from the given uri and include it in
    the current output.N)r�r�r>�_kwargs_for_includer
Zinclude_error_handler�	Exceptionr�exception_as�reraise�sys�exc_info)ryr�r}rr�r��ctx�resultrrrr�
sr�c
Cs�|dkrdSt|||�}|d}|}x|jdk	r8|j}q&W|�d|i�}td|j||dd�|_|j|jd<|jd<t|jd	d�}|dk	r�|||�}|r�|St|jd
d�}	|	dk	r�|	|�|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.Nrr<zself:%sF)r�r|r;�local�
_mako_inheritZ_mako_generate_namespaces)	r�rrr:r�r�r
rIrqr�)
ryr�r}r�r�Zihr�r��retZgen_nsrrr�
_inherit_froms.


r�cCsf|jj}|dkr"t�d|jj��|�||�}y
|�|�Stjk
r`t�tt	�
����YnXdS)Nz.Template '%s' has no TemplateLookup associated)r
rrZTemplateLookupExceptionr�Z
adjust_urir�ZTopLevelLookupException�strrr�)ryr�Z
relativetorrrrr�>s
r�cCs^|dkrtd|j||dd�}||jd<|jd<t|jd�rT|j�||�}|rT|S|j|fS)Nzself:%sF)r�r|rr�r�)r�r�r
rprqr�r�)ryr�r�r�rrrr�Lsr�FcCsx|rtjdd�}n$|jr"t��}ntj||j|jd�}t|f|�}||_|�	|�t
|||f|�t||��|���
�S)z^create a Context and return the string
    output of the given template and template callable.T)�
as_unicode)r��encoding�errors)rr)Zbytestring_passthroughr�StringIO�output_encoding�encoding_errorsrrr�_render_context�_kwargs_for_callabler0r�)r�r�r�rr�r+ryrrr�_render\s$


r�cCsnt�|�}|dr|S|ddd�|dd�D�}i}x0|D](}|dkr>||kr>||kr>||||<q>W|S)NrircSsg|]}|dk	r|�qS)Nr)rvr�rrrrwsz(_kwargs_for_callable.<locals>.<listcomp>ra�ry)r�inspect_getargspec)r�r�argspec�	namedargsr�argrrrr�xs

r�cKs^t�|�}|ddd�|dd�D�}x0|D](}|dkr.||kr.||kr.||||<q.W|S)NrcSsg|]}|dk	r|�qS)Nr)rvr�rrrrw�sz'_kwargs_for_include.<locals>.<listcomp>rar�ry)rr�)r�rrr�r�r�rrrr��s

r�cOs\ddlm}t||j�s8t||�\}}t||||d�n t||j�\}}t||||d�dS)Nr)r�r)Z
mako.templater��
isinstanceZDefTemplater��_exec_templater;)�tmplr�ryr�rr�Zinheritr�rrrr��sr�cCs�|j}|dk	rx|js|jrxy||f|�|�Wq�tk
rRt||t���Yq�t��d}t|||�Yq�Xn||f|�|�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
Zformat_exceptions�
error_handlerr��
_render_errorrr�r�r�)r�ryr�rr��errrr��sr�cCs�|jr&|�||�}|s�tjt���n\t��}|jrNtj	dd�g|j
dd�<nt�	|j|j�g|j
dd�<|�
|�|j||d�dS)NT)r�)�error)r�rr�r�r�rZhtml_error_templaterrr)r	r�r�rZrender_context)r�ryr�r�Zerror_templaterrrr��s
r�)N)F)NN)$rBrr��makorrrZmako.compatr�objectrr$rrNZ	UNDEFINEDZSTOP_RENDERINGrRrZrnrur�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>sB-(BD]: 

	


Youez - 2016 - github.com/yon3zu
LinuXploit