� <��g�|���UdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z ddl m Z dd l mZdd lmZdd lmZdd lmZdd lmZddlmZejrFddlZddlmZddlmZddlmZGd�dej��ZGd�de��Z ej!ee fZ"dZ#ej$e%dfe&d<ej'd��Z(Gd�d��Z)ededej*dej*dej!ej*effd ���Z+d!ej,e%ge%fdej,de%ffd"�Z-d!ej,e%e%e.ge%fdej,de%ffd#�Z/d!ej,e%e%ge%fdej,de%ffd$�Z0d!ej,e%e%e%e.ge%fdej,de%ffd%�Z1Gd&�d'e)��Z2Gd(�d)e)��Z3Gd*�d+e)��Z4Gd,�d-e)��Z5e#d.fd/e j6d0ej7e%d1e8dej9ej$e.e%ej!ej:e%ej$ej:e%dffffd2�Z;Gd3�d4��Z<d5ej=d6ej7e%d7ej7e%d8ej>e%ej*fdej9ej$e.e%ej!ej:e%ej$ej:e%dffej?e%ff d9�Z@e2ZAe3ZBe4ZCe5ZDdS):z2Extension API for adding custom tags and behavior.�N)�Markup�)�defaults)�nodes)� Environment)�TemplateAssertionError)�TemplateSyntaxError)�concat)�Context)� Undefined)� import_string)� pass_context)�Token)� TokenStream)�Parserc�6�eZdZdedefd�Zdedededefd�ZdS) �_TranslationsBasic�message�returnc��dS�N�)�selfrs �Z/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/jinja2/ext.py�gettextz_TranslationsBasic.gettext������singular�plural�nc��dSrr)rrrr s r�ngettextz_TranslationsBasic.ngettexts�� �DrN)�__name__� __module__� __qualname__�strr�intr"rrrrrsZ������3�3�3�3�3�3�3�3� �S� �#� �#� �#� � � � � � rrc �>�eZdZdededefd�Zdededededef d�Zd S) �_TranslationsContext�contextrrc��dSrr)rr*rs r�pgettextz_TranslationsContext.pgettext"rrrrr c��dSrr)rr*rrr s r� npgettextz_TranslationsContext.npgettext$s���#rN)r#r$r%r&r,r'r.rrrr)r)!sk������B�C�B�#�B�#�B�B�B�B� �� �*-� �7:� �?B� � � � � � � � rr))�_rr"r,r..�GETTEXT_FUNCTIONSz\s*\n\s*c��eZdZUdZejeed<dd�Ze ��Z ej eed<dZ de ddfd �Zde dd fd �Z dd ed ejedejedefd�Zdddejdejdffd�Zdddejejejejffd�Z dd edejedejfd�Z d d edejejejdejejejdejejdejejdejedejfd�ZdS)!� ExtensionagExtensions can be used to add extra functionality to the Jinja template system at the parser level. Custom extensions are bound to an environment but may not store environment specific data on `self`. The reason for this is that an extension can be bound to another environment (for overlays) by creating a copy and reassigning the `environment` attribute. As extensions are created by the environment they cannot accept any arguments for configuration. One may want to work around that by using a factory function, but that is not possible as extensions are identified by their import name. The correct way to configure the extension is storing the configuration values on the environment. Because this way the environment ends up acting as central configuration storage the attributes may clash which is why extensions have to ensure that the names they choose for configuration are not too generic. ``prefix`` for example is a terrible name, ``fragment_cache_prefix`` on the other hand is a good name as includes the name of the extension (fragment cache). � identifierrNc�2�|j�d|j��|_dS)N�.)r$r#r3)�clss r�__init_subclass__zExtension.__init_subclass__Ls���N�;�;�S�\�;�;����r�tags�d� environmentc��||_dSr)r:)rr:s r�__init__zExtension.__init__Ys��&����rzte.Selfc��t�|j��}|j�|j��||_|S)z=Create a copy of this extension bound to another environment.)�object�__new__� __class__�__dict__�updater:)rr:�rvs r�bindzExtension.bind\s9�� �^�^�D�N� +� +�� � ���4�=�)�)�)�$���� r�source�name�filenamec��|S)z�This method is called before the actual lexing and can be used to preprocess the source. The `filename` is optional. The return value must be the preprocessed source. r)rrErFrGs r� preprocesszExtension.preprocesscs ��� r�streamrrc��|S)a It's passed a :class:`~jinja2.lexer.TokenStream` that can be used to filter tokens returned. This method has to return an iterable of :class:`~jinja2.lexer.Token`\s, but it doesn't have to return a :class:`~jinja2.lexer.TokenStream`. r)rrJs r� filter_streamzExtension.filter_streamls ��� r�parserrc��t���)aIf any of the :attr:`tags` matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes. )�NotImplementedError)rrMs r�parsezExtension.parsevs�� "�#�#�#r�linenoc�:�tj|j||���S)z�Return an attribute node for the current extension. This is useful to pass constants on extensions to generated template code. :: self.attr('_my_attribute', lineno=lineno) �rQ)r�ExtensionAttributer3)rrFrQs r�attrzExtension.attr~s���'����f�M�M�M�Mr�args�kwargs�dyn_args� dyn_kwargsc�p�|�g}|�g}tj|�||���|||||���S)zsCall a method of the extension. This is a shortcut for :meth:`attr` + :class:`jinja2.nodes.Call`. NrS)r�CallrU)rrFrVrWrXrYrQs r� call_methodzExtension.call_method�sS�� �<��D� �>��F��z� �I�I�d�6�I� *� *� � � � ��  � � � r)rNr)NNNNN) r#r$r%�__doc__�t�ClassVarr&�__annotations__r7�setr8�Set�priorityrr<rD�OptionalrI�Union�IterablerLr�Node�ListrPr'rTrU�Expr�Keywordr[r\rrrr2r27s\���������$� �3�����<�<�<�<��s�u�u�D�!�%��*�����H�'�K�'�D�'�'�'�'�� �� �����OS�����!"��C���<=�J�s�O�� ������#�� ���� �7� 3�3� 4�����$�H�$�����Q�V�E�J�=O�1O�)P�$�$�$�$�48� N� N�� N�!"��C�� N� � !� N� N� N� N�04�48�+/�-1�"&� � �� ��j���� �+�,� �� �1�6�%�-�0�1�  � �*�U�Z�(�  � �J�u�z�*�  �� �3�� � �� � � � � � rr2� __contextrVrWrc�J�|j|�d��g|�Ri|��S)Nr)�call�resolve)rkrVrWs r�_gettext_aliasro�s4�� �9�>�)�+�+�I�6�6� H�� H� H� H�� H� H�Hr�funcc �p��tdtdtdtjdtf�fd� ��}|S)Nrk�__string� variablesrc�p��|��|��}|jjrt|��}||zSr)rm�eval_ctx� autoescaper)rkrrrsrCrps �rrz"_make_new_gettext.<locals>.gettext�s;��� �^�^�D�(� +� +�� � � (� �����B��I�~�r�rr r&r^�Any)rprs` r�_make_new_gettextry�sP�����7��c�����#�������\�� �Nrc ���tdtdtdtdtdtjdtf �fd� ��}|S)Nrk� __singular�__plural�__numrsrc���|�d|��|��|||��}|jjrt |��}||zS)N�num�� setdefaultrmrurvr)rkr{r|r}rsrCrps �rr"z$_make_new_ngettext.<locals>.ngettext�sU��� ���U�E�*�*�*� �^�^�D�*�h�� >� >�� � � (� �����B��I�~�r�rr r&r'r^rx)rpr"s` r�_make_new_ngettextr��sl���� �� �� �� �� � �U� � � � � � � ��\� � �Orc �~��tdtdtdtdtjdtf �fd� ��}|S)Nrk� __string_ctxrrrsrc���|�d|��|��||��}|jjrt |��}||zS)Nr*r�)rkr�rrrsrCrps �rr,z$_make_new_pgettext.<locals>.pgettext�sU��� ���Y� �5�5�5� �^�^�D�,�� 9� 9�� � � (� �����B��I�~�rrw)rpr,s` r�_make_new_pgettextr��s\���� �� �*-� �9<� �KL�5� � � � � � � ��\� � �Orc���tdtdtdtdtdtdtjdtf�fd� ��}|S) Nrkr�r{r|r}rsrc����|�d|��|�d|��|��||||��}|jjrt |��}||zS)Nr*rr�)rkr�r{r|r}rsrCrps �rr.z&_make_new_npgettext.<locals>.npgettext�so��� ���Y� �5�5�5����U�E�*�*�*� �^�^�D�,� �H�e� L� L�� � � (� �����B��I�~�rr�)rpr.s` r�_make_new_npgettextr��sy������������ � � � �U� � �������\��$ �rc����eZdZdZdhZdeddf�fd� Z d&ddd eje ddfd �Z d&d eje ddfd �Z d'd ej e ge fd ej e e ege fd eje dejej e e ge fdejej e e e ege fddf d�Zd(d�Zefdeje ejfdeje dejejee ejeje ejeje dffffd�Zdddejejejejffd�Zefde deje de fd�Zddde dejeje e ffd�Zde deje d eje d!ej e ej!fd"ejej!d#e d$e dej"fd%�Z#�xZ$S))�InternationalizationExtensionz-This extension adds gettext support to Jinja.�transr:rNc����t���|��t|jd<|�|j|j|j|j|j d���dS)Nr/F)�install_gettext_translations�install_null_translations�install_gettext_callables�uninstall_gettext_translations�extract_translations�newstyle_gettext) �superr<ro�globals�extend�_install� _install_null�_install_callables� _uninstall�_extract)rr:r@s �rr<z&InternationalizationExtension.__init__sm��� ������%�%�%�#1� ��C� ����)-��&*�&8�&*�&=�+/�?�!%��"� � � � � � r� translations�_SupportedTranslations�newstylec���t|dd��}|�|j}t|dd��}|�|j}t|dd��}t|dd��}|�|||||���dS)N�ugettext� ungettextr,r.)r�r,r.)�getattrrr"r�)rr�r�rr"r,r.s rr�z&InternationalizationExtension._installs��� �,� �D�9�9�� �?�"�*�G��<��d�;�;�� � �#�,�H��<��T�:�:���L�+�t�<�<� � ��� �X��8�y� � � � � � rc �^�ddl}|���}t|d��r|j}ndtdtdtfd�}t|d��r|j}n'dtdtdtd t dtf d �}|�|j|j|||� ��dS) Nrr,�c�src��|Srr)r�r�s rr,z=InternationalizationExtension._install_null.<locals>.pgettext*s���rr.�pr c��|dkr|n|S)Nrr)r�r�r�r s rr.z>InternationalizationExtension._install_null.<locals>.npgettext1s����F�F�q�q��)r)rr"r�r,r.) r�NullTranslations�hasattrr,r&r.r'r�r")rr�rr�r,r.s rr�z+InternationalizationExtension._install_null s��������/�/�1�1� � �<�� ,� ,� �#�,�H�H� �C� �C� �C� � � � � �<�� -� -� *�$�.�I�I� *�S� *�S� *�S� *�S� *�S� *� *� *� *� ��� �(�!�*���� � � � � � rrr"r,r.c��|� ||j_|jjr@t|��}t|��}|�t |��}|�t |��}|jj�||||���dS�N)rr"r,r.)r:r�ryr�r�r�r�rB)rrr"r�r,r.s rr�z0InternationalizationExtension._install_callables<s��� � �08�D� � -� � � ,� ;�'��0�0�G�)�(�3�3�H��#�-�h�7�7���$�/� �:�:� � �� �'�'��h��Y� (� � � � � rc�P�dD]"}|jj�|d���#dSr�)r:r��pop)rr��keys rr�z(InternationalizationExtension._uninstallTs:��C� 4� 4�C� � � $� (� (��d� 3� 3� 3� 3� 4� 4rrE�gettext_functions.c��t|t��r|j�|��}t ||��Sr)� isinstancer&r:rP�extract_from_ast)rrEr�s rr�z&InternationalizationExtension._extractXs=�� �f�c� "� "� 4��%�+�+�F�3�3�F���(9�:�:�:rrMrc ��t|j��j}d}|j�d��}|�|j}d}d}d}i}d} |jjjdk�r�|r|j�d��|j�d��r�nX|j�d��} | j|vr+|� d| j�d �| jt� ��|jjjd kr3t|j��|� ��x|| j<} n;| �| jd vr | jd k} ��tj | jd��x|| j<} |�ot| tj��rHtj dd��}||| j<tjtj dd��| ��}n| }| jdk}|jjjdk���|j�d��d} d} t#��}|�|d��\}}|r>|�|��|�'tj |dd��}|ddk}|jj�d��r�d} t|j��|jjjdkrf|j�d��} | j|vr+|� d| j�d�| jt� ��|| j}| jdk}|j�d��|�|d��\}} t|j��|�|��nt|j��|D]}||vrtj |d��||<�| sd}n|�|� d|��| �|jjd} | r,|�|��}| r|�| ��} |�|| |||t3|��|o| ��}|�|��|�||gS|S)zParse a translatable tag.N�stringF� block_end�comma�colonrFztranslatable variable z defined twice.)�exc�assign)�trimmed� notrimmedr��load�_trans�storerTrzname:pluralizezunknown variable z for pluralizationzpluralize without variables�ext.i18n.trimmed)�nextrJrQ�next_if�value�current�type�expect�skip_if�failr�parse_expressionr�Namer�r[�Assignra� _parse_blockrB�testr:�policies�_trim_whitespace� _make_node�bool� set_lineno)rrMrQr*� context_token� plural_expr�plural_expr_assignment�num_called_numrsr��token�varr� have_plural� referenced�singular_namesr� plural_namesrF�nodes rrPz#InternationalizationExtension.parsecs����f�m�$�$�+����� �-�-�h�7�7� � � $�#�)�G� /3� �;?����-/� ����m�#�(�K�7�7�� .�� �$�$�W�-�-�-��}�$�$�W�-�-� ���M�(�(��0�0�E��{�i�'�'�� � �K�U�[�K�K�K��L�.������}�$�)�X�5�5��V�]�#�#�#�/5�/F�/F�/H�/H�H� �%�+�&�����U�[�4L�%L�%L��+��2���/4�z�%�+�v�/N�/N�N� �%�+�&���"��c�5�:�.�.�&�"'�*�X�v�">�">�K�-8�I�e�k�*�-2�\�� �8�W�5�5�s�.�.�*�*�#&�K�!&���!5��G�m�#�(�K�7�7�J � ���[�)�)�)���� ��U�U� �$(�#4�#4�V�T�#B�#B� ��� � <� � � �n� -� -� -��"�#�j���):�F�C�C� �!/��!2�e�!;�� �=� � %� %�&6� 7� 7� ��K� ��� � � ��}�$�)�[�8�8�� �,�,�V�4�4���;�i�/�/��K�K�M�E�K�M�M�M�� �2� ���� (�� �4� �!&���!5�� �M� � �� -� -� -�#'�#4�#4�V�U�#C�#C� �L�&� ��� � � � � � �l� +� +� +� +� ��� � � �� ;� ;�D��9�$�$�"'�*�T�6�":�":� �$���� ?��K�K� � � �K�K�5�v� >� >� >� �?��&�/�0B�C�G� � 7��,�,�X�6�6�H�� 7��.�.�v�6�6����� � � � � � �� � � � *�{� � �� ������� !� -�*�D�1� 1��Krr��_ws_rec�R�|�d|�����S)N� )�sub�strip)rr�r�s rr�z.InternationalizationExtension._trim_whitespace�s���z�z�#�v�|�|�~�~�.�.�.r�allow_pluralizec���g}g} |jjjdkrN|�|jjj�dd����t |j���nn|jjjdkr|t |j��|j�d��j}|�|��|�d|�d���|j�d ��n�|jjjd kr�t |j��|jjjdkr|jjjnd }|d krn�|d kr|rn~|�d��n|dkr|�d��|�d|�d���n1|jj r|�d��ntd������|t|��fS)z1Parse until the next block tag with a given name.T�data�%�%%�variable_beginrFz%(z)s� variable_end� block_beginN�endtrans� pluralizez:a translatable section can have only one pluralize sectionr�z6trans blocks can't be nested; did you mean `endtrans`?zBcontrol structures in translatable sections are not allowed; saw `�`zunclosed translation blockzinternal parser error) rJr�r��appendr��replacer�r�r��eos� RuntimeErrorr )rrMr�r��bufrF� block_names rr�z*InternationalizationExtension._parse_block�s"��� ���$ <��}�$�)�V�3�3�� � �6�=�0�6�>�>�s�D�I�I�J�J�J��V�]�#�#�#�#���&�+�/?�?�?��V�]�#�#�#��}�+�+�F�3�3�9���!�!�$�'�'�'�� � �=��=�=�=�)�)�)�� �$�$�^�4�4�4�4���&�+�}�<�<��V�]�#�#�#��}�,�1�V�;�;��M�)�/�/��� ��+�+���;�.�.�&����K�K�T����� �7�*�*��K�K�P����� � �*�&�*�*�*�������"� <�� � �8�9�9�9�9�"�#:�;�;�;�I$ <�L�6�#�;�;�&�&rrrr*rsr��vars_referencedr�c�B�|jj}|s0|s.|�dd��}|r|�dd��}d} tj|��g} |�-| �dtj|����d| ��} |�.d| ��} | �tj|��|f��tjtj| d��| gdd��} |rQ|� ��D];\} } |r| d kr�| j � tj | | �����<nYtj | ��} |rCtj| tjd �|� ��D������} tj| g��S) z/Generates a useful node from the data provided.r�r�rNrr�r r�rc�b�g|],\}}tjtj|��|����-Sr)r�Pair�Const)�.0r�r�s r� <listcomp>z<InternationalizationExtension._make_node.<locals>.<listcomp>EsB����� *��U�"�J�u�{�3�'7�'7��?�?���r)r:r�r�rr��insertr�r[r��itemsrWr�rj�MarkSafeIfAutoescape�Mod�Dict�Output)rrrr*rsr�r�r�r�� func_name� func_argsr�r�r�s rr�z(InternationalizationExtension._make_nodes����#�4�� � 3�x� 3��'�'��c�2�2�H�� 3�����c�2�2��� �).��X�)>�)>�(?� � � � � � �Q�� �G� 4� 4� 5� 5� 5�'�I���I� � "�'�I���I� � � �e�k�&�1�1�;�?� @� @� @��z�%�*�Y��7�7��B��d�S�S�� � �'�o�o�/�/� >� >� ��U�"��c�U�l�l��� �"�"�5�=��e�#<�#<�=�=�=�=�  >��-�d�3�3�D�� ��y���J���.7�o�o�.?�.?����������|�T�F�#�#�#rr)NNN)r�r�rN)%r#r$r%r]r8rr<r^rdr�r�r��Callabler&r'r�r�r0rer�Template�Sequence�Iterator�Tupler�rgrhrPr��Patternr�r�rrirr�� __classcell__)r@s@rr�r��s[�������7�7� �9�D�  �K�  �D�  �  �  �  �  �  �TX� � �4� �@A� �4�@P� � � � � � �$ � �a�j��&6� �$� � � � �@&*�<@�GK�  � ���S�E�3�J�'� ��*�c�3��_�c�1�2� ��*�T�"�  � �*�Q�Z��c� �C��8�9�  � �:�a�j�#�s�C��)=�s�)B�C�D�  � � � � � �04�4�4�4�.?� ;� ;����U�^�+�,� ;��:�c�?� ;� �� ���S�!�'�!�*�S�/�1�7�1�:�c�?�C�;O�3P�"P�Q�Q�R� � ;� ;� ;� ;�x�H�x�����Q�V�E�J�=O�1O�)P�x�x�x�x�tFL�/�/�s�/�A�I�c�N�/�PS�/�/�/�/�-'��-'�15�-'� ������c�!� "�-'�-'�-'�-'�^<$��<$�� �3��<$���C�� <$� �6�#�u�z�/�*� <$� �Z�� �+� <$��<$��<$� ��<$�<$�<$�<$�<$�<$�<$�<$rr�c�2�eZdZdZdhZdddejfd�ZdS)�ExprStmtExtensionzrAdds a `do` tag to Jinja that works like the print statement just that it doesn't print the return value. �dorMrrc��tjt|j��j���}|���|_|S)NrS)r�ExprStmtr�rJrQ� parse_tupler�)rrMr�s rrPzExprStmtExtension.parseUs9���~�T�&�-�%8�%8�%?�@�@�@���&�&�(�(�� �� rN)r#r$r%r]r8rrrPrrrr r NsK�������� �6�D��H���������rr c�X�eZdZdZddhZdddejejej ffd�Z dS) �LoopControlExtensionz/Adds break and continue to the template engine.�break�continuerMrrc��t|j��}|jdkrtj|j���Stj|j���S)NrrS)r�rJr�r�BreakrQ�Continue)rrMr�s rrPzLoopControlExtension.parse`sH���V�]�#�#�� �;�'� !� !��;�e�l�3�3�3� 3��~�U�\�2�2�2�2rN) r#r$r%r]r8r^rerrrrPrrrrr[sV������9�9� �Z� �D�3�H�3�����e�n�1L�)M�3�3�3�3�3�3rrc�B�eZdZdZdhZdddejfd�Zdede fd�Z d S) �DebugExtensiona�A ``{% debug %}`` tag that dumps the available variables, filters, and tests. .. code-block:: html+jinja <pre>{% debug %}</pre> .. code-block:: text {'context': {'cycler': <class 'jinja2.utils.Cycler'>, ..., 'namespace': <class 'jinja2.utils.Namespace'>}, 'filters': ['abs', 'attr', 'batch', 'capitalize', 'center', 'count', 'd', ..., 'urlencode', 'urlize', 'wordcount', 'wordwrap', 'xmlattr'], 'tests': ['!=', '<', '<=', '==', '>', '>=', 'callable', 'defined', ..., 'odd', 'sameas', 'sequence', 'string', 'undefined', 'upper']} .. versionadded:: 2.11.0 �debugrMrrc���|j�d��j}tj��}|�d|g|���}tj|g|���S)Nz name:debug�_renderrS)rJr�rQr�ContextReferencer\r)rrMrQr*�results rrPzDebugExtension.parse~s[����%�%�l�3�3�:���(�*�*���!�!�)�g�Y�v�!�F�F���|�V�H�V�4�4�4�4rr*c��|���t|jj�����t|jj�����d�}t j|dd���S)N)r*�filters�tests�T)�depth�compact)�get_all�sortedr:r �keysr!�pprint�pformat)rr*rs rrzDebugExtension._render�sn�����(�(��d�.�6�;�;�=�=�>�>��D�,�2�7�7�9�9�:�:� � ���~�f�A�t�<�<�<�<rN) r#r$r%r]r8rrrPr r&rrrrrrgsm��������( �9�D�5�H�5���5�5�5�5� =�w�=�3�=�=�=�=�=�=rrT�astr�� babel_stylec#��K�|�tj��D�]Y}t|jtj��r|jj|vr�1g}|jD]f}t|tj��r5t|j t��r|� |j ���Q|� d���g|j D]}|� d���|j �|� d��|j�|� d��|std�|D����}|s��n+t!|��dkr |d}nt|��}|j|jj|fV���[dS)a�Extract localizable strings from the given template node. Per default this function returns matches in babel style that means non string parameters as well as keyword arguments are returned as `None`. This allows Babel to figure out what you really meant if you are using gettext functions that allow keyword arguments for placeholder expansion. If you don't want that behavior set the `babel_style` parameter to `False` which causes only strings to be returned and parameters are always stored in tuples. As a consequence invalid gettext calls (calls without a single string parameter or string parameters after non-string parameters) are skipped. This example explains the behavior: >>> from jinja2 import Environment >>> env = Environment() >>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}') >>> list(extract_from_ast(node)) [(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))] >>> list(extract_from_ast(node, babel_style=False)) [(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))] For every string found this function yields a ``(lineno, function, message)`` tuple, where: * ``lineno`` is the number of the line on which the string was found, * ``function`` is the name of the ``gettext`` function used (if the string was extracted from embedded Python code), and * ``message`` is the string, or a tuple of strings for functions with multiple string arguments. This extraction function operates on the AST and is because of that unable to extract any comments. For comment support you have to use the babel extraction interface or extract comments yourself. Nc3�K�|]}|�|V�� dSrr)r��xs r� <genexpr>z#extract_from_ast.<locals>.<genexpr>�s"����<�<�a�a�m��m�m�m�m�<�<rrr)�find_allrr[r�r�r�rFrVr�r�r&r�rWrXrY�tuple�lenrQ)r*r�r+r��strings�argr/�outs rr�r��s�����V� � �U�Z�(�(�!/�!/���4�9�e�j�1�1� ��y�~�%6�6�6� �+-���9� %� %�C��#�u�{�+�+� %� �3�9�c�0J�0J� %����s�y�)�)�)�)����t�$�$�$�$��� !� !�A� �N�N�4� � � � � �=� $� �N�N�4� � � � �?� &� �N�N�4� � � �� %��<�<�7�<�<�<�<�<�C�� �� ��7�|�|�q� � ��a�j����G�n�n���k�4�9�>�3�.�.�.�.�.�C!/�!/rc��eZdZdZdejejeeefdejeddfd�Z dedej efd�Z d edej efd �Z dS) �_CommentFinderz�Helper class to find comments in a token stream. Can only find comments for gettext calls forwards. Once the comment from line 4 is found, a comment for line 1 will not return a usable value. �tokens� comment_tagsrNc�>�||_||_d|_d|_dS)Nr)r8r9�offset� last_lineno)rr8r9s rr<z_CommentFinder.__init__�s(���� �(����� �����rr;c�*� t|j|j|���D]\\}}}|dvrR |�dd��\}}n#t$rY�1wxYw||jvr|���gc||_S�]g||_S#||_wxYw)N)�comment� linecommentr)�reversedr8r;�split� ValueErrorr9�rstrip)rr;r/� token_type� token_value�prefixr>s r�find_backwardsz_CommentFinder.find_backwards�s��� !�.6�� �D�K�&�0�1�/�/� 2� 2�*��:�{��!;�;�;�!�*5�*;�*;�D�!�*D�*D������%�!�!�!� ��!������!2�2�2� '��� 0� 0�1�1�1�!�D�K�K��� �D�K�K��&�D�K� � � � s4�+B �A�B � A�B �A�"B �?B � BrQc��|jr |j|krgSt|j|jd���D].\}\}}}||kr|�|j|z��cS�/|�t |j����Sr)r9r<� enumerater8r;rGr2)rrQ�idx� token_linenor/s r� find_commentsz_CommentFinder.find_comments�s���� � �D�$4�v�$=�$=��I�)2�4�;�t�{�}�}�3M�)N�)N� >� >� %�C�%�,��1��f�$�$��*�*�4�;��+<�=�=�=�=�=�%��"�"�3�t�{�#3�#3�4�4�4r) r#r$r%r]r^rrr'r&r<rhrGrLrrrr7r7�s��������� ��j����c�3��!7�8��HI� �SV��� �����!�S�!�Q�V�C�[�!�!�!�!� 5�C�5�A�F�3�K�5�5�5�5�5�5rr7�fileobj�keywordsr9�optionsc#�@K�i}|�dd���d��D]+}|���}|s�d|t|��<�,t|vr d|t<ddt jttfdtdtd tfd �}||d d ��}t|�d tj ��|�dtj ��|�dtj ��|�dtj��|�dtj��|�dtj��|�d��p tj|�d��p tj||dtj��||dtj��tj||dtj��t/|��dd���}||d��r d |jd<||d��rd |_|����|�dd����} |�| ��} t;|�|�| ������} n#t@$r|s�YdSwxYwtC| |��} tE| |��D]!\} }}| ||| �#| ��fV��"dS) aBabel extraction method for Jinja templates. .. versionchanged:: 2.3 Basic support for translation comments was added. If `comment_tags` is now set to a list of keywords for extraction, the extractor will try to find the best preceding comment that begins with one of the keywords. For best results, make sure to not have more than one gettext call in one line of code and the matching comment in the same line or the line before. .. versionchanged:: 2.5.1 The `newstyle_gettext` flag can be set to `True` to enable newstyle gettext calls. .. versionchanged:: 2.7 A `silent` option can now be provided. If set to `False` template syntax errors are propagated instead of being ignored. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions :param comment_tags: a list of translator tags to search for and include in the results. :param options: a dictionary of additional options (optional) :return: an iterator over ``(lineno, funcname, message, comments)`` tuples. (comments will be empty currently) � extensions��,NFrOr��defaultrc�p�|�|t|�������dvS)N>�1�on�yes�true)�getr&�lower)rOr�rTs r�getboolzbabel_extract.<locals>.getbool8s.���{�{�3��G� � �-�-�3�3�5�5�9S�S�Sr�silentT�block_start_string�block_end_string�variable_start_string�variable_end_string�comment_start_string�comment_end_string�line_statement_prefix�line_comment_prefix� trim_blocks� lstrip_blocks�keep_trailing_newliner)� cache_size� auto_reloadr�r�r��encodingzutf-8)F)$rZrAr�r r�r^�Mappingr&r�rr�BLOCK_START_STRING�BLOCK_END_STRING�VARIABLE_START_STRING�VARIABLE_END_STRING�COMMENT_START_STRING�COMMENT_END_STRING�LINE_STATEMENT_PREFIX�LINE_COMMENT_PREFIX� TRIM_BLOCKS� LSTRIP_BLOCKS�NEWLINE_SEQUENCE�KEEP_TRAILING_NEWLINEr1r�r��read�decoderP�list�lexrIr r7r�rL)rMrNr9rOrQ�extension_namer\r]r:rEr�r8�finderrQrprs r� babel_extractrs2����J35�J�!�+�+�l�B�7�7�=�=�c�B�B�9�9��'�-�-�/�/��� � �48� �=��0�0�1�1�$�J�6�6�48� �0�1�T�T���3��8�,�T�3�T��T�RV�T�T�T�T��W�W�h�� -� -�F��� � �(�(�*E�F�F�� � �&��(A�B�B�� � �+�X�-K�L�L�� � �)�8�+G�H�H�� � �*�H�,I�J�J�� � �(�(�*E�F�F�� � �+�,�,�N��0N�� � �)�*�*�J�h�.J������(<�=�=�����(�*@�A�A��!����0�(�2P�Q�Q� �j��������K�$�w�w� �"�"�8�37� ��/�0��w�w�*�+�+�,�'+� �$� �\�\�^�^� "� "�7�;�;�z�7�#C�#C� D� D�F��� � ��(�(���k�o�o�k�&<�&<�V�&D�&D�E�E�F�F���� ����� � ���� ���� �F�L� 1� 1�F�!1�$��!A�!A�B�B����g��d�G�V�%9�%9�&�%A�%A�A�A�A�A�A�B�Bs�=A K� K�K)Er]r(�re�typingr^� markupsaferrRrrr:r� exceptionsrr �runtimer r r �utilsr r� TYPE_CHECKING�typing_extensions�te�lexerrrrMr�Protocolrr)rer�r0rr&r`�compiler�r2rxrorryr'r�r�r�r�r rrrrr�rrdr�r7�BinaryIOrrhr�i18nr � loopcontrolsrrrr�<module>r�s���8�8�8� � � � � � � � �����������������������$�$�$�$�$�$�.�.�.�.�.�.�+�+�+�+�+�+������������������� � � � � � ��������?�O�"�"�"�"�������"�"�"�"�"�"������������R�[���� �����1�����W�%7�9M�%M�N�� (��1�7�3��8�$���� ���K� � ��j �j �j �j �j �j �j �j �Z�I��I� �u�I�01��I��W�Q�U�I� ��I�I�I���I� �A�J��u�c�z�2� �q�z�#�s�(�7K� � � � ��Q�Z��c�3���(<�=��!�*�S�RU�X�BV�����&�Q�Z��c� �C��8��Q�Z��S��=Q�����"� �*�c�3��S�)�3�.� /���Z��S�������2U$�U$�U$�U$�U$�I�U$�U$�U$�p � � � � � � � � � 3� 3� 3� 3� 3�9� 3� 3� 3�%=�%=�%=�%=�%=�Y�%=�%=�%=�T*;��L/�L/� ��L/��z�#��L/��L/��Z��G�C��a�g�a�j��o�q�w�q�z�#���7K�/L�L�M� M�N�� L/�L/�L/�L/�^%5�%5�%5�%5�%5�%5�%5�%5�PYB� �Z�YB��j��o�YB��*�S�/�YB��V�C���J� � YB� �Z��G� �S�!�'�!�*�S�/�1�7�1�:�c�?�C�3G�+H�H�I�1�6�RU�;�V��� YB�YB�YB�YB�z%����#� ����r
Memory