
    gl                     p   S r SSKrSSKrSSKrSSKJr  SSKJr  SSKJr   " S S5      r " S S	\	5      r
 " S
 S5      r\" 5       rSr " S S5      r " S S5      r " S S5      r " S S5      r " S S\5      r " S S\5      rS rS rS rS rS rS rS rS'S  jrS(S! jrS" rS# rS$ rS)S% jr S& r!g)*zdprovides runtime services for templates, including Context,
Namespace, and various helper functions.    N)compat)
exceptions)utilc                       \ rS rSrSrS rS r\S 5       r\S 5       r	S r
S rS	 rS
 rS rS rS rS rSS jrS rS rS rS rS rSrg)Context   zProvides runtime namespace, output buffer, and various
callstacks for templates.

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

c                     U/U l         X l        UR                  5       U l        S U l        S U l        0 U l        [        R                  " [        U 5      U R                  S'   [        5       =U l        U R                  S'   g )Ncapturecaller)_buffer_stack_datacopy_kwargs_with_template_outputting_as_unicode
namespaces	functoolspartialr
   CallerStackcaller_stack)selfbufferdatas      T/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/mako/runtime.py__init__Context.__init__   sl    $X
yy{"&*# !* 1 1'4 @

9 4?=@DJJx0    c                     Xl         UR                  R                  U R                  5      nU(       a(  [        R
                  " SSR                  U5      -  5      eg )Nz%Reserved words passed to render(): %sz, )r   reserved_namesintersectionr   r   NameConflictErrorjoin)r   tillegal_namess      r   _set_with_templateContext._set_with_template.   sQ    ((55djjA..7))M*+  r   c                 .    U R                   R                  $ )zMReturn the :class:`.TemplateLookup` associated
with this :class:`.Context`.

)r   lookupr   s    r   r(   Context.lookup7   s     "")))r   c                 6    U R                   R                  5       $ )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)   s    r   kwargsContext.kwargs?   s    ( ||  ""r   c                 :    U R                   R                  U5        g)zIPush a ``caller`` callable onto the callstack for
this :class:`.Context`.N)r   append)r   r   s     r   push_callerContext.push_callerU   s     	  (r   c                     U R                   S	 g)zHPop a ``caller`` callable onto the callstack for this
:class:`.Context`.N)r   r)   s    r   
pop_callerContext.pop_caller[   s     b!r   c                 H    [        U R                  R                  5       5      $ )zAReturn a list of all names established in this :class:`.Context`.)listr   keysr)   s    r   r8   Context.keysa   s     DJJOO%&&r   c                 d    XR                   ;   a  U R                   U   $ [        R                  U   $ N)r   builtins__dict__r   keys     r   __getitem__Context.__getitem__f   s+    **::c?"$$S))r   c                 z    [         R                  " 5       nU R                  R                  U5        UR                  $ )zMpush a capturing buffer onto this Context and return
the new writer function.)r   FastEncodingBufferr   r/   writer   bufs     r   _push_writerContext._push_writerl   s0     %%'!!#&yyr   c                 j    U R                   R                  5       nXR                   S   R                  4$ )zepop the most recent capturing buffer from this Context
and return the current writer after the pop.

r3   )r   poprD   rE   s     r   _pop_buffer_and_writerContext._pop_buffer_and_writert   s2       $$&&&r*0000r   c                 $    U R                  5         g)z*push a capturing buffer onto this Context.N)rG   r)   s    r   _push_bufferContext._push_buffer}   s     	r   c                 6    U R                   R                  5       $ )z7pop the most recent capturing buffer from this Context.)r   rJ   r)   s    r   _pop_bufferContext._pop_buffer   s     !!%%''r   Nc                 t    U R                   R                  U[        R                  R                  X5      5      $ )z+Return a value from this :class:`.Context`.)r   getr<   r=   )r   r?   defaults      r   rT   Context.get   s*     zz~~c8#4#4#8#8#FGGr   c                 @    U R                   S   R                  U5        g)zKWrite a string to this :class:`.Context` object's
underlying output buffer.r3   Nr   rD   )r   strings     r   rD   Context.write   s     	2$$V,r   c                 4    U R                   S   R                  $ )z#Return the current writer function.r3   rX   r)   s    r   writerContext.writer   s     !!"%+++r   c                 B   [         R                  [         5      nU R                  Ul        U R                  R	                  5       Ul        U R
                  Ul        U R                  Ul        U R                  Ul        U R                  Ul        U R                  Ul	        U$ r;   )
