a
    e	gl                     @   sH  d Z ddlZddlZddlZddlmZ ddlmZ ddlmZ G dd dZG dd	 d	e	Z
G d
d dZe ZdZG dd dZG dd dZG dd dZG dd dZG dd deZG dd deZdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd6d'd(Zd7d*d+Zd,d- Zd.d/ Zd0d1 Zd8d2d3Z d4d5 Z!dS )9zdprovides runtime services for templates, including Context,
Namespace, and various helper functions.    N)compat)
exceptions)utilc                   @   s   e Zd ZdZdd Zdd Zedd Zedd	 Zd
d Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zd'ddZdd Zdd  Zd!d" Zd#d$ Zd%d& ZdS )(ContextzProvides runtime namespace, output buffer, and various
    callstacks for templates.

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

    c                 K   sR   |g| _ || _| | _d | _d | _i | _tt	| | jd< t
  | _| jd< d S )Ncapturecaller)_buffer_stack_datacopy_kwargs_with_template_outputting_as_unicode
namespaces	functoolspartialr   CallerStackcaller_stack)selfbufferdata r   O/var/www/html/llm_bihealth/app/venv/lib/python3.9/site-packages/mako/runtime.py__init__   s    
zContext.__init__c                 C   s0   || _ |j| j}|r,tdd| d S )Nz%Reserved words passed to render(): %sz, )r   reserved_namesintersectionr	   r   ZNameConflictErrorjoin)r   tZillegal_namesr   r   r   _set_with_template.   s    zContext._set_with_templatec                 C   s   | j jS )z]Return the :class:`.TemplateLookup` associated
        with this :class:`.Context`.

        )r   lookupr   r   r   r   r   7   s    zContext.lookupc                 C   s
   | 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
   r   r   r   r   kwargs?   s    zContext.kwargsc                 C   s   | j | dS )zQPush a ``caller`` callable onto the callstack for
        this :class:`.Context`.N)r   append)r   r   r   r   r   push_callerU   s    zContext.push_callerc                 C   s   | j d= dS )zPPop a ``caller`` callable onto the callstack for this
        :class:`.Context`.N)r   r   r   r   r   
pop_caller[   s    zContext.pop_callerc                 C   s   t | j S )zAReturn a list of all names established in this :class:`.Context`.)listr	   keysr   r   r   r   r&   a   s    zContext.keysc                 C   s"   || j v r| j | S tj| S d S N)r	   builtins__dict__r   keyr   r   r   __getitem__f   s    

zContext.__getitem__c                 C   s   t  }| j| |jS )zUpush a capturing buffer onto this Context and return
        the new writer function.)r   FastEncodingBufferr   r!   writer   bufr   r   r   _push_writerl   s    zContext._push_writerc                 C   s   | j  }|| j d jfS )zupop the most recent capturing buffer from this Context
        and return the current writer after the pop.

        r#   )r   popr.   r/   r   r   r   _pop_buffer_and_writert   s    
zContext._pop_buffer_and_writerc                 C   s   |    dS )z*push a capturing buffer onto this Context.N)r1   r   r   r   r   _push_buffer}   s    zContext._push_bufferc                 C   s
   | j  S )z7pop the most recent capturing buffer from this Context.)r   r2   r   r   r   r   _pop_buffer   s    zContext._pop_bufferNc                 C   s   | j |tj||S )z+Return a value from this :class:`.Context`.)r	   getr(   r)   )r   r+   defaultr   r   r   r6      s    zContext.getc                 C   s   | j d | dS )zSWrite a string to this :class:`.Context` object's
        underlying output buffer.r#   Nr   r.   )r   stringr   r   r   r.      s    zContext.writec                 C   s   | j d jS )z#Return the current writer function.r#   r8   r   r   r   r   writer   s    zContext.writerc                 C   sJ   t t }| j|_| j |_| j|_| j|_| j|_| j|_| j	|_	|S r'   )
r   __new__r   r	   r
   r   r   r   r   r   )r   cr   r   r   _copy   s    
zContext._copyc                 C   s    |s| S |   }|j| |S )zCreate 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<   r   r   r   _locals   s
    zContext._localsc                 C   s6   |   }|j}|dd |dd |dd |S )zfcreate a new copy of this :class:`.Context`. with
        tokens related to inheritance state removed.r   Nparentnext)r=   r	   r2   )r   r<   xr   r   r   _clean_inheritance_tokens   s    z!Context._clean_inheritance_tokens)N)__name__
