� <��gɅ���dZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl m Z dd l mZdd l mZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZejd��Zejdej dej!f���Z"ej#r!ddl$Z$ddl%Z&ddl'm(Z(Gd�de&j)��Z*gd�Z+gd�Z,ded efd!�Z-d"ej.ej!d e/fd#�Z0d"ej.ej!d e/fd$�Z1 dId&d'd(ej2e/d)ej3e/ej d*gej4e/ffd+ej2ej3e/ej!fd,e5d-ej2ej6e/ej!fd.ej2ej7e/ej!fd d*fd/�Z8Gd0�d1��Z9d2e"d e"fd3�Z:ej7j;Gd4�d*����Z<Gd5�d6��Z=Gd7�d8��Z>Gd9�d:e>��Z?Gd;�d<��Z@Gd=�d>��ZAdeAfd?ej2d@dAejBeAd ejBeAfdB�ZCGdC�dDeA��ZDGdE�dFeA��ZEGdG�dHeA��ZFdS)Jz;The runtime functions and state used by compiled templates.�N)�abc)�chain)�escape)�Markup)�soft_str��� auto_aiter)� auto_await)�TemplateNotFound)�TemplateRuntimeError)�UndefinedError)� EvalContext)�_PassArg)�concat)� internalcode)�missing)� Namespace)�object_type_repr)�pass_eval_context�V�F.)�bound)� Environmentc �@�eZdZ ddejedddedefd�ZdS) �LoopRenderFuncr�reciter�loop_render_func�depth�returnc��dS�N�)�selfrrrs �^/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/jinja2/runtime.py�__call__zLoopRenderFunc.__call__&s �� �#�N)r) �__name__� __module__� __qualname__�t�Iterabler�int�strr&r#r'r%rr%s^������ �  � ��Z��]� �/� ��  � �  � � � � � r'r)� LoopContext�TemplateReference�Macrorr rr� markup_join�str_join�identityr r� Undefinedr)�AsyncLoopContextr r �xr c��|S)zLReturns its argument. Useful for certain things in the environment. r#)r7s r%r4r4Fs �� �Hr'�seqc��g}tt|��}|D]Y}|�|��t|d��r2t d���t ||����cS�Zt|��S)z?Concatenation that escapes if necessary and converts to string.�__html__�)�mapr�append�hasattrr�joinrr)r9�buf�iterator�args r%r2r2Ms�� �C��8�S�!�!�H��9�9�� � � �3���� �3� � #� #� 9��"�:�:�?�?�5��h�#7�#7�8�8� 8� 8� 8� 9� �#�;�;�r'c�F�ttt|����S)z3Simple args to string conversion and concatenation.)rr=r.)r9s r%r3r3Xs�� �#�c�3�-�-� � � r'F� environmentr� template_name�blocks�Context�vars�shared�globals�localsc���|�i}|r|}nt|pdfi|��}|r9|rt|��}|���D]\}} | tur| ||<�|�|||||���S)z%Internal helper for context creation.Nr#)rK)�dict�itemsr� context_class) rErFrGrIrJrKrL�parent�key�values r%� new_contextrT]s��� �|��� �-�����g�m��,�,�t�,�,�� �$� � "��&�\�\�F� �,�,�.�.� $� $�J�C���G�#�#�#��s� �� � $� $��V�]�F�G� %� � �r'c�@�eZdZdZd d�Zdedejfd�Zdefd �Z dS) r0zThe `self` in templates.�contextrHr Nc��||_dSr")�_TemplateReference__context)r$rVs r%�__init__zTemplateReference.__init__}s �� ����r'�namec�T�|jj|}t||j|d��S�Nr)rXrG�BlockReference)r$rZrGs r%� __getitem__zTemplateReference.__getitem__�s'����&�t�,���d�D�N�F�A�>�>�>r'c�L�dt|��j�d|jj�d�S)N�<� �>)�typer(rXrZ�r$s r%�__repr__zTemplateReference.__repr__�s)��A�4��:�:�&�A�A���)<�A�A�A�Ar')rVrHr N) r(r)r*�__doc__rYr.r+�Anyr^rer#r'r%r0r0zst������"�"�!�!�!�!�?��?���?�?�?�?�B�#�B�B�B�B�B�Br'r0� dict_methodc���tj���dddtjf�fd� ��}tjt |��S)Nr$rHr c�>���|�����Sr")�get_all)r$rhs �r%�f_allz_dict_method_all.<locals>.f_all�s����{�4�<�<�>�>�*�*�*r')� functools�wrapsr+rg�castr)rhrls` r%�_dict_method_allrp�sZ����_�[�!�!�+�I�+�!�%�+�+�+�+�+�"�!�+� �6�!�U� � �r'c��eZdZdZ d dddejeejfdejedejeej dgej effdejej eejff d �Z ded ej dgej efd ej d fd �Zd dedejd ejfd�Zded ej ejdffd�Zded ejfd�Zd ejeejffd�Zd ejeejffd�Zedej dejfdejdejd ej ejdffd���Zd dejejeejfd dfd�Zeej��Zeej��Zeej��Zded efd�Zded ejfd�Zd efd�ZdS)!rHa�The template context holds the variables of a template. It stores the values passed to the template and also the names the template exports. Creating instances is neither supported nor useful as it's created automatically at various stages of the template evaluation and should not be created by hand. The context is immutable. Modifications on :attr:`parent` **must not** happen and modifications on :attr:`vars` are allowed from generated template code only. Template filters and global functions marked as :func:`pass_context` get the active context passed as first argument and are allowed to access the context read-only. The template context supports read only dict operations (`get`, `keys`, `values`, `items`, `iterkeys`, `itervalues`, `iteritems`, `__getitem__`, `__contains__`). Additionally there is a :meth:`resolve` method that doesn't fail with a `KeyError` but returns an :class:`Undefined` object for missing variables. NrErrQrZrGrKc�&�||_i|_||_t|j|��|_t ��|_||_|�t ��nt |��|_d�|� ��D��|_ dS)Nc��i|] \}}||g�� Sr#r#��.0�k�vs r%� <dictcomp>z$Context.__init__.<locals>.<dictcomp>�s ��9�9�9�$�!�Q�q�1�#�9�9�9r') rQrIrEr�eval_ctx�set� exported_varsrZ� globals_keysrOrG)r$rErQrZrGrKs r%rYzContext.__init__�s~���� �(*�� �(3���#�D�$4�d�;�;�� �),������� �%,�_�C�E�E�E�#�g�,�,��� :�9�&�,�,�.�.�9�9�9�� � � r'�currentr �r]r5c��� |j|}|�|��dz}||n0#t$r#|j�d|�d�d���cYSwxYwt ||||��S)zRender a parent block.r� there is no parent block called �.�super�rZ)rG�index� LookupErrorrE� undefinedr])r$rZr}rGr�s r%r�z Context.super�s��� ��[��&�F��L�L��)�)�A�-�E� �5�M�M�M��� � � ��#�-�-�<�4�<�<�<�7�.��� � � � �����d�D�&�%�8�8�8s�-0�*A�ArR�defaultc�8� ||S#t$r|cYSwxYw)z�Look up a variable by name, or return a default if the key is not found. :param key: The variable name to look up. :param default: The value to return if the key is not found. )�KeyError)r$rRr�s r%�getz Context.get�s5�� ���9� ��� � � ��N�N�N� ���s � � �r5c�x�|�|��}|tur|j�|���S|S)aNLook up a variable by name, or return an :class:`Undefined` object if the key is not found. If you need to add custom behavior, override :meth:`resolve_or_missing`, not this method. The various lookup functions use that method, not this one. :param key: The variable name to look up. r�)�resolve_or_missingrrEr�)r$rR�rvs r%�resolvezContext.resolve�s?��� $� $�S� )� )�� ��=�=��#�-�-�3�-�7�7� 7�� r'c�h�||jvr |j|S||jvr |j|StS)aNLook up a variable by name, or return a ``missing`` sentinel if the key is not found. Override this method to add custom lookup behavior. :meth:`resolve`, :meth:`get`, and :meth:`__getitem__` use this method. Don't call this method directly. :param key: The variable name to look up. )rIrQr)r$rRs r%r�zContext.resolve_or_missing�s<�� �$�)� � ��9�S�>� !� �$�+� � ��;�s�#� #��r'c�*���fd��jD��S)z+Get a new dict with the exported variables.c�,��i|]}|�j|��Sr#)rI)rurvr$s �r%rxz(Context.get_exported.<locals>.<dictcomp>�s!���<�<�<�A��4�9�Q�<�<�<�<r')r{rds`r%� get_exportedzContext.get_exported�s ���<�<�<�<��);�<�<�<�<r'c�h�|js|jS|js|jSt|jfi|j��S)z�Return the complete context as dict including the exported variables. For optimizations reasons this might not return an actual copy so be careful with using it. )rIrQrNrds r%rkzContext.get_all�sB�� �y� ��;� ��{� ��9� ��D�K�-�-�4�9�-�-�-r'� _Context__obj.�args�kwargsc�� d}t|d��r tj|j���|j}tj|��}|tjurg|�d��r|�|d��}|�d��r|�|d��}|f|z}n3|tjur |jf|z}n|tj ur |j f|z}|� dd��|� dd�� ||i|��S#t$r|j � d��cYSwxYw)z�Call the callable with the arguments and keyword arguments provided but inject the active context or environment as first argument if the callable has :func:`pass_context` or :func:`pass_environment`. Tr&N� _loop_vars� _block_varszGvalue was undefined because a callable raised a StopIteration exception) r?r�from_objr&rVr��derived� eval_contextryrE�pop� StopIterationr�)�_Context__selfr�r�r��__traceback_hide__�pass_args r%�callz Context.calls��� &�!%� � �E�:� &� &� #��!�%�.�1�1�=��N�E��$�U�+�+�� �x�'� '� '��z�z�,�'�'� >�����|�(<�=�=���z�z�-�(�(� ?�����}�(=�>�>���9�t�#�D�D� ��.� .� .��O�%��,�D�D� ��-� -� -��&�(�4�/�D�� � �=�$�'�'�'�� � �<��&�&�&� ��5�$�)�&�)�)� )��� � � ��%�/�/�+��� � � � ���s�D%�%$E � E rLc ���t|j|ji|���dd|��}|j|_|j�d�|j���D����|S)z�Internal helper function to create a derived context. This is used in situations where the system needs a new context in the same template that is independent. TNc3�>K�|]\}}|t|��fV��dSr")�listrts r%� <genexpr>z"Context.derived.<locals>.<genexpr>?s0����K�K�t�q�!�q�$�q�'�'�l�K�K�K�K�K�Kr')rTrErZrkryrG�updaterO)r$rLrVs r%r�zContext.derived6ss�� � � �d�i��T�\�\�^�^�T�4�� � �� �=�������K�K�t�{�7H�7H�7J�7J�K�K�K�K�K�K��r'c�&�||jvp||jvSr")rIrQ�r$rZs r%� __contains__zContext.__contains__Fs���t�y� �7�D�D�K�$7�7r'c�`�|�|��}|turt|���|S)zpLook up a variable by name with ``[]`` syntax, or raise a ``KeyError`` if the key is not found. )r�rr�)r$rR�items r%r^zContext.__getitem__Is1���&�&�s�+�+�� �7�?�?��3�-�-� �� r'c�l�dt|��j�d|����d|j�d�S)Nr`raz of rb)rcr(rkrZrds r%rezContext.__repr__Ts6��M�4��:�:�&�M�M������M�M�t�y�M�M�M�Mr'r") r(r)r*rfr+�Dictr.rg�Optional�Callable�Iterator�MutableMappingrY�Unionr�r�r�r�r�rkrr�r�rprN�keys�valuesrO�boolr�r^rer#r'r%rHrH�s��������2=A� :�:�"�:���s�A�E�z�"�:��j��o� :� ��s�A�J� �{�A�J�s�O�'C�D�D�E� :� ��A�,�S�!�%�Z�8�9� :�:�:�:�* 9�� 9�"#�*�i�[�!�*�S�/�-I�"J� 9� ��.� /� 9� 9� 9� 9� � �s� �Q�U� �a�e� � � � ��3��1�7�1�5�+�+=�#>�����"�c��a�e�����$=�a�f�S�!�%�Z�0�=�=�=�=� .����Q�U� �+� .� .� .� .��-��z�#�q�u�*�%�-��u�-��%� -� ���� �#� $� -�-�-��\�-�^ � �a�j����Q�U� �);�<� � � � � � � � �D�I� &� &�D� � �d�k� *� *�F� � �T�Z� (� (�E�8��8��8�8�8�8� �s� �q�u� � � � �N�#�N�N�N�N�N�Nr'c ���eZdZdZdedddejejdgejefde ddf d �Z e dej d fd ���Z edefd ���Zedefd ���ZdS)r]z"One block on a template reference.rZrVrH�stackrr Nc�>�||_||_||_||_dSr")rZ�_context�_stack�_depth)r$rZrVr�rs r%rYzBlockReference.__init__[s$���� ��� ��� ��� � � r'r~c���|jdzt|j��kr*|jj�d|j�d�d���St|j|j|j|jdz��S)zSuper the block.rr�r�r�r�)r��lenr�r�rEr�rZr]rds r%r�zBlockReference.supergsv�� �;��?�c�$�+�.�.� .� .��=�,�6�6�A�4�9�A�A�A��7��� ��d�i���� �T�[�ST�_�U�U�Ur'c���K�|jj�d�|j|j|j��2���d{V����}|jjjrt|��S|S)Nc��"K�g|3d{V��}|�� 6Sr"r#�rur7s r%� <listcomp>z.BlockReference._async_call.<locals>.<listcomp>ss.���� F� F� F� F� F� F� F� F��Q� F� F� F� F��)r�rErr�r�ry� autoescaper�r$r�s r%� _async_callzBlockReference._async_callps|���� �]� &� -� -� F� F�6�d�k�$�+�6�t�}�E�E� F� F� F� F� F� F� F� F� F� � �� �=� !� ,� ��"�:�:� �� r'c� �|jjjr|���S|jj�|j|j|j����}|jjjrt|��S|Sr") r�rE�is_asyncr�rr�r�ryr�rr�s r%r&zBlockReference.__call__{sy�� �=� $� -� &��#�#�%�%� %� �]� &� -� -� $�D�K�� � $�T�]� 3� 3� � �� �=� !� ,� ��"�:�:� �� r')r(r)r*rfr.r+�Listr�r�r-rY�propertyr�r�rr�r&r#r'r%r]r]Xs�������,�,� �� �� ��v�a�j�)��a�j��o�!=�>�?� � � � � � � � ��V�q�w�<�=�V�V�V��X�V���3�����\��� �#� � � ��\� � � r'r]c �V�eZdZUdZdZdZejee d<e Z ej e d<e Z ej e d<e Zej e d<e Zej e d< d&d ejed ejd d ejddeddf d�Zed ejedejefd���Zedefd���Zdefd�Zedefd���Zedefd���Zedefd���Zedefd���Zedefd���Zdej fd�Z edefd���Z!edej"ej d ffd���Z#edej"ej d ffd���Z$dedefd�Z%d ej defd!�Z&d'd"�Z'dej(ej dffd#�Z)e*d ejede+fd$���Z,de+fd%�Z-dS)(r/zeA wrapper iterable for dynamic ``for`` loops, with information about the loop and iteration. �����N�_length�_after�_current�_before�_last_changed_valuer�iterabler�r5�recurser�depth0r c�r�||_|�|��|_||_||_||_dS)a@ :param iterable: Iterable to wrap. :param undefined: :class:`Undefined` class to use for next and previous items. :param recurse: The function to render the loop body when the loop is marked recursive. :param depth0: Incremented when looping recursively. N)� _iterable� _to_iterator� _iterator� _undefined�_recurser�)r$r�r�r�r�s r%rYzLoopContext.__init__�s9��"����*�*�8�4�4���#����� ��� � � r'c� �t|��Sr")�iter�r�s r%r�zLoopContext._to_iterator�s���H�~�~�r'c�4�|j�|jS t|j��|_ni#t$r\t |j��}|�|��|_t|��|jz|jtuz|_YnwxYw|jS)z�Length of the iterable. If the iterable is a generator or otherwise does not have a size, it is eagerly evaluated to get a size. ) r�r�r�� TypeErrorr�r�r�r�r�r�r$r�s r%�lengthzLoopContext.length�s��� �<� #��<� � U��t�~�.�.�D�L�L��� U� U� U��D�N�+�+�H�!�.�.�x�8�8�D�N��x�=�=�4�:�5���G�9S�T�D�L�L�L� U���� �|�s�*�A#B�Bc��|jSr")r�rds r%�__len__zLoopContext.__len__�s ���{�r'c��|jdzS)zBHow many levels deep a recursive loop currently is, starting at 1.r)r�rds r%rzLoopContext.depth�����{�Q��r'c��|jdzS)z-Current iteration of the loop, starting at 1.r��index0rds r%r�zLoopContext.index�r�r'c� �|j|jz S)zrNumber of iterations from the end of the loop, ending at 0. Requires calculating :attr:`length`. �r�r�rds r%� revindex0zLoopContext.revindex0�s�� �{�T�Z�'�'r'c� �|j|jz S)zrNumber of iterations from the end of the loop, ending at 1. Requires calculating :attr:`length`. �r�r�rds r%�revindexzLoopContext.revindex�s�� �{�T�[�(�(r'c��|jdkS)z0Whether this is the first iteration of the loop.rr�rds r%�firstzLoopContext.first�s���{�a��r'c�x�|jtur|jSt|jt��|_|jS)a Return the next element in the iterable, or :data:`missing` if the iterable is exhausted. Only peeks one item ahead, caching the result in :attr:`_last` for use in subsequent checks. The cache is reset when :meth:`__next__` is called. )r�r�nextr�rds r%� _peek_nextzLoopContext._peek_next�s4�� �;�g� %� %��;� ��4�>�7�3�3�� ��{�r'c�8�|���tuS)z�Whether this is the last iteration of the loop. Causes the iterable to advance early. See :func:`itertools.groupby` for issues this can cause. The :func:`groupby` filter avoids that issue. �r�rrds r%�lastzLoopContext.last�s����� � �G�+�+r'c�H�|jr|�d��S|jS)zZThe item in the previous iteration. Undefined during the first iteration. zthere is no previous item)r�r�r�rds r%�previtemzLoopContext.previtem�s*�� �:� @��?�?�#>�?�?� ?��|�r'c�j�|���}|tur|�d��S|S)a The item in the next iteration. Undefined during the last iteration. Causes the iterable to advance early. See :func:`itertools.groupby` for issues this can cause. The :func:`jinja-filters.groupby` filter avoids that issue. �there is no next item�r�rr�r�s r%�nextitemzLoopContext.nextitems4���_�_� � �� ��=�=��?�?�#:�;�;� ;�� r'r�c�^�|std���||jt|��zS)z�Return a value from the given args, cycling through based on the current :attr:`index0`. :param args: One or more values to cycle through. zno items for cycling given)r�r�r�)r$r�s r%�cyclezLoopContext.cycles3�� � :��8�9�9� 9��D�K�#�d�)�)�+�,�,r'rSc�.�|j|kr ||_dSdS)z�Return ``True`` if previously called with a different value (including when called for the first time). :param value: One or more values to compare to the last call. TF)r�)r$rSs r%�changedzLoopContext.changed"s$�� � #�u� ,� ,�',�D� $��4��ur'c��|Sr"r#rds r%�__iter__zLoopContext.__iter__.���� r'c��|jtur|j}t|_nt|j��}|xjdz c_|j|_||_||fS�Nr)r�rr�r�r�r�r�r�s r%�__next__zLoopContext.__next__1sW�� �;�g� %� %���B�!�D�K�K��d�n�%�%�B� � � �q�� � ��}�� ��� ��4�x�r'c�r�|j�td���|�||j|j���S)z�When iterating over nested data, render the body of the loop recursively with the given inner iterable data. The loop must have the ``recursive`` marker for this to work. NzCThe loop must have the 'recursive' marker to be called recursively.)r)r�r�rr�s r%r&zLoopContext.__call__=s?�� �=� ��U��� ��}�}�X�t�}�D�J�}�G�G�Gr'c�R�dt|��j�d|j�d|j�d�S)Nr`ra�/rb)rcr(r�r�rds r%rezLoopContext.__repr__Ks0��D�4��:�:�&�D�D���D�D�d�k�D�D�D�Dr'r\)r r/).r(r)r*rfr�r�r+r�r-�__annotations__rr�rgr�r�r�r,r�TyperY� staticmethodr�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�rr�Tuplerrr.r&rer#r'r%r/r/�s���������� �F�#�G�Q�Z��_�#�#�#��F�A�E�����H�a�e�����G�Q�U����!(����(�(�(� 15�� ���*�Q�-���6�+�&����,�-� � � � � ����,��q�z�!�}����A������\���������X��$��������s�����X����s�����X���(�3�(�(�(��X�(��)�#�)�)�)��X�)�� �t� � � ��X� � �A�E� � � � ��,�d�,�,�,��X�,���!�'�!�%��"4�5�����X��� �!�'�!�%��"4�5� � � ��X� � -�1� -�� -� -� -� -� �a�e� �� � � � ����� �!�'�!�%��"6�7� � � � �� H���A�� H�3� H� H� H��\� H�E�#�E�E�E�E�E�Er'r/c��eZdZUejejed<edejej e ej e fdeje fd���Z e defd���Ze defd���Ze defd���Zdejfd�Ze defd ���Ze dejejd ffd ���Zdd �Zdejejdffd �ZdS)r6r�r�r c� �t|��Sr"r r�s r%r�zAsyncLoopContext._to_iteratorRs���(�#�#�#r'c��>K�|j�|jS t|j��|_nl#t$r_d�|j2���d{V��}|�|��|_t|��|jz|jtuz|_YnwxYw|jS)Nc��"K�g|3d{V��}|�� 6Sr"r#r�s r%r�z+AsyncLoopContext.length.<locals>.<listcomp>`s.����8�8�8�8�8�8�8�8�A��8�8�8�8r�) r�r�r�r�r�r�r�r�rr�s r%r�zAsyncLoopContext.lengthXs����� �<� #��<� � U��t�~�.�.�D�L�L��� U� U� U�8�8���8�8�8�8�8�8�8�8�8�H�!�.�.�x�8�8�D�N��x�=�=�4�:�5���G�9S�T�D�L�L�L� U���� �|�s�,�A&B�Bc��0K�|j�d{V��|jz Sr"r�rds r%r�zAsyncLoopContext.revindex0fs'�����[� � � � � � �4�:�-�-r'c��0K�|j�d{V��|jz Sr"r�rds r%r�zAsyncLoopContext.revindexjs'�����[� � � � � � �4�;�.�.r'c���K�|jtur|jS |j����d{V��|_n#t$rt|_YnwxYw|jSr")r�rr�� __anext__�StopAsyncIterationrds r%r�zAsyncLoopContext._peek_nextnsy���� �;�g� %� %��;� � "� $�� 8� 8� :� :�:�:�:�:�:�:�D�K�K��!� "� "� "�!�D�K�K�K� "�����{�s�$>�A�Ac��HK�|����d{V��tuSr"r�rds r%r�zAsyncLoopContext.lastys-�����_�_�&�&�&�&�&�&�&�&�'�1�1r'r5c��zK�|����d{V��}|tur|�d��S|S)Nr�r�r�s r%r�zAsyncLoopContext.nextitem}sH�����?�?�$�$� $� $� $� $� $� $�� ��=�=��?�?�#:�;�;� ;�� r'c��|Sr"r#rds r%� __aiter__zAsyncLoopContext.__aiter__�rr'c���K�|jtur|j}t|_n|j����d{V��}|xjdz c_|j|_||_||fSr)r�rr�rr�r�r�r�s r%rzAsyncLoopContext.__anext__�sq���� �;�g� %� %���B�!�D�K�K��~�/�/�1�1�1�1�1�1�1�1�B� � � �q�� � ��}�� ��� ��4�x�r'N)r r6)r(r)r*r+� AsyncIteratorrgr r r�r,r� AsyncIterabler�r�r-r�r�r�r�r�r�r�rr rr#r'r%r6r6Os����������q�u�%�%�%�%��$��'�!�*�Q�-����);�;�<�$� ��� �$�$�$��\�$� � �c� � � ��X� ��.��.�.�.��X�.��/��/�/�/��X�/� �!�%� � � � ��2�D�2�2�2��X�2�������{�(:� ;�����X������ �����0B�)B�!C� � � � � � r'r6c�@�eZdZdZ ddddejdefdedejed ed ed ed ej efd �Z e e dej dej defd�����Zdejej dedefd�Zdejej dedefd�Zdefd�ZdS)r1zWraps a macro function.NrEr�func.rZ� arguments� catch_kwargs� catch_varargs�caller�default_autoescapec ��||_||_t|��|_||_||_||_||_||_d|v|_ |�1t|j ��r|� d��}n|j }||_ dS)Nr#) � _environment�_funcr��_argument_countrZr r!r"r#�explicit_caller�callabler��_default_autoescape) r$rErrZr r!r"r#r$s r%rYzMacro.__init__�s���(����� �"�9�~�~����� �"���(���*����� �'�9�4��� � %�� �.�/�/� <�%0�%;�%;�D�%A�%A�"�"�%0�%;�"�#5�� � � r'r�r�r c �Z�|r3t|dt��r|dj}|dd�}n|j}t |d|j���}t |��}d}||jkrk|jt |��d�D]M} |�|��}n#t$r t}YnwxYw|dkrd}|� |���Nn|j }|j rK|sI|�dd��} | �|j�dd���} |� | ��|jr|� |��nR|rPd|vrt#d|j�d ����t#d|j�d t't)|���������|jr#|� ||jd���nEt |��|jkr-t#d|j�d t |j���d ����|�||��S) NrrFr#TzNo caller definedr�zmacro zX was invoked with two values for the special caller argument. This is most likely a bug.z takes no keyword argument z takes not more than z argument(s))� isinstancerr�r+r�r(r�r r�r�rr>r)r#r&r�r!r�rZr�r�r"�_invoke) r$r�r�r�r �off� found_callerrZrSr#s r%r&zMacro.__call__�s���& � 2�J�t�A�w� �4�4� 2��a��+�J�����8�D�D��1�J���4�� 4�4�5�6�6� ��)�n�n��� � �$�&� &� &���s�9�~�~�'7�'7�8� (� (��$�"�J�J�t�,�,�E�E���$�$�$�#�E�E�E�$�����8�#�#�#'�L�� � ��'�'�'�'� (� �/�L� �;� %�|� %��Z�Z��$�/�/�F��~��*�4�4�5H�x�4�X�X�� � � �V� $� $� $� � � � � � �V� $� $� $� $� � ��6�!�!��C�T�Y�C�C�C�����W���W�W��d�6�l�l�AS�AS�W�W��� � � � � � � �T�$�"6�"8�"8�9� :� :� :� :� ��Y�Y��-� -� -��6���6�6����'�'�6�6�6��� � �|�|�I�z�2�2�2s�B*�*B>�=B>r�c��LK�|j|��d{V��}|rt|��S|Sr")r'r�r$r r�r�s r%� _async_invokezMacro._async_invokes?�����4�:�y�)� )� )� )� )� )� )�� � ��"�:�:� �� r'c��|jjr|�||��S|j|�}|rt |��}|Sr")r&r�r3r'rr2s r%r.z Macro._invoke sL�� � � %� =��%�%�i��<�<� <� �T�Z�� #�� � �����B�� r'c�r�|j�dnt|j��}dt|��j�d|�d�S)N� anonymousr`rarb)rZ�reprrcr(r�s r%rezMacro.__repr__s<��"�i�/�{�{�T�$�)�_�_��0�4��:�:�&�0�0��0�0�0�0r'r")r(r)r*rfr+r�r.r�r�r�rYrrrgr&r3r.rer#r'r%r1r1�sh������!�!�04�6�6�"�6��j��c��"�6�� 6� �6�#�;� 6� � 6��6��6��J�t�,�6�6�6�6�:��J3�a�e�J3�q�u�J3��J3�J3�J3����\�J3�X�Q�V�A�E�]����QT����� ������ �D� �S� � � � �1�#�1�1�1�1�1�1r'r1c �:�eZdZdZdZdedefdeje dej deje dej e ddf d �Z ede fd ���Zed ej d ej dd fd���Zede dej fd���ZexZxZxZZexZxZxZZexZZexZZexZZ exZ!Z"exZ#Z$exZ%xZ&xZ'Z(exZ)xZ*Z+exZ,Z-dej de.fd�Z/dej de.fd�Z0de1fd�Z2de fd�Z3de1fd�Z4dej5ej fd�Z6dej7ej fd�Z8de.fd�Z9de fd�Z:dS)r5agThe default undefined type. This can be printed, iterated, and treated as a boolean. Any other operation will raise an :exc:`UndefinedError`. >>> foo = Undefined(name='foo') >>> str(foo) '' >>> not foo True >>> foo + 42 Traceback (most recent call last): ... jinja2.exceptions.UndefinedError: 'foo' is undefined ��_undefined_hint�_undefined_obj�_undefined_name�_undefined_exceptionN�hint�objrZ�excr c�>�||_||_||_||_dSr"r9)r$r>r?rZr@s r%rYzUndefined.__init__2s*�� $���!���#���$'��!�!�!r'c���|jr|jS|jtur |j�d�St |jt ��st |j���d|j��St |j���d|j��S)zXBuild a message about the undefined value based on how it was accessed. z is undefinedz has no element z has no attribute )r:r;rr<r-r.rrds r%�_undefined_messagezUndefined._undefined_message>s��� � � (��'� '� � �'� )� )��*�;�;�;� ;��$�.��4�4� �#�D�$7�8�8�5�5� �0�5�5� �  �� 3�4�4� 3� 3��.� 3� 3� r'r�r�� te.NoReturnc�6�|�|j���)zeRaise an :exc:`UndefinedError` when operations are performed on the undefined value. )r=rC)r$r�r�s r%�_fail_with_undefined_errorz$Undefined._fail_with_undefined_errorTs���'�'��(?�@�@�@r'c��|dd�dkr|dd�dkrt|���|���S�N��__�����)�AttributeErrorrFr�s r%� __getattr__zUndefined.__getattr__]sI�� ����8�t� � ��R�S�S� �T� 1� 1� ��&�&� &��.�.�0�0�0r'�otherc�>�t|��t|��uSr")rc�r$rNs r%�__eq__zUndefined.__eq__ss���D�z�z�T�%�[�[�(�(r'c�.�|�|�� Sr")rQrPs r%�__ne__zUndefined.__ne__vs���;�;�u�%�%�%�%r'c�:�tt|����Sr")�idrcrds r%�__hash__zUndefined.__hash__ys���$�t�*�*�~�~�r'c��dS)Nr<r#rds r%�__str__zUndefined.__str__|s���rr'c��dSr\r#rds r%r�zUndefined.__len__s���qr'c#�K�dEd{V��dS�Nr#r#rds r%rzUndefined.__iter__�s����� � � � � � � � � r'c�K�dD]}dWV��dSr[r#)r$�_s r%rzUndefined.__aiter__�s,����� � �A� �E�E�E�E�E� � r'c��dS)NFr#rds r%�__bool__zUndefined.__bool__�s���ur'c��dS)Nr5r#rds r%rezUndefined.__repr__�s���{r');r(r)r*rf� __slots__rrr+r�r.rgr r rYr�rCrrFrM�__add__�__radd__�__sub__�__rsub__�__mul__�__rmul__�__div__�__rdiv__� __truediv__� __rtruediv__� __floordiv__� __rfloordiv__�__mod__�__rmod__�__pos__�__neg__r&r^�__lt__�__le__�__gt__�__ge__�__int__� __float__� __complex__�__pow__�__rpow__r�rQrSr-rVrXr�r�rrrr_rer#r'r%r5r5s������� � ��I�!%�� $�,:� (� (��j��o� (��U� (��j��o� (� �V�(� )� (� � (� (� (� (�� �C� � � ��X� �*�A��U�A�&'�e�A� �A�A�A��\�A��1��1���1�1�1��\�1�/I�H�G�H�h�H��8�.H�H�G�H�h�H��8�!;�;�K�,�#=�=�L�=�3�3�G�h�2�2�G�g�7�7�H�{�(B�B�F�B�V�B�f�v�(B�B�G�B�i�+�3�3�G�h�)�A�E�)�d�)�)�)�)�&�A�E�&�d�&�&�&�&��#������������������!�*�Q�U�+����������!7������$������#������r'r5�loggerzlogging.Logger�basec�������Fddl}|jt�����|jt j����dtddf�fd� �G��fd�d|��}|S)akGiven a logger object this returns a new undefined class that will log certain failures. It will log iterations and printing. If no logger is given a default logger is created. Example:: logger = logging.getLogger(__name__) LoggingUndefined = make_logging_undefined( logger=logger, base=Undefined ) .. versionadded:: 2.8 :param logger: the logger to use. If not provided, a default logger is created. :param base: the base class to add logging functionality to. This defaults to :class:`Undefined`. Nr�undefr c�>����d|j��dS)NzTemplate variable warning: %s)�warningrC)r~r{s �r%� _log_messagez,make_logging_undefined.<locals>._log_message�s!������6��8P�Q�Q�Q�Q�Qr'c����eZdZdZdejdejddf��fd� Zdef��fd� Zdej ejf��fd� Z de f��fd � Z �xZ S) �0make_logging_undefined.<locals>.LoggingUndefinedr#r�r�r rDc��� t��j|i|��dS#|j$r}��d|��|�d}~wwxYw)NzTemplate variable error: %s)r�rFr=�error)r$r�r��e� __class__r{s ��r%rFzKmake_logging_undefined.<locals>.LoggingUndefined._fail_with_undefined_error�sf��� �2����2�D�C�F�C�C�C�C�C���,� � � �� � �:�A�>�>�>������� ���s�� A�A�Ac�Z���|��t�����Sr")r�rX�r$r�r�s ��r%rXz8make_logging_undefined.<locals>.LoggingUndefined.__str__�s'��� �L�� � � ��7�7�?�?�$�$� $r'c�Z���|��t�����Sr")r�rr�s ��r%rz9make_logging_undefined.<locals>.LoggingUndefined.__iter__��)��� �L�� � � ��7�7�#�#�%�%� %r'c�Z���|��t�����Sr")r�r_r�s ��r%r_z9make_logging_undefined.<locals>.LoggingUndefined.__bool__�r�r')r(r)r*rar+rgrFr.rXr�rr�r_� __classcell__)r�r�r{s@��r%�LoggingUndefinedr��s���������� � ��� �*+�%� � � � � � � � � � %�S� %� %� %� %� %� %� %� &�a�j���/� &� &� &� &� &� &� &� &�d� &� &� &� &� &� &� &� &� &� &� &r'r�)�logging� getLoggerr(� addHandler� StreamHandler�sys�stderrr5)r{r|r�r�r�s` @r%�make_logging_undefinedr��s�����,�~�����"��"�8�,�,�����/�'�/�� �;�;�<�<�<�R�I�R�$�R�R�R�R�R�R�&�&�&�&�&�&�&�&�4�&�&�&�0 �r'c�B�eZdZdZdZdefd�Zdeddfd�Zdeddfd�Zd S) �ChainableUndefineda�An undefined that is chainable, where both ``__getattr__`` and ``__getitem__`` return itself rather than raising an :exc:`UndefinedError`. >>> foo = ChainableUndefined(name='foo') >>> str(foo.bar['baz']) '' >>> foo.bar['baz'] + 42 Traceback (most recent call last): ... jinja2.exceptions.UndefinedError: 'foo' is undefined .. versionadded:: 2.11.0 r#r c� �t|��Sr")r.rds r%r;zChainableUndefined.__html__�s���4�y�y�r'rZc�\�|dd�dkr|dd�dkrt|���|SrH)rLr�s r%rMzChainableUndefined.__getattr__�s<�� ����8�t� � ��R�S�S� �T� 1� 1� ��&�&� &�� r'�_namec��|Sr"r#)r$r�s r%r^zChainableUndefined.__getitem__�rr'N) r(r)r*rfrar.r;rMr^r#r'r%r�r��s������� � ��I��#����� �� �(<� � � � ����)=������r'r�c�"�eZdZdZdZdefd�ZdS)�DebugUndefinedaAn undefined that returns the debug info when printed. >>> foo = DebugUndefined(name='foo') >>> str(foo) '{{ foo }}' >>> not foo True >>> foo + 42 Traceback (most recent call last): ... jinja2.exceptions.UndefinedError: 'foo' is undefined r#r c��|jr d|j��}n6|jtur|j}n dt |j���d|j�d�}d|�d�S)Nzundefined value printed: zno such element: �[�]z{{ z }})r:r;rr<r)r$�messages r%rXzDebugUndefined.__str__�s��� � � �H�$�2F�H�H�G�G� � �G� +� +��*�G�G�.�$4�T�5H�$I�$I�.�.��(�.�.�.� � &�w�%�%�%�%r'N)r(r)r*rfrar.rXr#r'r%r�r��s@������ � ��I� &�� &� &� &� &� &� &r'r�c�T�eZdZdZdZejxZxZZ ejxZ xZ xZ Z ejZdS)�StrictUndefinedasAn undefined that barks on print and iteration as well as boolean tests and all kinds of comparisons. In other words: you can do nothing with it except checking if it's defined using the `defined` test. >>> foo = StrictUndefined(name='foo') >>> str(foo) Traceback (most recent call last): ... jinja2.exceptions.UndefinedError: 'foo' is undefined >>> not foo Traceback (most recent call last): ... jinja2.exceptions.UndefinedError: 'foo' is undefined >>> foo + 42 Traceback (most recent call last): ... jinja2.exceptions.UndefinedError: 'foo' is undefined r#N)r(r)r*rfrar5rFrrXr�rQrSr_rVr�r#r'r%r�r�sP��������&�I�#,�#G�G�H�G�w��,5�,P�P�F�P�V�P�h���7�L�L�Lr'r�)NFNN)Grfrmr��typingr+� collectionsr� itertoolsr� markupsaferrr� async_utilsr r � exceptionsr r r�nodesr�utilsrrrrrrr�TypeVarrr�rgr� TYPE_CHECKINGr��typing_extensions�terEr�Protocolr�exported�async_exportedr4r,r.r2r3r�r�r�r�r��MappingrTr0rp�registerrHr]r/r6r1r5r r�r�r�r�r#r'r%�<module>r�s���A�A����� � � � �����������������������������������#�#�#�#�#�#�#�#�#�#�#�#�(�(�(�(�(�(�,�,�,�,�,�,�&�&�&�&�&�&�������������������������������������#�#�#�#�#�#�$�$�$�$�$�$� �A�I�c�N�N�� �A�I�c���C���J�/�0�0�0���?� ��N�N�N�"�"�"�"�(�(�(�(�(�(����������� � � �� ���� �� �a� � � � ��Q�Z���&��3�����!�!�*�Q�U�#�!��!�!�!�!�,0��8<�04������:�c�?�� �F�3�� �I�;�� �3��#?�@�@� A�� �*�Q�V�C���J�'� (� � � � �Z��(��a�e��4� 5� � �J�q�y��a�e��,� -�������: B� B� B� B� B� B� B� B��!����������DN�DN�DN�DN�DN�DN�DN���DN�N/�/�/�/�/�/�/�/�dBE�BE�BE�BE�BE�BE�BE�BE�JD�D�D�D�D�{�D�D�D�NC1�C1�C1�C1�C1�C1�C1�C1�Lq�q�q�q�q�q�q�q�j,0�9�7�7� �J�'� (�7�78�v�i�7H�7��V�I��7�7�7�7�t"�"�"�"�"��"�"�"�J&�&�&�&�&�Y�&�&�&�@8�8�8�8�8�i�8�8�8�8�8r'
Memory