r   __new__r   r   r   r   r   r   r   r   )r   cs     r   _copyContext._copy   ss    OOG$,,**//#LL	..#'#>#> **r   c                 n    U(       d  U $ U R                  5       nUR                  R                  U5        U$ )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.


)ra   r   update)r   dr`   s      r   _localsContext._locals   s,     KJJL	qr   c                     U R                  5       nUR                  nUR                  SS5        UR                  SS5        UR                  SS5        U$ )z^create a new copy of this :class:`.Context`. with
tokens related to inheritance state removed.r   Nparentnext)ra   r   rJ   )r   r`   xs      r   _clean_inheritance_tokens!Context._clean_inheritance_tokens   sG     JJLGG	fd	h	fdr   )r   r   r   r   r   r   r   r;   )__name__
__module____qualname____firstlineno____doc__r   r%   propertyr(   r,   r0   r4   r8   r@   rG   rK   rN   rQ   rT   rD   r\   ra   rf   rl   __static_attributes__ r   r   r   r      s    A" * * # #*)"'
*1
(
H
-,
	"	r   r   c                   >    \ rS rSrS rS rS rS rS rS r	S r
S	rg
)r      c                     S U l         g r;   
nextcallerr)   s    r   r   CallerStack.__init__   s	    r   c                 "    U R                  5       $ r;   __bool__r)   s    r   __nonzero__CallerStack.__nonzero__       }}r   c                 j    [        U 5      =(       a    U R                  5       =(       a    S=(       d    S$ )NTF)len_get_callerr)   s    r   r~   CallerStack.__bool__   s$    4y8T--/8DAEAr   c                     U S   $ Nr3   ru   r)   s    r   r   CallerStack._get_caller   s     Bxr   c                 6    [        U R                  5       U5      $ r;   )getattrr   r>   s     r   __getattr__CallerStack.__getattr__   s    t'')3//r   c                 `    U R                   =(       d    S nU R                  U5        S U l         U$ r;   )rz   r/   )r   frames     r   _push_frameCallerStack._push_frame   s(    '4Er   c                 .    U R                  5       U l        g r;   )rJ   rz   r)   s    r   
_pop_frameCallerStack._pop_frame   s    ((*r   ry   N)rn   ro   rp   rq   r   r   r~   r   r   r   r   rt   ru   r   r   r   r      s&    B
0%r   r   c                   *    \ rS rSrSrS rS rS rSrg)	Undefined   zRepresents an undefined value in a template.

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

c                     [        S5      e)Nr   )	NameErrorr)   s    r   __str__Undefined.__str__   s    $$r   c                 "    U R                  5       $ r;   r}   r)   s    r   r   Undefined.__nonzero__   r   r   c                     g)NFru   r)   s    r   r~   Undefined.__bool__   s    r   ru   N)	rn   ro   rp   rq   rr   r   r   r~   rt   ru   r   r   r   r      s    %r   r    c                   R    \ rS rSrSrS rS rS r\S 5       r	S r
S rS	 rS
 rSrg)	LoopStack   za stack for LoopContexts that implements the context manager protocol
to automatically pop off the top of the stack on context exit
c                     / U l         g r;   stackr)   s    r   r   LoopStack.__init__   s	    
r   c                 <    U R                  U5        U R                  $ r;   )_push_topr   iterables     r   _enterLoopStack._enter   s    