__module____qualname____doc__r   r   propertyr   r    r"   r$   r&   r,   r1   r3   r4   r5   r6   r.   r:   r=   r@   rD   r   r   r   r   r      s*   	

	
r   c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )r   c                 C   s
   d | _ d S r'   )
nextcallerr   r   r   r   r      s    zCallerStack.__init__c                 C   s   |   S r'   __bool__r   r   r   r   __nonzero__   s    zCallerStack.__nonzero__c                 C   s   t | r|  rdpdS )NTF)len_get_callerr   r   r   r   rL      s    zCallerStack.__bool__c                 C   s   | d S Nr#   r   r   r   r   r   rO      s    zCallerStack._get_callerc                 C   s   t |  |S r'   )getattrrO   r*   r   r   r   __getattr__   s    zCallerStack.__getattr__c                 C   s   | j pd }| | d | _ |S r'   )rJ   r!   )r   framer   r   r   _push_frame   s    

zCallerStack._push_framec                 C   s   |   | _d S r'   )r2   rJ   r   r   r   r   
_pop_frame   s    zCallerStack._pop_frameN)
rE   rF   rG   r   rM   rL   rO   rR   rT   rU   r   r   r   r   r      s   r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )		UndefinedzRepresents an undefined value in a template.

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

    c                 C   s   t dd S )NrV   )	NameErrorr   r   r   r   __str__   s    zUndefined.__str__c                 C   s   |   S r'   rK   r   r   r   r   rM      s    zUndefined.__nonzero__c                 C   s   dS )NFr   r   r   r   r   rL      s    zUndefined.__bool__N)rE   rF   rG   rH   rX   rM   rL   r   r   r   r   rV      s   rV    c                   @   sT   e Zd ZdZdd Zdd Zdd Zedd	 Zd
d Z	dd Z
dd Zdd ZdS )	LoopStackza stack for LoopContexts that implements the context manager protocol
    to automatically pop off the top of the stack on context exit
    c                 C   s
   g | _ d S r'   stackr   r   r   r   r      s    zLoopStack.__init__c                 C   s   |  | | jS r'   )_push_topr   iterabler   r   r   _enter   s    
zLoopStack._enterc                 C   s   |    | jS r'   )_popr^   r   r   r   r   _exit   s    zLoopStack._exitc                 C   s   | j r| j d S | S d S rP   r[   r   r   r   r   r^     s    
zLoopStack._topc                 C   s
   | j  S r'   )r\   r2   r   r   r   r   rb     s    zLoopStack._popc                 C   s&   t |}| jr| jd |_| j|S rP   )LoopContextr\   rA   r!   )r   r`   newr   r   r   r]     s    zLoopStack._pushc                 C   s   t dd S )NzNo loop context is established)r   RuntimeExceptionr*   r   r   r   rR     s    zLoopStack.__getattr__c                 C   s
   t | jS r'   )iterr^   r   r   r   r   __iter__  s    zLoopStack.__iter__N)rE   rF   rG   rH   r   ra   rc   rI   r^   rb   r]   rR   rh   r   r   r   r   rZ      s   
rZ   c                   @   sr   e Zd ZdZdd Zdd Zejdd Ze	dd	 Z
e	d
d Ze	dd Ze	dd Ze	dd Zdd ZdS )rd   a  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.
    c                 C   s   || _ d| _d | _d S Nr   )	_iterableindexrA   r_   r   r   r   r   3  s    zLoopContext.__init__c                 c   s$   | j D ]}|V  |  jd7  _qd S N   )rj   rk   )r   ir   r   r   rh   8  s    
zLoopContext.__iter__c                 C   s
   t | jS r'   )rN   rj   r   r   r   r   __len__=  s    zLoopContext.__len__c                 C   s   t | | j d S rl   )rN   rk   r   r   r   r   reverse_indexA  s    zLoopContext.reverse_indexc                 C   s
   | j dkS ri   )rk   r   r   r   r   firstE  s    zLoopContext.firstc                 C   s   | j t| d kS rl   )rk   rN   r   r   r   r   lastI  s    zLoopContext.lastc                 C   s   | j  S r'   )oddr   r   r   r   evenM  s    zLoopContext.evenc                 C   s   t | jd S )N   )boolrk   r   r   r   r   rs   Q  s    zLoopContext.oddc                 G   s   |st d|| jt|  S )z,Cycle through values as the loop progresses.z(You must provide values to cycle through)
