� ���g�l���dZddlZddlZddlZddlmZddlmZddlmZGd�d��ZGd�d e ��Z Gd �d ��Z e ��Z d Z Gd �d��ZGd�d��ZGd�d��ZGd�d��ZGd�de��ZGd�de��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd(d �Zd)d"�Zd#�Zd$�Zd%�Zd*d&�Z d'�Z!dS)+zdprovides runtime services for templates, including Context, Namespace, and various helper functions.�N)�compat)� exceptions)�utilc��eZdZdZd�Zd�Zed���Zed���Zd�Z d�Z d�Z d �Z d �Z d �Zd �Zd �Zdd�Zd�Zd�Zd�Zd�Zd�ZdS)�Contextz�Provides runtime namespace, output buffer, and various callstacks for templates. See :ref:`runtime_toplevel` for detail on the usage of :class:`.Context`. c ���|g|_||_|���|_d|_d|_i|_tjt|��|jd<t��x|_ |jd<dS)N�capture�caller) � _buffer_stack�_data�copy�_kwargs�_with_template�_outputting_as_unicode� namespaces� functools�partialr � CallerStack� caller_stack)�self�buffer�datas �\/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/mako/runtime.py�__init__zContext.__init__st��$�X����� ��y�y�{�{�� �"���&*��#����!*� 1�'�4� @� @�� �9��4?�=�=�@���D�J�x�0�0�0�c��||_|j�|j��}|r*t jdd�|��z���dS)Nz%Reserved words passed to render(): %sz, )r�reserved_names� intersectionr r�NameConflictError�join)r�t� illegal_namess r�_set_with_templatezContext._set_with_template.s`������(�5�5�d�j�A�A� � � ��.�7��)�)�M�*�*�+��� � � rc��|jjS)z]Return the :class:`.TemplateLookup` associated with this :class:`.Context`. )r�lookup�rs rr%zContext.lookup7s�� �"�)�)rc�4�|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 r&s r�kwargszContext.kwargs?s��(�|� � �"�"�"rc�:�|j�|��dS)zQPush a ``caller`` callable onto the callstack for this :class:`.Context`.N)r�append)rr s r� push_callerzContext.push_callerUs!�� �� � ��(�(�(�(�(rc��|jd=dS)zPPop a ``caller`` callable onto the callstack for this :class:`.Context`.�����N)rr&s r� pop_callerzContext.pop_caller[s�� � �b� !� !� !rc�N�t|j�����S)zAReturn a list of all names established in this :class:`.Context`.)�listr �keysr&s rr1z Context.keysas���D�J�O�O�%�%�&�&�&rc�R�||jvr |j|Stj|S�N)r �builtins�__dict__�r�keys r� __getitem__zContext.__getitem__fs)�� �$�*� � ��:�c�?� "��$�S�)� )rc�j�tj��}|j�|��|jS)zUpush a capturing buffer onto this Context and return the new writer function.)r�FastEncodingBufferr r*�write�r�bufs r� _push_writerzContext._push_writerls1���%�'�'�� ��!�!�#�&�&�&��y�rc�\�|j���}||jdjfS)zupop the most recent capturing buffer from this Context and return the current writer after the pop. r-)r �popr;r<s r�_pop_buffer_and_writerzContext._pop_buffer_and_writerts.�� � �$�$�&�&���D�&�r�*�0�0�0rc�.�|���dS)z*push a capturing buffer onto this Context.N)r>r&s r� _push_bufferzContext._push_buffer}s�� �������rc�4�|j���S)z7pop the most recent capturing buffer from this Context.)r r@r&s r� _pop_bufferzContext._pop_buffer�s���!�%�%�'�'�'rNc�t�|j�|tj�||����S)z+Return a value from this :class:`.Context`.)r �getr4r5)rr7�defaults rrGz Context.get�s-���z�~�~�c�8�#4�#8�#8��g�#F�#F�G�G�Grc�F�|jd�|��dS)zSWrite a string to this :class:`.Context` object's underlying output buffer.r-N�r r;)r�strings rr;z Context.write�s&�� ��2��$�$�V�,�,�,�,�,rc�&�|jdjS)z#Return the current writer function.r-rJr&s r�writerzContext.writer�s���!�"�%�+�+rc��t�t��}|j|_|j���|_|j|_|j|_|j|_|j|_|j |_ |Sr3) r�__new__r r r rrrrr)r�cs r�_copyz Context._copy�sg�� �O�O�G� $� $���,����*�/�/�#�#����L�� ��.���#'�#>�� ���� ��*����rc�j�|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. )rQr �update)r�drPs r�_localszContext._locals�s7��� ��K� �J�J�L�L�� ����q�����rc���|���}|j}|�dd��|�dd��|�dd��|S)zfcreate a new copy of this :class:`.Context`. with tokens related to inheritance state removed.rN�parent�next)rQr r@)rrP�xs r�_clean_inheritance_tokensz!Context._clean_inheritance_tokens�sY�� �J�J�L�L�� �G�� ���f�d���� ���h����� ���f�d�����rr3)�__name__� __module__� __qualname__�__doc__rr#�propertyr%r(r+r.r1r8r>rArCrErGr;rMrQrUrZ�rrrrsP��������A�A�A�"����*�*��X�*��#�#��X�#�*)�)�)� "�"�"� '�'�'� *�*�*� ���1�1�1���� (�(�(� H�H�H�H� -�-�-� ,�,�,� � � ����" � � � � rrc�8�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z dS) rc��d|_dSr3)� nextcallerr&s rrzCallerStack.__init__�s ������rc�*�|���Sr3��__bool__r&s r� __nonzero__zCallerStack.__nonzero__�����}�}���rc�P�t|��r|���rdpdS)NTF)�len� _get_callerr&s rrfzCallerStack.__bool__�s)���4�y�y�8�T�-�-�/�/�8�D�A�E�Arc��|dS�Nr-r`r&s rrkzCallerStack._get_caller�s ���B�x�rc�F�t|���|��Sr3)�getattrrkr6s r� __getattr__zCallerStack.__getattr__�s���t�'�'�)�)�3�/�/�/rc�P�|jpd}|�|��d|_|Sr3)rcr*)r�frames r� _push_framezCallerStack._push_frame�s,����'�4�� � � �E�������� rc�8�|���|_dSr3)r@rcr&s r� _pop_framezCallerStack._pop_frame�s���(�(�*�*����rN) r[r\r]rrgrfrkrprsrur`rrrr�s�������������B�B�B���� 0�0�0���� %�%�%�%�%rrc�$�eZdZdZd�Zd�Zd�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. c� �td���)Nrw)� NameErrorr&s r�__str__zUndefined.__str__�s��� �$�$�$rc�*�|���Sr3rer&s rrgzUndefined.__nonzero__�rhrc��dS)NFr`r&s rrfzUndefined.__bool__�s���urN)r[r\r]r^rzrgrfr`rrrwrw�sK��������%�%�%��������rrw�c�R�eZdZdZd�Zd�Zd�Zed���Zd�Z d�Z d�Z d �Z d S) � LoopStackz�a stack for LoopContexts that implements the context manager protocol to automatically pop off the top of the stack on context exit c��g|_dSr3��stackr&s rrzLoopStack.__init__�s ���� � � rc�:�|�|��|jSr3)�_push�_top�r�iterables r�_enterzLoopStack._enter�s�� � � �8�����y�rc�8�|���|jSr3)�_popr�r&s r�_exitzLoopStack._exits�� � � � � � ��y�rc�.�|jr |jdS|Srmr�r&s rr�zLoopStack._tops�� �:� ��:�b�>� !��Krc�4�|j���Sr3)r�r@r&s rr�zLoopStack._pop s���z�~�~���rc��t|��}|jr|jd|_|j�|��Srm)� LoopContextr�rWr*)rr��news rr�zLoopStack._pushs<���(�#�#�� �:� (���B��C�J��z� � ��%�%�%rc�*�tjd���)NzNo loop context is established)r�RuntimeExceptionr6s rrpzLoopStack.__getattr__s���)�*J�K�K�Krc�*�t|j��Sr3)�iterr�r&s r�__iter__zLoopStack.__iter__s���D�I���rN) r[r\r]r^rr�r�r_r�r�r�rpr�r`rrrr�s����������������������X��  � � �&�&�&� L�L�L�����rrc��eZdZdZd�Zd�Zejd���Ze d���Z e d���Z e d���Z e d���Z e d ���Zd �Zd S) r�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�0�||_d|_d|_dS�Nr)� _iterable�indexrWr�s rrzLoopContext.__init__3s��!����� ��� � � rc#�FK�|jD]}|V�|xjdz c_�dS�N�)r�r�)r�is rr�zLoopContext.__iter__8s;������ � �A��G�G�G� �J�J�!�O�J�J�J� � rc�*�t|j��Sr3)rjr�r&s r�__len__zLoopContext.__len__=s���4�>�"�"�"rc�6�t|��|jz dz Sr�)rjr�r&s r� reverse_indexzLoopContext.reverse_indexAs���4�y�y�4�:�%��)�)rc��|jdkSr�)r�r&s r�firstzLoopContext.firstEs���z�Q��rc�8�|jt|��dz kSr�)r�rjr&s r�lastzLoopContext.lastIs���z�S��Y�Y��]�*�*rc��|j Sr3)�oddr&s r�evenzLoopContext.evenMs ���8�|�rc�0�t|jdz��S)N�)�boolr�r&s rr�zLoopContext.oddQs���D�J��N�#�#�#rc�^�|std���||jt|��zS)z,Cycle through values as the loop progresses.z(You must provide values to cycle through)� ValueErrorr�rj)r�valuess r�cyclezLoopContext.cycleUs2��� I��G�H�H� H��d�j�3�v�;�;�.�/�/rN)r[r\r]r^rr�r�memoized_instancemethodr�r_r�r�r�r�r�r�r`rrr�r�s���������,��� ���  �!�#�#�"�!�#��*�*��X�*�����X���+�+��X�+�����X���$�$��X�$�0�0�0�0�0rr�c��eZdZd�Zd�ZdS)�_NSAttrc��||_dSr3)�_NSAttr__parent)rrWs rrz_NSAttr.__init__]s ���� � � rc��|j}|r3t|j|��rt|j|��S|j}|�3t |���r3)r��hasattr�modulero�inherits�AttributeError)rr7�nss rrpz_NSAttr.__getattr__`sX�� �]��� !��r�y�#�&�&� !��r�y�#�.�.�.��[�� � !� �S�!�!�!rN)r[r\r]rrpr`rrr�r�\s2���������"�"�"�"�"rr�c��eZdZdZ dd�ZdZdZ dZ dZ dZ dZ dZ e j d���Zd�Zd�Zd �Zed ���Zd �Zd �Zd �Zd�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. NTc�Z�||_||_||_|�d�|D��|_dSdS)Nc��i|] }|j|�� Sr`�r[��.0rPs r� <dictcomp>z&Namespace.__init__.<locals>.<dictcomp>����?�?�?��a�j�!�?�?�?r)�name�contextr�� callables)rr�r�r�r�� populate_self� calling_uris rrzNamespace.__init__{s@���� ��� � �� � � �?�?�Y�?�?�?�D�N�N�N� !� rr`c� �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` )r�r&s r�attrzNamespace.attr�s���t�}�}�rc���||f}||jjvr|jj|St||j���||j���}||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�TemplateNamespacerQ� _templateuri)r�urir7r�s r� get_namespacezNamespace.get_namespace�st��(�S�k�� �$�,�)� )� )��<�*�3�/� /� � � �L� � � � ���)�  � � �� (*�� ���$�� rc�8�t|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�s r� get_templatezNamespace.get_template�s�� �� �c�4�3D�E�E�Erc �(�|jj|fi|��S)a�Return a value from the :class:`.Cache` referenced by this :class:`.Namespace` object's :class:`.Template`. The advantage to this method versus direct access to the :class:`.Cache` is that the configuration parameters declared in ``<%page>`` take effect here, thereby calling up the same configured backend as that configured by ``<%page>``. )�cacherG)rr7r(s r� get_cachedzNamespace.get_cached�s ���t�z�~�c�,�,�V�,�,�,rc��|jjS)zReturn the :class:`.Cache` object referenced by this :class:`.Namespace` object's :class:`.Template`. )�templater�r&s rr�zNamespace.caches���}�"�"rc �8�t|j||jfi|��dS)z$Include a file at the given ``uri``.N)� _include_filer�r�)rr�r(s r� include_filezNamespace.include_file s)�� �d�l�C��):�E�E�f�E�E�E�E�Erc��|D];}|dkr |���D] \}}|||<� �(t||��||<�<dS)N�*)� _get_starro)rrT�l�ident�k�vs r� _populatezNamespace._populatesh��� 0� 0�E���|�|� �N�N�,�,���D�A�q��A�a�D�D��#�4��/�/��%���  0� 0rc#�RK�|jr|jD]}||j|fV��dSdSr3)r�r6s rr�zNamespace._get_starsP���� �>� 1��~� 1� 1���D�N�3�/�0�0�0�0�0� 1� 1� 1� 1rc���||jvr|j|}n8|jrt|j|��}ntd|j�d|�d����t |||��|S�Nz Namespace 'z' has no member '�')r�r�ror�r��setattr)rr7�vals rrpzNamespace.__getattr__sy�� �$�.� � ��.��%�C�C� �]� ��$�-��-�-�C�C� �.�7;�y�y�y�#�#�#�F��� � ��c�3����� r�NNTN)r[r\r]r^rr�r�r�r��filenamer�r�r�memoized_propertyr�r�r�r�r_r�r�r�r�rpr`rrr�r�js4������ � �&���� @� @� @� @��I� �F���H�� �G���H�� �C���L� ������� ���@F�F�F� -� -� -��#�#��X�#�F�F�F� 0�0�0�1�1�1� � � � � rr�c�t�eZdZdZ d d�Zed���Zed���Zed���Zd�Z d �Z dS) r�z@A :class:`.Namespace` specific to a :class:`.Template` instance.NTc �D�||_||_||_|�d�|D��|_|�-t |||��|_|jjj|_n*|�||_|jj|_ntd���|rt||j|���\} } dSdS)Nc��i|] }|j|�� Sr`r�r�s rr�z.TemplateNamespace.__init__.<locals>.<dictcomp>?r�rz 'template' argument is required.)�self_ns) r�r�r�r�r�r�r�� _template_urir�� TypeError�_populate_self_namespace) rr�r�r�r�r�r�r�r�� lclcallable� lclcontexts rrzTemplateNamespace.__init__0s����� ��� � �� � � �?�?�Y�?�?�?�D�N� � "�,�W�k�;�O�O�D�M� $� � 4� B�D� � � � !�$�D�M� (�� =�D� � ��>�?�?� ?� � �&>�����'�'�'� #�K���� � rc��|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�r&s rr�zTemplateNamespace.moduleOs���}�#�#rc��|jjS�zhThe path of the filesystem file used for this :class:`.Namespace`'s module or template. )r�r�r&s rr�zTemplateNamespace.filenameZs�� �}�%�%rc��|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�r&s rr�zTemplateNamespace.urias���}� � rc#��K��jr�jD]}|�j|fV���fd�}�jjjD]}|||��fV��dS)Nc�l���j�|��}tj|�j��Sr3)r��_get_def_callablerrr�)r7� callable_rs �rrGz(TemplateNamespace._get_star.<locals>.getqs-���� �7�7��<�<�I��$�Y�� �=�=� =r)r�r�r��_exports)rr7rGr�s` rr�zTemplateNamespace._get_starls������ �>� 1��~� 1� 1���D�N�3�/�0�0�0�0�0� >� >� >� >� >���%�.� � �A��c�c�!�f�f�+� � � � � � rc�d�||jvr|j|}n�|j�|��r5|j�|��}t j||j��}n8|jrt|j|��}ntd|j �d|�d����t|||��|Sr�) r�r��has_defr�rrr�r�ror�r�r��rr7r�r�s rrpzTemplateNamespace.__getattr__xs��� �$�.� � ��.��%�C�C� �]� "� "�3� '� '� �� �7�7��<�<�I��#�I�t�|�<�<�C�C� �]� ��$�-��-�-�C�C�!�.�7;�y�y�y�#�#�#�F��� � ��c�3����� r)NNNNTN) r[r\r]r^rr_r�r�r�r�rpr`rrr�r�,s�������J�J� ����������>�$�$��X�$��&�&��X�&� �!�!��X�!� � � �����rr�c�D�eZdZdZ dd�Zed���Zd�Zd�ZdS) �ModuleNamespacez;A :class:`.Namespace` specific to a Python module instance.NTc���||_||_||_|�d�|D��|_t |��}|�d��dd�D]} t || ��}�||_dS)Nc��i|] }|j|�� Sr`r�r�s rr�z,ModuleNamespace.__init__.<locals>.<dictcomp>�r�r�.r�)r�r�r�r�� __import__�splitror�) rr�r�r�r�r�r�r��mod�tokens rrzModuleNamespace.__init__�s����� ��� � �� � � �?�?�Y�?�?�?�D�N��� � ���\�\�#�&�&�q�r�r�*� &� &�E��#�u�%�%�C�C��� � � rc��|jjSr�)r��__file__r&s rr�zModuleNamespace.filename�s�� �{�#�#rc#�K�|jr|jD]}||j|fV��t|j��D]P}|ddkrBt|j|��}t |��r|t j||j��fV��QdS)Nr�_)r��dirr�ro�callablerrr�)rr7r�s rr�zModuleNamespace._get_star�s����� �>� 1��~� 1� 1���D�N�3�/�0�0�0�0�0��t�{�#�#� J� J�C��1�v��}�}�#�D�K��5�5� ��I�&�&�J��y�0��D�L�I�I�I�I�I�I��  J� Jrc�P�||jvr|j|}n}t|j|��r0t|j|��}t j||j��}n8|jrt|j|��}ntd|j �d|�d����t|||��|Sr�) r�r�r�rorrr�r�r�r�r�rs rrpzModuleNamespace.__getattr__�s��� �$�.� � ��.��%�C�C� �T�[�#� &� &� ��� �S�1�1�I��#�I�t�|�<�<�C�C� �]� ��$�-��-�-�C�C� �.�7;�y�y�y�#�#�#�F��� � ��c�3����� rr�) r[r\r]r^rr_r�r�rpr`rrrr�sx������E�E���������*�$�$��X�$� J�J�J� � � � � rrc����fd�}|S)z�Apply a caller_stack compatibility decorator to a plain Python function. See the example in :ref:`namespaces_python_modules`. c���|j��� �|g|�Ri|��|j���S#|j���wxYwr3)rrsru)r��argsr(�funcs �r�wrap_stackframez(supports_caller.<locals>.wrap_stackframe�sm�����(�(�*�*�*� .��4��1�$�1�1�1�&�1�1� � � +� +� -� -� -� -��G� � +� +� -� -� -� -���s � A�Ar`)rrs` r�supports_callerr�s$���.�.�.�.�.� �rc��t|��stjd���|��� ||i|��|���}n#|���}wxYw|���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)))rrr�rCrE�getvalue)r�r�rr(r=s rr r �s��� �I� � � ��)� A� � � � ������$�� �4�"�6�"�"�"��!�!�#�#����g�!�!�#�#��#�#�#�#� �<�<�>�>�s �A�A,c����fd�}|S)Nc������fd�}|S)Nc������fd�} �jdd�|_n#t$rYnwxYw�|���g|�Ri|��S)Nc�����g|�Ri|��Sr3r`)r�kwr�� render_fns ��r�yzB_decorate_toplevel.<locals>.decorate_render.<locals>.go.<locals>.y�s#��� �y��6�4�6�6�6�2�6�6�6r�)r[r�)r�rrr!�fnr s` ��r�goz7_decorate_toplevel.<locals>.decorate_render.<locals>.go�s����� 7� 7� 7� 7� 7� 7� �&�/����3�� � ��� � � ��� �����2�2�a�5�5��.�4�.�.�.�2�.�.� .s �� ,�,r`)r r$r#s` �r�decorate_renderz+_decorate_toplevel.<locals>.decorate_render�s)���� /� /� /� /� /� /�� rr`)r#r%s` r�_decorate_toplevelr&�s$��� � � � � � �rc������fd�}|S)Nc�,����|�����fd�}|S)Nc�����g|�Ri|��Sr3r`)rrr��decs ��rr$z5_decorate_inline.<locals>.decorate_render.<locals>.gos#����3�w�,��,�,�,��,�,� ,rr`)r r$r*r�r#s @��rr%z)_decorate_inline.<locals>.decorate_render�s6�����b��m�m�� -� -� -� -� -� -�� rr`)r�r#r%s`` r�_decorate_inliner+�s*���������� �rc �F�t|||��}t|���|��\}}t||jfi|��}|jrG ||fi|��dS#t $r.|�|tj����}|s�YdSwxYw||fi|��dS)zPlocate the template from the given uri and include it in the current output.N) r�r�rZ�_kwargs_for_includer �include_error_handler� Exceptionr� exception_as)r�r�r�r(r�r��ctx�results rr�r�s��� ���k�:�:�H�/��)�)�+�+�X����Y��!��G�M� D� D�V� D� D�F��%�!� � �I�c� $� $�V� $� $� $� $� $��� � � ��3�3�C��9L�9N�9N�O�O�F�� �� � � � ���� � �#� � �� � � � � s� A�4B�Bc��|�dSt|||��}|d}|}|j�|j}|j�|�d|i��}td|jz||d���|_|jx|jd<|jd<t |jd d��}|�|||��}|r|St |jd d��} | � | |��|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.NrrX�self:%sF�r�r�rW�local� _mako_inherit�_mako_generate_namespaces) r�r�rUr�r�r ror�r�) r�r�r�r�r��ihr�r��ret�gen_nss r� _inherit_fromr<s ��  �{��t����k�:�:�H��f�o�G� �B� �+� !� �[�� �+� !����&�"��.�.�J�#��H�L� ���� ���B�K� ;=�+�E�G�M�(��j�.�w�7�����$�?�?�I����i��*�-�-�� � ��J� �X�_�&A�4� H� H�F� ����w���� � � � +�+rc�L�|jj}|�!tjd|jjz���|�||��} |�|��S#tj$r8}tjttj ������|�d}~wwxYw)Nz.Template '%s' has no TemplateLookup associated) rr%r�TemplateLookupExceptionr�� adjust_urir��TopLevelLookupException�strrr0)r�r�� relativetor%�es rr�r�<s��� � #� *�F� �~��0� <��$�(� )� � � � � � �C�� ,� ,�C���"�"�3�'�'�'�� � -�����0� ��#�%�%� &� &� � �� ��������s�A�B#�+3B�B#c���|�td|jz||d���}|x|jd<|jd<t|jd��r|j�||��}|r|S|j|fS)Nr4Fr5rr6r7)r�r�r r�r�r7r�)r�r�r�r:s rr�r�Ls�����#� �� � $� ���  � � �� 6=�<�G�M�&��G�M�'�2��x���0�0���o�+�+�H�g�>�>�� � ��J� � �� (�(rFc�L�|rtj��}n tj|j|j���}t |fi|��}||_|�|��t|||g|�Rit||����|� ��� ��S)z^create a Context and return the string output of the given template and template callable.)�encoding�errors) rr:�output_encoding�encoding_errorsrrr#�_render_context�_kwargs_for_callablerEr)r�r�rr� as_unicoder=r�s r�_renderrM\s���� ��%�'�'����%��-�h�6N� � � ���c�"�"�T�"�"�G�%/�G�"� ���x�(�(�(������ � ��� �y�$� /� /� ��� � � � � � )� )� +� +�+rc��tj|��}|dr|S|dd�|dd�D��z}i}|D]}|dkr||vr||vr ||||<�|S)Nr�rc��g|]}|�|��Sr3r`�r�r�s r� <listcomp>z(_kwargs_for_callable.<locals>.<listcomp>{���G�G�G�A���a���rr��r��r�inspect_getargspec)r�r�argspec� namedargsr(�args rrKrKts����'� �2�2�G��q�z��� ��� �G�G���1���G�G�G�G�I� �F��$�$�� �)� � ��t� � ��6�0A�0A��s�)�F�3�K�� �Mrc ��tj|��}|dd�|dd�D��z}|D]}|dkr||vr||vr ||||<�|S)Nrc��g|]}|�|��Sr3r`rPs rrQz'_kwargs_for_include.<locals>.<listcomp>�rRrr�rSr�rT)r�rr(rVrWrXs rr-r-�sv���'� �2�2�G��� �G�G���1���G�G�G�G�I��$�$�� �)� � ��t� � ��6�0A�0A��s�)�F�3�K�� �Mrc���ddlm}t||j��s(t ||��\}}t ||||���dSt ||j��\}}t ||||���dS)Nr)rr()� mako.templater�� isinstance� DefTemplater��_exec_templaterW)�tmplr�r�rr(r��inheritr�s rrJrJ�s���$�$�$�$�$�$� �d�H�0� 1� 1�E� 8��$� G� G���*��w� ��f�E�E�E�E�E�E�!9��$�+� N� N���*��y�'��V�D�D�D�D�D�Drc�*�|j}|�}|js|jro ||g|�Ri|��dS#t$r&t ||t j����YdStj��d}t |||��YdSxYw||g|�Ri|��dS)z�execute a rendering callable given the callable, a Context, and optional explicit arguments the contextual Template will be located if it exists, and the error handling options specified on that Template will be interpreted here. Nr) r�format_exceptions� error_handlerr/� _render_errorrr0�sys�exc_info)r�r�rr(r�rCs rr_r_�s����%�H����"��&.�&<�� 0� �I�g� /�� /� /� /�� /� /� /� /� /��� D� D� D� �(�G�V�-@�-B�-B� C� C� C� C� C� C� 0�� ���q�!�A� �(�G�Q� /� /� /� /� /� /����� �'�+�D�+�+�+�F�+�+�+�+�+s� '�,B�+Bc���|jrL|�||��}|s2tj��\}}}|r|r|�|���|�dSt j��}|jrtj��g|j dd�<n*tj|j |j ��g|j dd�<|� |��|� ||���dS)N)�error)rdrfrg�with_tracebackr�html_error_templaterrr:r rHrIr#�render_context)r�r�rir2�tp�value�tb�error_templates rrere�s����<��'�'���7�7��� ��L�N�N�M�B��r�� �� ��*�*�2�.�.�.�� �  � �$�7�9�9�� � )� �(,�(?�(A�(A�'B�G� !�!�!�!� $� $��'�"�2�"�2���(�G� !�!�!�!� $� �"�"�>�2�2�2��%�%�g�U�%�;�;�;�;�;rr3)F)NN)"r^r4rrf�makorrrrr0rrw� UNDEFINED�STOP_RENDERINGrr�r�r�r�rrr r&r+r�r<r�r�rMrKr-rJr_rer`rr�<module>rts���,�,��������� � � � �������������������i�i�i�i�i�i�i�i�X%�%�%�%�%�$�%�%�%�8��������( �I�K�K� ���%�%�%�%�%�%�%�%�P>0�>0�>0�>0�>0�>0�>0�>0�B "� "� "� "� "� "� "� "���������DZ�Z�Z�Z�Z� �Z�Z�Z�z7�7�7�7�7�i�7�7�7�t���$���*���$ � � �!�!�!�(,�,�,�@ � � � )� )� )� )� ,�,�,�,�0 � � ���� E� E� E�,�,�,�,�.<�<�<�<�<r
Memory