8yyr   c                 :    U R                  5         U R                  $ r;   )_popr   r)   s    r   _exitLoopStack._exit   s    		yyr   c                 F    U R                   (       a  U R                   S   $ U $ r   r   r)   s    r   r   LoopStack._top  s    ::::b>!Kr   c                 6    U R                   R                  5       $ r;   )r   rJ   r)   s    r   r   LoopStack._pop  s    zz~~r   c                     [        U5      nU R                  (       a  U R                  S   Ul        U R                  R                  U5      $ r   )LoopContextr   ri   r/   )r   r   news      r   r   LoopStack._push  s7    (#::BCJzz  %%r   c                 .    [         R                  " S5      e)NzNo loop context is established)r   RuntimeExceptionr>   s     r   r   LoopStack.__getattr__  s    ))*JKKr   c                 ,    [        U R                  5      $ r;   )iterr   r)   s    r   __iter__LoopStack.__iter__  s    DIIr   r   N)rn   ro   rp   rq   rr   r   r   r   rs   r   r   r   r   r   rt   ru   r   r   r   r      s?       &Lr   r   c                       \ rS rSrSrS rS r\R                  S 5       r	\
S 5       r\
S 5       r\
S 5       r\
S	 5       r\
S
 5       rS rSrg)r   i  an  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                 ,    Xl         SU l        S U l        g Nr   	_iterableindexri   r   s     r   r   LoopContext.__init__3  s    !
r   c              #   d   #    U R                    H  nUv   U =R                  S-  sl        M     g 7fN   )r   r   )r   is     r   r   LoopContext.__iter__8  s%     AGJJ!OJ  s   .0c                 ,    [        U R                  5      $ r;   )r   r   r)   s    r   __len__LoopContext.__len__=  s    4>>""r   c                 8    [        U 5      U R                  -
  S-
  $ r   )r   r   r)   s    r   reverse_indexLoopContext.reverse_indexA  s    4y4::%))r   c                      U R                   S:H  $ r   )r   r)   s    r   firstLoopContext.firstE  s    zzQr   c                 8    U R                   [        U 5      S-
  :H  $ r   )r   r   r)   s    r   lastLoopContext.lastI  s    zzSY]**r   c                 $    U R                   (       + $ r;   )oddr)   s    r   evenLoopContext.evenM  s    88|r   c                 2    [        U R                  S-  5      $ )N   )boolr   r)   s    r   r   LoopContext.oddQ  s    DJJN##r   c                 Z    U(       d  [        S5      eXR                  [        U5      -     $ )z,Cycle through values as the loop progresses.z(You must provide values to cycle through)
ValueErrorr   r   )r   valuess     r   cycleLoopContext.cycleU  s'    GHHjj3v;.//r   r   N)rn   ro   rp   rq   rr   r   r   r   memoized_instancemethodr   rs   r   r   r   r   r   r   rt   ru   r   r   r   r     s    ,

 
!!# "# * *   + +   $ $0r   r   c                        \ rS rSrS rS rSrg)_NSAttri\  c                     Xl         g r;   )_NSAttr__parent)r   ri   s     r   r   _NSAttr.__init__]  s    r   c                     U R                   nU(       aF  [        UR                  U5      (       a  [        UR                  U5      $ UR                  nU(       a  MF  [        U5      er;   )r   hasattrmoduler   inheritsAttributeError)r   r?   nss      r   r   _NSAttr.__getattr__`  sM    ]]ryy#&&ryy#..[[	 b
 S!!r   )__parentN)rn   ro   rp   rq   r   r   rt   ru   r   r   r   r   \  s    "r   r   c                       \ rS rSrSr    SS jrSrSr Sr Sr	 Sr
 Sr Sr\R                  S 5       rS rS rS	 r\S
 5       rS rS rS rS rSrg)	Namespaceij  ak  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.