ValueErrorrk   rN   )r   valuesr   r   r   cycleU  s    zLoopContext.cycleN)rE   rF   rG   rH   r   rh   r   Zmemoized_instancemethodro   rI   rp   rq   rr   rt   rs   ry   r   r   r   r   rd     s    





rd   c                   @   s   e Zd Zdd Zdd ZdS )_NSAttrc                 C   s
   || _ d S r'   )_NSAttr__parent)r   rA   r   r   r   r   ]  s    z_NSAttr.__init__c                 C   s6   | j }|r*t|j|r"t|j|S |j}qt|d S r'   )r{   hasattrmodulerQ   inheritsAttributeError)r   r+   nsr   r   r   rR   `  s    z_NSAttr.__getattr__N)rE   rF   rG   r   rR   r   r   r   r   rz   \  s   rz   c                   @   s   e Zd ZdZdddZdZdZdZdZdZ	dZ
dZejdd Zd	d
 Zdd Zdd Zedd Zdd Zdd Zdd Zdd ZdS )	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.

    NTc                 C   s.   || _ || _|| _|d ur*dd |D | _d S )Nc                 S   s   i | ]}|j |qS r   rE   .0r<   r   r   r   
<dictcomp>      z&Namespace.__init__.<locals>.<dictcomp>)namecontextr~   	callables)r   r   r   r   r~   populate_selfcalling_urir   r   r   r   {  s
    	zNamespace.__init__r   c                 C   s   t | 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`

        )rz   r   r   r   r   attr  s    zNamespace.attrc                 C   sH   | |f}|| j jv r | j j| S t|| j  || jd}|| j j|< |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   r   r   r   get_namespace  s    zNamespace.get_namespacec                 C   s   t | j|| jS )zReturn 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   )r   r   r   r   r   get_template  s    zNamespace.get_templatec                 K   s   | j j|fi |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   )r   r+   r    r   r   r   
get_cached  s    zNamespace.get_cachedc                 C   s   | j jS )zReturn the :class:`.Cache` object referenced
        by this :class:`.Namespace` object's
        :class:`.Template`.

        )templater   r   r   r   r   r     s    zNamespace.cachec                 K   s   t | j|| jfi | dS )z$Include a file at the given ``uri``.N)_include_filer   r   )r   r   r    r   r   r   include_file  s    zNamespace.include_filec                 C   s@   |D ]6}|dkr,|   D ]\}}|||< qqt| |||< qd S )N*)	_get_starrQ   )r   r?   lidentkvr   r   r   	_populate  s
    zNamespace._populatec                 c   s&   | j r"| j D ]}|| j | fV  qd S r'   )r   r*   r   r   r   r     s    
zNamespace._get_starc                 C   sL   || j v r| j | }n&| jr*t| j|}ntd| j|f t| || |S Nz!Namespace '%s' has no member '%s')r   r~   rQ   r   r   setattr)r   r+   valr   r   r   rR     s    
zNamespace.__getattr__)NNTN)rE   rF   rG   rH   r   r   r}   r   r   filenamer   r   r   Zmemoized_propertyr   r   r   r   rI   r   r   r   r   rR   r   r   r   r   r   j  s0       
		
 	
r   c                   @   sN   e Zd ZdZdddZedd Zedd	 Zed
d Zdd Z	dd Z
dS )r   z@A :class:`.Namespace` specific to a :class:`.Template` instance.NTc	                 C   s   || _ || _|| _|d ur*dd |D | _|d urNt|||| _| jjj| _n"|d urh|| _|jj| _nt	d|rt
|| j| d\}	}
d S )Nc                 S   s   i | ]}|j |qS r   r   r   r   r   r   r   ?  r   z.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)r   r   r   r   r   r   r~   r   r   Zlclcallable
lclcontextr   r   r   r   0  s     zTemplateNamespace.__init__c                 C   s   | j jS )zThe 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   r   r   r   r}   O  s    	zTemplateNamespace.modulec                 C   s   | j jS zhThe path of the filesystem file used for this
        :class:`.Namespace`'s module or template.
        )r   r   r   r   r   r   r   Z  s    zTemplateNamespace.filenamec                 C   s   | j jS )zThe 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   r   r   r   r   a  s    	zTemplateNamespace.uric                 #   sP    j r" j D ]}| j | fV  q fdd} jjjD ]}|||fV  q8d S )Nc                    s    j | }t| jS r'   )r   _get_def_callabler   r   r   )r+   	callable_r   r   r   r6   q  s    z(TemplateNamespace._get_star.<locals>.get)r   r   r}   Z_exports)r   r+   r6   r   r   r   r   r   l  s    
