Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/mako/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/mako/__pycache__/runtime.cpython-38.pyc
U

O��g�l�@sHdZddlZddlZddlZddlmZddlmZddlmZGdd�d�ZGdd	�d	e	�Z
Gd
d�d�Ze�ZdZ
Gd
d�d�ZGdd�d�ZGdd�d�ZGdd�d�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd6d'd(�Zd7d*d+�Zd,d-�Zd.d/�Zd0d1�Zd8d2d3�Z d4d5�Z!dS)9zdprovides runtime services for templates, including Context,
Namespace, and various helper functions.�N)�compat)�
exceptions)�utilc@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�9/opt/cppython/lib/python3.8/site-packages/mako/runtime.py�__init__s
zContext.__init__cCs0||_|j�|j�}|r,t�dd�|���dS)Nz%Reserved words passed to render(): %sz, )r�reserved_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)}

        )rr
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)rrrrr�
pop_caller[szContext.pop_callercCst|j���S)zAReturn a list of all names established in this :class:`.Context`.)�listr	�keysrrrrr&aszContext.keyscCs"||jkr|j|Stj|SdS�N)r	�builtins�__dict__�r�keyrrr�__getitem__fs

zContext.__getitem__cCst��}|j�|�|jS)zUpush a capturing buffer onto this Context and return
        the new writer function.)r�FastEncodingBufferrr!�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.r/rrr�_pop_buffer_and_writerts
zContext._pop_buffer_and_writercCs|��dS)z*push a capturing buffer onto this Context.N)r1rrrr�_push_buffer}szContext._push_buffercCs
|j��S)z7pop the most recent capturing buffer from this Context.)rr2rrrr�_pop_buffer�szContext._pop_bufferNcCs|j�|tj�||��S)z+Return a value from this :class:`.Context`.)r	�getr(r))rr+�defaultrrrr6�szContext.getcCs|jd�|�dS)zSWrite a string to this :class:`.Context` object's
        underlying output buffer.r#N�rr.)r�stringrrrr.�sz
Context.writecCs|jdjS)z#Return the current writer function.r#r8rrrr�writer�szContext.writercCsJt�t�}|j|_|j��|_|j|_|j|_|j|_|j|_|j	|_	|Sr')
r�__new__rr	r
rrr
rr)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.


        )r=r	�update)r�dr<rrr�_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)r=r	r2)rr<�xrrr�_clean_inheritance_tokens�sz!Context._clean_inheritance_tokens)N)�__name__�
__module__�__qualname__�__doc__rr�propertyrr r"r$r&r,r1r3r4r5r6r.r:r=r@rDrrrrrs*	

	
rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rcCs
d|_dSr')�
nextcallerrrrrr�szCallerStack.__init__cCs|��Sr'��__bool__rrrr�__nonzero__�szCallerStack.__nonzero__cCst|�r|��rdpdS)NTF)�len�_get_callerrrrrrL�szCallerStack.__bool__cCs|dS�Nr#rrrrrrO�szCallerStack._get_callercCst|��|�Sr')�getattrrOr*rrr�__getattr__�szCallerStack.__getattr__cCs|jpd}|�|�d|_|Sr')rJr!)r�framerrr�_push_frame�s

zCallerStack._push_framecCs|��|_dSr')r2rJrrrr�
_pop_frame�szCallerStack._pop_frameN)
rErFrGrrMrLrOrRrTrUrrrrr�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)NrV)�	NameErrorrrrr�__str__�szUndefined.__str__cCs|��Sr'rKrrrrrM�szUndefined.__nonzero__cCsdS)NFrrrrrrL�szUndefined.__bool__N)rErFrGrHrXrMrLrrrrrV�srV�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'��stackrrrrr�szLoopStack.__init__cCs|�|�|jSr')�_push�_top�r�iterablerrr�_enter�s
zLoopStack._entercCs|��|jSr')�_popr^rrrr�_exitszLoopStack._exitcCs|jr|jdS|SdSrPr[rrrrr^s
zLoopStack._topcCs
|j��Sr')r\r2rrrrrbszLoopStack._popcCs&t|�}|jr|jd|_|j�|�SrP)�LoopContextr\rAr!)rr`�newrrrr]szLoopStack._pushcCst�d��dS)NzNo loop context is established)r�RuntimeExceptionr*rrrrRszLoopStack.__getattr__cCs
t|j�Sr')�iterr^rrrr�__iter__szLoopStack.__iter__N)
rErFrGrHrrarcrIr^rbr]rRrhrrrrrZ�s
rZc@sreZdZdZdd�Zdd�Zejdd��Ze	dd	��Z
e	d
d��Ze	dd
��Ze	dd��Z
e	dd��Zdd�ZdS)rda�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�indexrAr_rrrr3szLoopContext.__init__ccs$|jD]}|V|jd7_qdS�N�)rjrk)r�irrrrh8s
zLoopContext.__iter__cCs
t|j�Sr')rNrjrrrr�__len__=szLoopContext.__len__cCst|�|jdSrl)rNrkrrrr�
reverse_indexAszLoopContext.reverse_indexcCs
|jdkSri)rkrrrr�firstEszLoopContext.firstcCs|jt|�dkSrl)rkrNrrrr�lastIszLoopContext.lastcCs|jSr')�oddrrrr�evenMszLoopContext.evencCst|jd�S)N�)�boolrkrrrrrsQszLoopContext.oddcGs|std��||jt|�S)z,Cycle through values as the loop progresses.z(You must provide values to cycle through)�
ValueErrorrkrN)r�valuesrrr�cycleUszLoopContext.cycleN)rErFrGrHrrhrZmemoized_instancemethodrorIrprqrrrtrsryrrrrrds 