Nc                 ~    Xl         X l        X@l        Ub#  U Vs0 s H  owR                  U_M     snU l        g g s  snf r;   )namecontextr   rn   	callables)r   r   r   r   r   populate_selfcalling_urir`   s           r   r   Namespace.__init__{  s=     	  5>?Yjj!mY?DN !?s   :ru   c                     [        U 5      $ )zAccess 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)   s    r   attrNamespace.attr  s     t}r   c                     X4nX R                   R                  ;   a  U R                   R                  U   $ [        UU R                   R                  5       UU R                  S9nX0R                   R                  U'   U$ )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   TemplateNamespacera   _templateuri)r   urir?   r   s       r   get_namespaceNamespace.get_namespace  sr    ( k,,)))<<**3//LL ))	
 (*$	r   c                 B    [        U R                  XR                  5      $ )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  s     r   get_templateNamespace.get_template  s      c3D3DEEr   c                 <    U R                   R                  " U40 UD6$ )aX  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>``.

)cacherT   )r   r?   r,   s      r   
get_cachedNamespace.get_cached  s     zz~~c,V,,r   c                 .    U R                   R                  $ )zgReturn the :class:`.Cache` object referenced
by this :class:`.Namespace` object's
:class:`.Template`.

)templater  r)   s    r   r  Namespace.cache  s     }}"""r   c                 F    [        U R                  XR                  40 UD6  g)z$Include a file at the given ``uri``.N)_include_filer   r  )r   r  r,   s      r   include_fileNamespace.include_file  s     	dllC):):EfEr   c                 z    U H5  nUS:X  a  U R                  5        H	  u  pEXQU'   M     M(  [        X5      X'   M7     g )N*)	_get_starr   )r   re   lidentkvs         r   	_populateNamespace._populate  s;    E| NN,DAaD - #4/ r   c              #   z   #    U R                   (       a&  U R                    H  nXR                   U   4v   M     g g 7fr;   )r   r>   s     r   r  Namespace._get_star  s1     >>~~NN3/00 & s   9;c                     XR                   ;   a  U R                   U   nOFU R                  (       a  [        U R                  U5      nO[        SU R                  < SU< S35      e[        XU5        U$ NzNamespace 'z' has no member '')r   r   r   r   r   setattr)r   r?   vals      r   r   Namespace.__getattr__  s[    .. ..%C]]$---C 7;yy#F  	3
r   )r   r   r   r   NNTN)rn   ro   rp   rq   rr   r   r   r   r  r   filenamer  r  r   memoized_propertyr   r  r	  r  rs   r  r  r  r  r   rt   ru   r   r   r   r   j  s    & @ IF H
 G H C L	  @F- # #F
01

r   r   c                   j    \ rS rSrSr      SS jr\S 5       r\S 5       r\S 5       r	S r
S	 rS
rg)r  i,  z@A :class:`.Namespace` specific to a :class:`.Template` instance.Nc	                    Xl         X l        X`l        Ub"  U V	s0 s H  oR                  U	_M     sn	U l        Ub7  [        X$U5      U l        U R                  R                  R                  U l	        O0Ub"  X0l        UR                  R                  U l	        O[        S5      eU(       a  [        X R                  U S9u  pg g s  sn	f )Nz 'template' argument is required.)self_ns)r   r   r   rn   r   r  r  r   _template_urir  	TypeError_populate_self_namespace)r   r   r   r  r  r   r   r   r   r`   lclcallable
lclcontexts               r   r   TemplateNamespace.__init__0  s     	  5>?Yjj!mY?DN",W;ODM $ 4 4 B BD!$M ( = =D>??&>'#K  @s   Cc                 .    U R                   R                  $ )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)   s    r   r   TemplateNamespace.moduleO  s     }}###r   c                 .    U R                   R                  $ zXThe path of the filesystem file used for this
:class:`.Namespace`'s module or template.
)r  r(  r)   s    r   r(  TemplateNamespace.filenameZ  s    
 }}%%%r   c                 .    U R                   R                  $ )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)   s    r   r  TemplateNamespace.uria  s     }}   r   c              #      ^ #    T R                   (       a&  T R                    H  nUT R                   U   4v   M     U 4S jnT R                  R                  R                   H  nX2" U5      4v   M     g 7f)Nc                 |   > TR                   R                  U 5      n[        R                  " UTR                  5      $ r;   )r  _get_def_callabler   r   r   )r?   	callable_r   s     r   rT   (TemplateNamespace._get_star.<locals>.getq  s.    77<I$$Y==r   )r   r  r   _exports)r   r?   rT   r  s   `   r   r  TemplateNamespace._get_starl  s^     >>~~DNN3/00 &	> %%..Ac!f+ /s   A1A4c                    XR                   ;   a  U R                   U   nOU R                  R                  U5      (       a<  U R                  R                  U5      n[        R
                  " X0R                  5      nOFU R                  (       a  [        U R                  U5      nO[        SU R                  < SU< S35      e[        XU5        U$ r"  )r   r  has_defr<  r   r   r   r   r   r   r   r$  r   r?   r%  r=  s       r   r   TemplateNamespace.__getattr__x  s    .. ..%C]]""3''77<I##I||<C]]$---C !7;yy#F  	3
r   )r  r   r   r   r   r  )NNNNTN)rn   ro   rp   rq   rr   r   rs   r   r(  r  r  r   rt   ru   r   r   r  r  ,  sd    J > $ $ & & ! !
r   r  c                   F    \ rS rSrSr    S	S jr\S 5       rS rS r	Sr
g)
ModuleNamespacei  z;A :class:`.Namespace` specific to a Python module instance.Nc                     Xl         X l        XPl        Ub"  U Vs0 s H  oR                  U_M     snU l        [        U5      n	UR                  S5      SS   H  n
[        X5      n	M     Xl        g s  snf )N.r   )	r   r   r   rn   r   
__import__splitr   r   )r   r   r   r   r   r   r   r   r`   modtokens              r   r   ModuleNamespace.__init__  sn     	  5>?Yjj!mY?DN \\#&qr*E#%C + @s   A0c                 .    U R                   R                  $ r6  )r   __file__r)   s    r   r(  ModuleNamespace.filename  s    
 {{###r   c              #   ^  #    U R                   (       a%  U R                    H  nXR                   U   4v   M     [        U R                  5       HZ  nUS   S:w  d  M  [        U R                  U5      n[	        U5      (       d  M6  U[
        R                  " X R                  5      4v   M\     g 7f)Nr   _)r   dirr   r   callabler   r   r   )r   r?   r=  s      r   r  ModuleNamespace._get_star  s     >>~~NN3/00 &t{{#C1v}#DKK5	I&&y00LLIII	 $s   AB-$B-)B-c                    XR                   ;   a  U R                   U   nO[        U R                  U5      (       a7  [        U R                  U5      n[        R
                  " X0R                  5      nOFU R                  (       a  [        U R                  U5      nO[        SU R                  < SU< S35      e[        XU5        U$ r"  )r   r   r   r   r   r   r   r   r   r   r$  rC  s       r   r   ModuleNamespace.__getattr__  s    .. ..%CT[[#&&S1I##I||<C]]$---C 7;yy#F  	3
r   )r   r   r   r   r   r'  )rn   ro   rp   rq   rr   r   rs   r(  r  r   rt   ru   r   r   rF  rF    s7    E * $ $Jr   rF  c                    ^  U 4S jnU$ )zApply a caller_stack compatibility decorator to a plain
Python function.

See the example in :ref:`namespaces_python_modules`.

c                    > U R                   R                  5          T" U /UQ70 UD6U R                   R                  5         $ ! U R                   R                  5         f = fr;   )r   r   r   )r   argsr,   funcs      r   wrap_stackframe(supports_caller.<locals>.wrap_stackframe  sQ    ((*	.1$1&1  ++-G  ++-s   A Aru   )r[  r\  s   ` r   supports_callerr^    s    . r   c                     [        U5      (       d  [        R                  " S5      eU R                  5          U" U0 UD6  U R	                  5       nUR                  5       $ ! U R	                  5       nf = f)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)))rT  r   r   rN   rQ   getvalue)r   r=  rZ  r,   rF   s        r   r
   r
     st     I))A
 	
 $4"6"!!#<<> !!#s   A   A2c                    ^  U 4S jnU$ )Nc                    >^  UU 4S jnU$ )Nc                    >^  U U4S jn TR                   SS  Ul         T" U5      " T /UQ70 UD6$ ! [         a     Nf = f)Nc                     > T" T/U Q70 UD6$ r;   ru   )rZ  kwr   	render_fns     r   yB_decorate_toplevel.<locals>.decorate_render.<locals>.go.<locals>.y  s     646266r      )rn   r.  )r   rZ  re  rg  fnrf  s   `   r   go7_decorate_toplevel.<locals>.decorate_render.<locals>.go  sP    7&//3
 a5.4.2..  s   1 
>>ru   )rf  rk  rj  s   ` r   decorate_render+_decorate_toplevel.<locals>.decorate_render  s    		/ 	r   ru   )rj  rm  s   ` r   _decorate_toplevelro    s     r   c                    ^ ^ U U4S jnU$ )Nc                 (   >^ T" U 5      mUU4S jnU$ )Nc                     > T" T/U Q70 UD6$ r;   ru   )rZ  re  r   decs     r   rk  5_decorate_inline.<locals>.decorate_render.<locals>.go   s    w,,,,r   ru   )rf  rk  rs  r   rj  s     @r   rm  )_decorate_inline.<locals>.decorate_render  s    m	- 	r   ru   )r   rj  rm  s   `` r   _decorate_inlinerv    s     r   c                 D   [        XU5      n[        U R                  5       U5      u  pV[        XPR                  40 UD6nUR
                  (       a   U" U40 UD6  gU" U40 UD6  g! [         a0    UR                  U[        R                  " 5       5      nU(       d  e  gf = f)zLlocate the template from the given uri and include it in
the current output.N)	r  r/  rl   _kwargs_for_includer   include_error_handler	Exceptionr   exception_as)r   r  r   r,   r  r=  ctxresults           r   r  r    s      k:H/))+XY !MMDVDF%%	c$V$ 	#    	33C9L9L9NOF 	s   	A% %7BBc                    Uc  g[        XU5      nU S   nUnUR                  b  UR                  nUR                  b  M  U R                  SU05      n[        SUR                  -  UUSS9Ul        UR                  =U R
                  S'   UR
                  S'   [        UR                  S	S5      nUb  U" X65      nU(       a  U$ [        UR                  S
S5      n	U	b  U	" U 5        UR                  U4$ )zycalled by the _inherit method in template modules to set
up the inheritance chain at the start of a template's
execution.Nr   rj   self:%sFr  r   ri   local_mako_inherit_mako_generate_namespaces)	r  r   rf   r  r  r   r   r   r=  )
r   r  r   r  r,  ihr1  r=  retgen_nss
             r   _inherit_fromr    s    
 {k:HfoG	B
++
![[ ++
!&".J#HLL 	BK ;=++EGMM(j..w7$?I-JX__&A4HFw
++r   c                 r   U R                   R                  nUc-  [        R                  " SU R                   R                  -  5      eUR                  X5      n UR                  U5      $ ! [        R                   a8  n[        R                  " [        [        R                  " 5       5      5      UeS nAff = f)Nz.Template '%s' has no TemplateLookup associated)r   r(   r   TemplateLookupExceptionr  
adjust_urir	  TopLevelLookupExceptionstrr   r{  )r   r  
relativetor(   es        r   r  r  <  s    ##**F~00<$$(()
 	
 

C
,C""3''-- 00##%&
	s   A* *B6>3B11B6c                    Uc  [        SUR                  -  U USS9nU=U R                  S'   U R                  S'   [        UR                  S5      (       a$  UR                  R                  X5      nU(       a  U$ UR                  U 4$ )Nr  Fr  r   r  r  )r  r  r   r   r   r  r=  )r   r  r,  r  s       r   r/  r/  L  s    #$	
 6=<GMM&GMM'2x00oo++H>J((r   c                 D   U(       a  [         R                  " 5       nO)[         R                  " U R                  U R                  S9n[	        U40 UD6nXFl        UR                  U 5        [        U UU/UQ70 [        X5      D6  UR                  5       R                  5       $ )zZcreate a Context and return the string
output of the given template and template callable.)encodingerrors)r   rC   output_encodingencoding_errorsr   r   r%   _render_context_kwargs_for_callablerQ   r`  )r  r=  rZ  r   
as_unicoderF   r   s          r   _renderr  \  s     %%'%%--h6N6N
 c"T"G%/"x( 
	
 y
/  ))++r   c                     [         R                  " U 5      nUS   (       a  U$ US   USS  Vs/ s H	  o3c  M  UPM     sn-   n0 nU H  nUS:w  d  M  Xa;   d  M  Xe;  d  M  X   XV'   M!     U$ s  snf )Nr   r   r      r   r   inspect_getargspec)r=  r   argspecr  	namedargsr,   args          r   r  r  t  sy    ''	2Gqz 
1GAaGGIF)0A)FK  M Hs
   A,A,c                     [         R                  " U 5      nUS   USS  Vs/ s H	  oDc  M  UPM     sn-   nU H  nUS:w  d  M  Xa;   d  M  Xb;  d  M  X   X&'   M!     U$ s  snf )Nr   r   r  r   r  )r=  r   r,   r  r  r  r  s          r   rx  rx    sf    ''	2G
1GAaGGI)0A)FK  M	 Hs
   AAc                     SS K Jn  [        XR                  5      (       d  [	        X 5      u  pg[        XgX4S9  g [	        X R                  5      u  pg[        XX4S9  g )Nr   )rZ  r,   )mako.templater  
isinstanceDefTemplater/  _exec_templateri   )tmplr=  r   rZ  r,   r  inheritr1  s           r   r  r    sL    $ d0011 8 GwE !9++ NyDr   c                 D   UR                   nUb0  UR                  (       d  UR                  (       a   U " U/UQ70 UD6  gU " U/UQ70 UD6  g! [         a"    [	        XA[
        R                  " 5       5         g  [        R                  " 5       S   n[	        XAU5         g= f)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   format_exceptionserror_handlerrz  _render_errorr   r{  sysexc_info)r=  r   rZ  r,   r  r  s         r   r  r    s     %%H""h&<&<	0g/// 	'+D+F+  	D(V-@-@-BC	0q!A(Q/s   A )B8%Bc                    U R                   (       aR  U R                  X5      nU(       d9  [        R                  " 5       u  pEnU(       a  U(       a  UR                  U5      eUeg [        R
                  " 5       nUR                  (       a$  [        R                  " 5       /UR                  S S & O9[        R                  " UR                  UR                  5      /UR                  S S & UR                  U5        UR                  XS9  g )N)error)r  r  r  with_tracebackr   html_error_templater   r   rC   r   r  r  r%   render_context)r  r   r  r}  tpvaluetberror_templates           r   r  r    s    ''7LLNMBr**2..  $779))(,(?(?(A'BG!!!$ ''"22"22(G!!!$ 	"">2%%g%;r   r;   )F)NN)"rr   r<   r   r  makor   r   r   r   r7   r   r   	UNDEFINEDSTOP_RENDERINGr   r   r   r   r  rF  r^  r
   ro  rv  r  r  r  r/  r  r  rx  r  r  r  ru   r   r   <module>r     s   ,   
   i iX%$ %8 ( K	% %P>0 >0B" " DZ	 Zz7i 7t$*$	!(,@ ) ,0E,.<r   