zTemplateNamespace._get_starc                 C   st   || j v r| j | }nN| j|r>| j|}t|| j}n&| jrRt| j|}nt	d| j
|f t| || |S r   )r   r   Zhas_defr   r   r   r   r~   rQ   r   r   r   r   r+   r   r   r   r   r   rR   x  s    
zTemplateNamespace.__getattr__)NNNNTN)rE   rF   rG   rH   r   rI   r}   r   r   r   rR   r   r   r   r   r   ,  s          





r   c                   @   s6   e Zd ZdZdddZedd Zdd	 Zd
d ZdS )ModuleNamespacez;A :class:`.Namespace` specific to a Python module instance.NTc           
      C   s^   || _ || _|| _|d ur*dd |D | _t|}|ddd  D ]}	t||	}qD|| _d S )Nc                 S   s   i | ]}|j |qS r   r   r   r   r   r   r     r   z,ModuleNamespace.__init__.<locals>.<dictcomp>.rm   )r   r   r~   r   
__import__splitrQ   r}   )
r   r   r   r}   r   r~   r   r   modtokenr   r   r   r     s    
zModuleNamespace.__init__c                 C   s   | j jS r   )r}   __file__r   r   r   r   r     s    zModuleNamespace.filenamec                 c   sj   | j r"| j D ]}|| j | fV  qt| jD ]8}|d dkr,t| j|}t|r,|t|| jfV  q,d S )Nr   _)r   dirr}   rQ   callabler   r   r   )r   r+   r   r   r   r   r     s    
zModuleNamespace._get_starc                 C   st   || j v r| j | }nNt| j|r>t| j|}t|| j}n&| jrRt| j|}ntd| j	|f t
| || |S r   )r   r|   r}   rQ   r   r   r   r~   r   r   r   r   r   r   r   rR     s    
zModuleNamespace.__getattr__)NNTN)	rE   rF   rG   rH   r   rI   r   r   rR   r   r   r   r   r     s       


r   c                    s    fdd}|S )zApply a caller_stack compatibility decorator to a plain
    Python function.

    See the example in :ref:`namespaces_python_modules`.

    c                    s>   | j   z" | g|R i |W | j   S | j   0 d S r'   )r   rT   rU   )r   argsr    funcr   r   wrap_stackframe  s    

z(supports_caller.<locals>.wrap_stackframer   )r   r   r   r   r   supports_caller  s    r   c                 O   sH   t |std|   z||i | W |  }n
|  }0 | S )zExecute 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   r   rf   r4   r5   getvalue)r   r   r   r    r0   r   r   r   r     s    r   c                    s    fdd}|S )Nc                    s    fdd}|S )Nc                    sP    fdd}zj dd  |_ W n ty4   Y n0 | g|R i |S )Nc                     s    g| R i |S r'   r   r   kw)r   	render_fnr   r   y  s    zB_decorate_toplevel.<locals>.decorate_render.<locals>.go.<locals>.y   )rE   r   )r   r   r   r   )fnr   )r   r   go  s    z7_decorate_toplevel.<locals>.decorate_render.<locals>.gor   r   r   r   )r   r   decorate_render  s    z+_decorate_toplevel.<locals>.decorate_renderr   )r   r   r   r   r   _decorate_toplevel  s    r   c                    s    fdd}|S )Nc                    s   |   fdd}|S )Nc                     s    g| R i |S r'   r   r   )r   decr   r   r      s    z5_decorate_inline.<locals>.decorate_render.<locals>.gor   r   r   r   )r   r   r     s    z)_decorate_inline.<locals>.decorate_renderr   )r   r   r   r   r   r   _decorate_inline  s    r   c                 K   s   t | ||}t|  |\}}t|| jfi |}|jrxz||fi | W q tyt   ||t }|sp Y q0 n||fi | dS )zPlocate the template from the given uri and include it in
    the current output.N)	r   r   rD   _kwargs_for_includer	   Zinclude_error_handler	Exceptionr   exception_as)r   r   r   r    r   r   ctxresultr   r   r   r     s    