rdc@seZdZdd�Zdd�ZdS)�_NSAttrcCs
||_dSr')�_NSAttr__parent)rrArrrr]sz_NSAttr.__init__cCs6|j}|r*t|j|�r"t|j|�S|j}qt|��dSr')r{�hasattr�modulerQ�inherits�AttributeError)rr+�nsrrrrR`sz_NSAttr.__getattr__N)rErFrGrrRrrrrrz\srzc@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.

    NTcCs.||_||_||_|dk	r*dd�|D�|_dS)NcSsi|]}|j|�qSr�rE��.0r<rrr�
<dictcomp>�sz&Namespace.__init__.<locals>.<dictcomp>)�name�contextr~�	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`

        )rzrrrr�attr�szNamespace.attrcCsH||f}||jjkr |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�TemplateNamespacer=�_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|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>``.

        )�cacher6)rr+r rrr�
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_filer�r�)rr�r rrr�include_file
szNamespace.include_filecCs@|D]6}|dkr,|��D]\}}|||<qqt||�||<qdS)N�*)�	_get_starrQ)rr?�l�ident�k�vrrr�	_populates
zNamespace._populateccs&|jr"|jD]}||j|fVqdSr')r�r*rrrr�s
zNamespace._get_starcCsL||jkr|j|}n&|jr*t|j|�}ntd|j|f��t|||�|S�Nz!Namespace '%s' has no member '%s')r�r~rQrr��setattr)rr+�valrrrrRs
�zNamespace.__getattr__)NNTN)rErFrGrHrr�r}r�r��filenamer�r�rZmemoized_propertyr�r�r�r�rIr�r�r�r�rRrrrrr�js0�
		
 	
r�c@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*dd�|D�|_|dk	rNt|||�|_|jjj|_n"|dk	rh||_|jj|_nt	d��|r�t
||j|d�\}	}
dS)NcSsi|]}|j|�qSrr�r�rrrr�?sz.TemplateNamespace.__init__.<locals>.<dictcomp>z 'template' argument is required.)�self_ns)r�r�r~r�r�r�r}Z
_template_urir��	TypeError�_populate_self_namespace)rr�r�r�r�r�r~r�r�Zlclcallable�
lclcontextrrrr0s$�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�r}rrrrr}Os	zTemplateNamespace.modulecCs|jjS�zhThe path of the filesystem file used for this
        :class:`.Namespace`'s module or template.
        )r�r�rrrrr�ZszTemplateNamespace.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�as	zTemplateNamespace.uric#sP�jr"�jD]}|�j|fVq�fdd�}�jjjD]}|||�fVq8dS)Ncs�j�|�}t�|�j�Sr')r��_get_def_callablerrr�)r+�	callable_rrrr6qsz(TemplateNamespace._get_star.<locals>.get)r�r�r}Z_exports)rr+r6r�rrrr�ls
zTemplateNamespace._get_starcCst||jkr|j|}nN|j�|�r>|j�|�}t�||j�}n&|jrRt|j|�}nt	d|j
|f��t|||�|Sr�)r�r�Zhas_defr�rrr�r~rQrr�r��rr+r�r�rrrrRxs
�zTemplateNamespace.__getattr__)NNNNTN)rErFrGrHrrIr}r�r�r�rRrrrrr�,s �





r�c@s6eZdZdZddd�Zedd��Zdd	�Zd
d�ZdS)
�ModuleNamespacez;A :class:`.Namespace` specific to a Python module instance.NTc
Cs^||_||_||_|dk	r*dd�|D�|_t|�}|�d�dd�D]}	t||	�}qD||_dS)NcSsi|]}|j|�qSrr�r�rrrr��sz,ModuleNamespace.__init__.<locals>.<dictcomp>�.rm)r�r�r~r��
__import__�splitrQr})
rr�r�r}r�r~r�r��mod�tokenrrrr�s
zModuleNamespace.__init__cCs|jjSr�)r}�__file__rrrrr��szModuleNamespace.filenameccsj|jr"|jD]}||j|fVqt|j�D]8}|ddkr,t|j|�}t|�r,|t�||j�fVq,dS)Nr�_)r��dirr}rQ�callablerrr�)rr+r�rrrr��s
zModuleNamespace._get_starcCst||jkr|j|}nNt|j|�r>t|j|�}t�||j�}n&|jrRt|j|�}ntd|j	|f��t
|||�|Sr�)r�r|r}rQrrr�r~rr�r�r�rrrrR�s
�zModuleNamespace.__getattr__)NNTN)	rErFrGrHrrIr�r�rRrrrrr��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`.

    cs0|j��z�|f|�|�W�S|j��XdSr')rrTrU)r��argsr ��funcrr�wrap_stackframe�s
z(supports_caller.<locals>.wrap_stackframer)r�r�rr�r�supports_caller�sr�cOs<t|�st�d��|��z|||�W5|��}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)))r�rrfr4r5�getvalue)r�r�r�r r0rrrr�s�
rcs�fdd�}|S)Ncs��fdd�}|S)NcsL��fdd�}z�jdd�|_Wntk
r6YnX�|��f|�|�S)Ncs��f|�|�Sr'r�r��kw)r��	render_fnrr�y�szB_decorate_toplevel.<locals>.decorate_render.<locals>.go.<locals>.y�)rEr�)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)Ncs��f|�|�Sr'rr�)r��decrrr�sz5_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||jf|�}|jrrz||f|�Wq~tk
rn|�|t���}|sj�Yq~Xn||f|�dS)zPlocate the template from the given uri and include it in
    the current output.N)	r�r�rD�_kwargs_for_includer	Zinclude_error_handler�	Exceptionr�exception_as)r�r�r�r r�r��ctx�resultrrrr�s�
r�c
Cs�|dkrdSt|||�}|d}|}|jdk	r6|j}q$|�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.NrrB�self:%sF�r�r�rA�local�
_mako_inheritZ_mako_generate_namespaces)	r�r~r@r�r�r	rQr}r�)
r�r�r�r�r�Zihr�r��retZgen_nsrrr�
_inherit_froms0
�
r�c
Csx|jj}|dkr"t�d|jj��|�||�}z|�|�WStjk
rr}zt�tt	�
���|�W5d}~XYnXdS)Nz.Template '%s' has no TemplateLookup associated)rrrZTemplateLookupExceptionr�Z
adjust_urir�ZTopLevelLookupException�strrr�)r�r�Z
relativetor�errrr�<s ��
��r�cCs^|dkrtd|j||dd�}||jd<|jd<t|jd�rT|j�||�}|rT|S|j|fS)Nr�Fr�rr�r�)r�r�r	r|r}r�r�)r�r�r�r�rrrr�Ls�r�FcCsb|rt��}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.)�encoding�errors)rr-�output_encoding�encoding_errorsrr
r�_render_context�_kwargs_for_callabler5r�)r�r�r�rZ
as_unicoder0r�rrr�_render\s&
�
���r�cCsjt�|�}|dr|S|ddd�|dd�D�}i}|D](}|dkr<||kr<||kr<||||<q<|S)NrurcSsg|]}|dk	r|�qSr'r�r�r�rrr�
<listcomp>{sz(_kwargs_for_callable.<locals>.<listcomp>rm�r��rZinspect_getargspec)r�r�argspec�	namedargsr �argrrrr�ts
r�cKsZt�|�}|ddd�|dd�D�}|D](}|dkr,||kr,||kr,||||<q,|S)NrcSsg|]}|dk	r|�qSr'rr�rrrr��sz'_kwargs_for_include.<locals>.<listcomp>rmr�r�r�)r�rr r�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_templaterA)�tmplr�r�r�r r��inheritr�rrrr��sr�cCs�|j}|dk	rx|js|jrxz||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��sys�exc_info)r�r�r�r r�r�rrrr��s��r�cCs�|jr>|�||�}|s�t��\}}}|r8|r8|�|��q�|�nXt��}|jrbt��g|j	dd�<nt�|j
|j�g|j	dd�<|�|�|j
||d�dS)N)�error)r�r�r��with_tracebackrZhtml_error_templater
rr-rr�r�rZrender_context)r�r�r�r��tp�value�tbZerror_templaterrrr��s"��
r�)N)F)NN)"rHr(rr��makorrrrr%rrVZ	UNDEFINEDZSTOP_RENDERINGrZrdrzr�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�rrrr�<module>sB-(AC]: 

	


F1le Man4ger