r   c           
      C   s   |du rdS t | ||}| d }|}|jdur6|j}q$| d|i}td|j ||dd|_|j | jd< |jd< t|jd	d}|dur|||}|r|S t|jd
d}	|	dur|	|  |j|fS )zcalled by the _inherit method in template modules to set
    up the inheritance chain at the start of a template's
    execution.Nr   rB   self:%sFr   r   rA   local_mako_inheritZ_mako_generate_namespaces)	r   r~   r@   r   r   r	   rQ   r}   r   )
r   r   r   r   r   Zihr   r   retZgen_nsr   r   r   _inherit_from  s0    

r   c              
   C   sz   | j j}|d u r"td| j j |||}z||W S  tjyt } z ttt	
 |W Y d }~n
d }~0 0 d S )Nz.Template '%s' has no TemplateLookup associated)r   r   r   ZTemplateLookupExceptionr   Z
adjust_urir   ZTopLevelLookupExceptionstrr   r   )r   r   Z
relativetor   er   r   r   r   <  s     
r   c                 C   s^   |d u rt d|j | |dd}| | jd< | jd< t|jdrT|j|| }|rT|S |j| fS )Nr   Fr   r   r   r   )r   r   r	   r|   r}   r   r   )r   r   r   r   r   r   r   r   L  s    r   Fc                 C   sl   |rt  }nt j| j| jd}t|fi |}||_||  t| ||g|R i t|| |	 
 S )z^create a Context and return the string
    output of the given template and template callable.)encodingerrors)r   r-   output_encodingencoding_errorsr   r   r   _render_context_kwargs_for_callabler5   r   )r   r   r   r   Z
as_unicoder0   r   r   r   r   _render\  s$    

r   c                 C   sj   t | }|d r|S |d dd |dd D  }i }|D ](}|dkr<||v r<||vr<|| ||< q<|S )Nru   r   c                 S   s   g | ]}|d ur|qS r'   r   r   r   r   r   r   
<listcomp>{  r   z(_kwargs_for_callable.<locals>.<listcomp>rm      r   r   Zinspect_getargspec)r   r   argspec	namedargsr    argr   r   r   r   t  s    
r   c                 K   sZ   t | }|d dd |dd D  }|D ](}|dkr,||v r,||vr,|| ||< q,|S )Nr   c                 S   s   g | ]}|d ur|qS r'   r   r   r   r   r   r     r   z'_kwargs_for_include.<locals>.<listcomp>rm   r   r   r   )r   r   r    r   r   r   r   r   r   r     s    
r   c                 O   s\   dd l m} t| |js8t|| \}}t||||d n t|| j\}}t||||d d S )Nr   )r   r    )Zmako.templater   
isinstanceZDefTemplater   _exec_templaterA   )tmplr   r   r   r    r   Zinheritr   r   r   r   r     s    r   c                 C   s   |j }|dur||js|jr|z| |g|R i | W q tyV   t||t  Y q   t d }t||| Y q0 n| |g|R i | dS )zexecute 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   Zformat_exceptionserror_handlerr   _render_errorr   r   sysexc_info)r   r   r   r    r   r   r   r   r   r     s    r   c                 C   s   | j r>|  ||}|st \}}}|r8|r8||q|nXt }|jrbt g|j	d d < nt|j
|jg|j	d d < || |j||d d S )N)error)r   r   r   with_tracebackr   Zhtml_error_templater   r   r-   r   r   r   r   Zrender_context)r   r   r   r   tpvaluetberror_templater   r   r   r     s"    
r   )N)F)NN)"rH   r(   r   r   Zmakor   r   r   r   r%   r   rV   	UNDEFINEDZSTOP_RENDERINGrZ   rd   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   sB    -(A C]: 

	
