Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ext.cpython-313.pyc328 linesDownload Raw Back to __pycache__
1�

2��j�|��X�%SrSSKrSSKrSSKrSSKJr SSKJr SSKJ	r	 SSK3Jr SSKJ
r
 SS	KJr SS4KJr SSKJr SSKJr SS
KJr SSKJr \R,(aGSSKrSSKJr SSKJr SSKJr "SS\R<5r"SS\5r \RB\\ 4r"Sr#\RH\%S4\&S'\RN"S5r("SS5r)\S\S\RTS\RTS\RB\RT\44S j5r+S!\RX\%/\%4S\RXS\%44S"jr-S!\RX\%\%\./\%4S\RXS\%44S#jr/S!\RX\%\%/\%4S\RXS\%44S$jr0S!\RX\%\%\%\./\%4S\RXS\%44S%jr1"S&S'\)5r2"S(S)\)5r3"S*S+\)5r4"S,S-\)5r5\#S.4S/\	RlS0\Rn\%S1\8S\Rr\RH\.\%\RB\Rt\%\RH\Rt\%S4444S2jjr;"S3S45r<S5\RzS6\Rn\%S7\Rn\%S8\R|\%\RT4S\Rr\RH\.\%\RB\Rt\%\RH\Rt\%S44\R~\%445S9jr@\2rA\3rB\4rC\5rDg):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�@�\rSrSrS\S\4SjrS\S\S\S\4SjrS	rg6)�_TranslationsBasic��message�returnc��g�N�)�selfrs  �PD:\code\apps\devtools\python\user_packages\Python313\site-packages\jinja2/ext.py�gettext�_TranslationsBasic.gettexts����singular�plural�nc��grr)rrr r!s    r�ngettext�_TranslationsBasic.ngettexts��rrN)	�__name__�7__module__�__qualname__�__firstlineno__�strr�intr#�__static_attributes__rrrrrs0��3�3�3�3�3�	�S�	�#�	�#�	�#�	rrc8�H�\rSrSrS\S\S\4SjrS\S\S\S\S\49S	jrS10rg)�_TranslationsContext�!�contextrrc��grr)rr/rs   r�pgettext�_TranslationsContext.pgettext"s��srrr r!c��grr)rr/rr r!s     r�	npgettext�_TranslationsContext.npgettext$s��rrN)	r%r&r'r(r)r1r*r4r+rrrr-r-!sA��B�C�B�#�B�#�B�	��	�*-�	�7:�	�?B�	�
�	rr-)�_rr#r1r4.�GETTEXT_FUNCTIONSz\s*\n\s*c�J�\rSrSr%Sr\R\\S'S Sjr	\11"5r\R\\S'Sr
S	\SS4S12jrS	\SS4SjrS!S
\S\R"\S\R"\S\4SjjrSSS\R&S\R(S44SjrSSS\R&\R.\R0\R.44SjrS!S\S\R"\S\R64SjjrS"S\S\R"\R0\R:S\R"\R0\R<S\R"\R:S\R"\R:S\R"\S\R>4Sjjr Sr!g)#�	Extension�7a+Extensions can be used to add extra functionality to the Jinja template13system at the parser level.  Custom extensions are bound to an environment14but may not store environment specific data on `self`.  The reason for15this is that an extension can be bound to another environment (for16overlays) by creating a copy and reassigning the `environment` attribute.17 18As extensions are created by the environment they cannot accept any19arguments for configuration.  One may want to work around that by using20a factory function, but that is not possible as extensions are identified21by their import name.  The correct way to configure the extension is22storing the configuration values on the environment.  Because this way the23environment ends up acting as central configuration storage the24attributes may clash which is why extensions have to ensure that the names25they choose for configuration are not too generic.  ``prefix`` for example26is a terrible name, ``fragment_cache_prefix`` on the other hand is a good27name as includes the name of the extension (fragment cache).28�29identifierrNc�D�URSUR3Ulg)N�.)r&r%r;)�clss r�__init_subclass__�Extension.__init_subclass__Ls���N�N�+�1�S�\�\�N�;��r�tags�d�environmentc��Xlgr�rC)rrCs  r�__init__�Extension.__init__Ys��&�rzte.Selfc��[RUR5nURR	UR5 XlU$)z=Create a copy of this extension bound to another environment.)�object�__new__�	__class__�__dict__�updaterC)rrC�rvs   r�bind�Extension.bind\s4��
�^�^�D�N�N�
+��30�����4�=�=�)�$���	r�source�name�filenamec��U$)z�This method is called before the actual lexing and can be used to31preprocess the source.  The `filename` is optional.  The return value32must be the preprocessed source.33r)rrQrRrSs    r�34preprocess�Extension.preprocesscs	���
r�streamrrc��U$)z�It's passed a :class:`~jinja2.lexer.TokenStream` that can be used35to filter tokens returned.  This method has to return an iterable of36:class:`~jinja2.lexer.Token`\s, but it doesn't have to return a37:class:`~jinja2.lexer.TokenStream`.38r)rrWs  r�
filter_stream�Extension.filter_streamls	���
r�parserrc��[5e)z�If any of the :attr:`tags` matched this method is called with the39parser as first argument.  The token the parser stream is pointing at40is the name token that matched.  This method has to return one or a41list of multiple nodes.42)�NotImplementedError)rr[s  r�parse�Extension.parsevs
��"�#�#r�linenoc�@�[R"URXS9$)z�Return an attribute node for the current extension.  This is useful43to pass constants on extensions to generated template code.44 45::46 47    self.attr('_my_attribute', lineno=lineno)48�r`)r�ExtensionAttributer;)rrRr`s   r�attr�Extension.attr~s���'�'�����M�Mr�args�kwargs�dyn_args�49dyn_kwargsc	�b�Uc/nUc/n[R"URXS9UUUUUS9$)zcCall a method of the extension.  This is a shortcut for50:meth:`attr` + :class:`jinja2.nodes.Call`.51rb)r�Callrd)rrRrfrgrhrir`s       r�call_method�Extension.call_method�sF���<��D��>��F��z�z��I�I�d�I�*������
52�	53rrE)rNr)NNNNN)"r%r&r'r(�__doc__�t�ClassVarr)�__annotations__r?�setrA�Set�priorityrrFrO�OptionalrU�Union�IterablerYr�Node�Listr^r*rcrd�Expr�Keywordrkrlr+rrrr9r97s����$�54�55�3���<��u�D�!�%�%��*���H�'�K�'�D�'����	��OS����!"���C���<=�J�J�s�O��	���#��	56�����57�58�7� 3�3�	4��$�H�$�������Q�V�V�E�J�J�=O�1O�)P�$�48�59N��60N�!"���C��61N�	�	!�	!�62N�04�48�+/�-1�"&�63��64��j�j�����65�66�+�,�67��68�69�1�6�6�%�-�-�0�1�	70�71�*�*�U�Z�Z�(�72��J�J�u�z�z�*�
73��74�75�3��76�77���78�79rr9�	__contextrfrgrc�L�UR"URS5/UQ70UD6$)Nr)�call�resolve)r|rfrgs   r�_gettext_aliasr��s(���>�>�)�+�+�I�6�H��H��H�Hr�funcc	�n^�[S[S[S[RS[4U4Sjj5nU$)Nr|�__string�	variablesrc�|>�URTU5nURR(a[U5nX2-$r)r~�eval_ctx�80autoescaper)r|r�r�rNr�s    �rr�"_make_new_gettext.<locals>.gettext�s5���
�^�^�D�(�
+�����(�(����B��~�r�rrr)ro�Any)r�rs` r�_make_new_gettextr��s<�����7��c������#�����Nrc
�^�[S[S[S[S[S[R81S[4U4Sjj5nU$)Nr|�82__singular�__plural�__numr�rc�>�URSU5 URTXU5nURR(a[	U5nXT-$)N�num��83setdefaultr~r�r�r)r|r�r�r�r�rNr�s      �rr#�$_make_new_ngettext.<locals>.ngettext�sG���	���U�E�*�
�^�^�D�*��
>�����(�(����B��~�r�rrr)r*ror�)r�r#s` r�_make_new_ngettextr��sX������������	�84�U�U��85
�
����Orc�z^�[S[S[S[S[RS[486U4Sjj5nU$)Nr|�__string_ctxr�r�rc�>�URSU5 URTX5nURR(a[	U5nXC-$)Nr/r�)r|r�r�r�rNr�s     �rr1�$_make_new_pgettext.<locals>.pgettext�sG���	���Y��5�
�^�^�D�,�
9�����(�(����B��~�rr�)r�r1s` r�_make_new_pgettextr��sH����87��88�*-�89�9<�90�KL�5�5�91�	�92��93��Orc�^�[S[S[S[S[S[S[R94S[4U4Sjj5nU$)	Nr|r�r�r�r�r�rc��>�URSU5 URSU5 URTXX45nURR(a[	U5nXe-$)Nr/r�r�)r|r�r�r�r�r�rNr�s       �rr4�&_make_new_npgettext.<locals>.npgettext�sY���	���Y��5����U�E�*�
�^�^�D�,�H�
L�����(�(����B��~�rr�)r�r4s` r�_make_new_npgettextr��se������������	�95���U�U�
�96
����$�rc�^�\rSrSrSrS1rS\SS4U4SjjrS(SS	S97\R\98SS4SjjrS(S99\R\100SS4SjjrS)S
\R\/\4S\R\\\/\4S101\R\102S\R\R\\/\4S\R\R\\\\/\4SS4SjjrS*Sjr\4S\R&\\R*4S\R,\S\R.\R0\\\R&\R\\R0\R\S4444SjjrSSS\R&\R4\R6\R444Sjr\4S\S\R<\S\4SjjrSSS\103S\R0\R6\\44Sjr S\S \R\S!\R\S"\RB\\RD4S#\R\RDS$\104S%\105S\RF4S&jr$S'r%U=r&$)+�InternationalizationExtension��z-This extension adds gettext support to Jinja.�transrCrNc	��>�[TU]U5 [URS'UR	UR106URURURURSS9 g)Nr6F)�install_gettext_translations�install_null_translations�install_gettext_callables�uninstall_gettext_translations�extract_translations�newstyle_gettext)107�superrFr��globals�extend�_install�
_install_null�_install_callables�108_uninstall�_extract)rrCrKs  �rrF�&InternationalizationExtension.__init__s]���
����%�#1����C� ����)-���&*�&8�&8�&*�&=�&=�+/�?�?�!%���"�
	�	109r�translations�_SupportedTranslations�newstylec���[USS5nUcURn[USS5nUcURn[USS5n[USS5nURX4X%US9 g)N�ugettext�	ungettextr1r4)r�r1r4)�getattrrr#r�)rr�r�rr#r1r4s       rr��&InternationalizationExtension._installsw��110�,�111�D�9���?�"�*�*�G��<��d�;����#�,�,�H��<��T�:���L�+�t�<�	������y�	 �	112rc113�f�SSKnUR5n[US5(a
URnOS[S[S[4Sjn[US5(a
UR114nO#S[S[S[S	[S[4115S116jnURURURUUUS9 g)Nrr1�c�src��U$rr)r�r�s  rr1�=InternationalizationExtension._install_null.<locals>.pgettext*s���rr4�pr!c��US:XaU$U$)Nrr)r�r�r�r!s    rr4�>InternationalizationExtension._install_null.<locals>.npgettext1s����F�q�)��)r)rr#r�r1r4)	r�NullTranslations�hasattrr1r)r4r*r�r#)rr�rr�r1r4s      rr��+InternationalizationExtension._install_null s�����/�/�1���<��,�,�#�,�,�H�
�C�
�C�
�C�
��<��-�-�$�.�.�I�
*�S�
*�S�
*�S�
*�S�
*�S�
*�	
��� �(�(�!�*�*����	 �	117rrr#r1r4c��UbX0RlURR(a2[U5n[U5nUb[	U5nUb[U5nURRRXXES9 g�N)rr#r1r4)rCr�r�r�r�r�r�rM)rrr#r�r1r4s      rr��0InternationalizationExtension._install_callables<s}����08���-����,�,�'��0�G�)�(�3�H��#�-�h�7���$�/�	�:�	���� � �'�'���	(�	118rc�b�SH)nURRRUS5 M+ gr�)rCr��pop)rr��keys   rr��(InternationalizationExtension._uninstallTs)��C�C����$�$�(�(��d�3�DrrQ�gettext_functions.c�x�[U[5(aURRU5n[	X5$r)�119isinstancer)rCr^�extract_from_ast)rrQr�s   rr��&InternationalizationExtension._extractXs2���f�c�"�"��%�%�+�+�F�3�F���:�:rr[rc120�121�[UR5RnSnURRS5nUbURnSnSnSn0nSn	URR122RS:wGa�U(aURRS5 URRS5(aGO�URRS5n123U124RU;a.URSU125R<S	3U126R[S1279 URR128RS:Xa4[UR5 UR5=X�R'nOTU	c"U129RS;aU130RS
:Hn	GM?[R"U131RS5=X�R'nUc�[U[R5(aR[R"SS5nXXU132R'[R "[R"SS5U5nOUnU133RS:HnURR134RS:waGM�URRS5 SnSn
[#5nUR%US5unnU(a6UR'U5 Uc"[R"USS5nUSS:HnURR135R)S5(GaSn
[UR5 URR136RS:wavURRS5n137U138RU;a.URSU139R<S3U140R[S1419 X�RnU142RS:HnURRS5 UR%US5unn[UR5 UR'U5 O[UR5 UH%nUU;dM[R"US5UU'M' U
(dSnOUcURSU5 U	cUR*R,Sn	U	(a)UR/U5nU(aUR/U5nUR1UUUUU[3U5U=(a U
5nUR5U5 UbUU/$U$)zParse a translatable tag.N�stringF�	block_end�comma�colonrRztranslatable variable z defined twice.)�exc�assign)�trimmed�	notrimmedr��load�_trans�storer�Trzname:pluralizezunknown variable z for pluralizationzpluralize without variables�ext.i18n.trimmed)�nextrWr`�next_if�value�current�type�expect�skip_if�failr�parse_expressionr�Namer�rk�Assignrr�_parse_blockrM�testrC�policies�_trim_whitespace�143_make_node�bool�144set_lineno)rr[r`r/�
context_token�plural_expr�plural_expr_assignment�num_called_numr�r��token�varr �have_plural�145referenced�singular_namesr�plural_namesrR�nodes                    rr^�#InternationalizationExtension.parsecsD���f�m�m�$�+�+�����
�
�-�-�h�7�
��$�#�)�)�G�146/3��;?����-/�	����m�m�#�#�(�(�K�7���
�
�$�$�W�-��}�}�$�$�W�-�-���M�M�(�(��0�E��{�{�i�'����,�U�[�[�O�?�K��L�L�.����}�}�$�$�)�)�X�5��V�]�]�#�/5�/F�/F�/H�H�	�+�+�&����U�[�[�4L�%L��+�+��2���/4�z�z�%�+�+�v�/N�N�	�+�+�&���"��c�5�:�:�.�.�"'�*�*�X�v�">�K�-8�e�k�k�*�-2�\�\��147�148�8�W�5�s�.�*�#&�K�!&����!5��G�m�m�#�#�(�(�K�7�J	�
�
���[�)������U�149�$(�#4�#4�V�T�#B� �������n�-��"�#�j�j���):�F�C��!/��!2�e�!;���=�=� � �%�%�&6�7�7��K�������}�}�$�$�)�)�[�8��
�
�,�,�V�4���;�;�i�/��K�K�+�E�K�K�?�:L�M����2� ��150(���4��!&����!5���M�M� � ��-�#'�#4�#4�V�U�#C� �L�&���������l�+�������D��9�$�"'�*�*�T�6�":�	�$�����K�
�
 ��K�K�5�v�>��?��&�&�/�/�0B�C�G���,�,�X�6�H���.�.�v�6��������������*�{�151��	
�����!�-�*�D�1�1��Krr��_ws_rec�B�URSUR55$)N� )�sub�strip)rr�r�s   rr��.InternationalizationExtension._trim_whitespace�s���z�z�#�v�|�|�~�.�.r�allow_pluralizec�x�/n/nURRRS:XaVURURRRRSS55 [
UR5 GO�URRRS:Xa}[
UR5 URRS5RnURU5 URSUS35 URRS5 GOURRRS	:Xa�[
UR5 URRRS:Xa URRROS152nUS:XaO�US:XaU(aOzURS
5 OUS:XaURS5 URSUS35 O8URR(aURS5 O[S5eGM)U[U54$)z1Parse until the next block tag with a given name.�data�%�%%�variable_beginrRz%(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)rWr�r��appendr��replacer�r�r��eos�RuntimeErrorr153)rr[rr��bufrR�154block_names       rr��*InternationalizationExtension._parse_block�s����155�����}�}�$�$�)�)�V�3��156�157�6�=�=�0�0�6�6�>�>�s�D�I�J��V�]�]�#����&�&�+�+�/?�?��V�]�]�#��}�}�+�+�F�3�9�9���!�!�$�'��158�159�R��v�R�=�)��
�
�$�$�^�4����&�&�+�+�}�<��V�]�]�#��}�}�,�,�1�1�V�;��M�M�)�)�/�/���160��+���;�.�&���K�K�T�� �7�*��K�K�P������&�<�q�*�����"�"����8�9�"�#:�;�;�I�L�6�#�;�&�&rrr r/r�r��vars_referencedr�c�161�URRnU(d2U(d+URSS5nU(aURSS5nSn	[R"U5/n162Ub+U163RS[R"U55 SU	3n	Ub,SU	3n	U164R
[R"U5U45 [R"[R"U	S5U165/SS5nU(aXUR5HCup�U(aUS	:XaMURR[R"X�55 ME O�[R"U5nU(aw[R"U[R"UR5VV
s/sH0up�[R "[R"U5U
5PM2 sn
n55n[R""U/5$s sn
nf)166z/Generates a useful node from the data provided.rrrNrr�r!r�r�)rCr�rr�Const�insertr�rkr��itemsrgrr{�MarkSafeIfAutoescape�Mod�Dict�Pair�Output)rrr r/r�r�rr�r��	func_name�	func_argsr�r�r�s              rr��(InternationalizationExtension._make_nodes����#�#�4�4��167�x��'�'��c�2�H������c�2���	�).���X�)>�(?�	������Q����G� 4�5��I�;��I��"��I�;��I����e�k�k�&�1�;�?�@��z�z�%�*�*�Y��7��B��d�S��168�'�o�o�/�169��"�c�U�l�����"�"�5�=�=��#<�=�0��-�-�d�3�D���y�y���J�J�/8�o�o�.?��.?�170��"�J�J�u�{�{�3�'7��?�.?������|�|�T�F�#�#��
s�%7G?rr)NNN)r�r�rN)'r%r&r'r(rnrArrFrorur�r�r��Callabler)r*r�r�r7rvr�Template�Sequence�Iterator�Tupler�rxryr^r��Patternr�r�rrzrr�r+�
__classcell__)rKs@rr�r��s����7��9�D�171172�K�173174�D�175176�TX�177�4�178�@A�179�180�4�@P�181�	
�182�$183�a�j�j��&6�184�$�185�@&*�<@�GK�
186����S�E�3�J�'�187��*�*�c�3��_�c�1�2�188��*�*�T�"�	189�190�*�*�Q�Z�Z��c�191�C��8�9�192��:�:�a�j�j�#�s�C��)=�s�)B�C�D�
193�194�195�04�.?�	;�����U�^�^�+�,�	;��:�:�c�?�	;�196���	����S�!�'�'�!�*�*�S�/�1�7�7�1�:�:�c�?�C�;O�3P�"P�Q�Q�R�197�		;�x�H�x�������Q�V�V�E�J�J�=O�1O�)P�x�tFL�/�s�/�A�I�I�c�N�/�PS�/�-'��-'�15�-'�	198��������c�!�	"�-'�^<$��<$��199�200�3��<$����C��	<$�201�6�6�#�u�z�z�/�*�<$��Z�Z��202�203�+�
<$��<$��<$�204���<$�<$rr�c�D�\rSrSrSrS1rSSS\R4SjrSr	g	)205�ExprStmtExtensioniNzjAdds a `do` tag to Jinja that works like the print statement just206that it doesn't print the return value.207�dor[rrc��[R"[UR5RS9nUR5UlU$)Nrb)r�ExprStmtr�rWr`�parse_tupler�)rr[r�s   rr^�ExprStmtExtension.parseUs4���~�~�T�&�-�-�%8�%?�%?�@���&�&�(��	��rrN)208r%r&r'r(rnrArr.r^r+rrrr+r+Ns'���
�6�D��H�����rr+c�x�\rSrSrSrSS1rSSS\R\R\R44SjrS	rg209)�LoopControlExtensioni[z/Adds break and continue to the template engine.�break�continuer[rrc���[UR5nURS:Xa[R"UR210S9$[R"UR211S9$)Nr3rb)r�rWr�r�Breakr`�Continue)rr[r�s   rr^�LoopControlExtension.parse`sB���V�]�]�#���;�;�'�!��;�;�e�l�l�3�3��~�~�U�\�\�2�2rrN)
r%r&r'r(rnrArorvrr6r7r^r+rrrr2r2[s8��9��Z� �D�3�H�3�������e�n�n�1L�)M�3rr2c�V�\rSrSrSrS1rSSS\R4SjrS\	S\2124S	jrS213rg)�DebugExtensioniga�A ``{% debug %}`` tag that dumps the available variables,214filters, and tests.215 216.. code-block:: html+jinja217 218    <pre>{% debug %}</pre>219 220.. code-block:: text221 222    {'context': {'cycler': <class 'jinja2.utils.Cycler'>,223                 ...,224                 'namespace': <class 'jinja2.utils.Namespace'>},225     'filters': ['abs', 'attr', 'batch', 'capitalize', 'center', 'count', 'd',226                 ..., 'urlencode', 'urlize', 'wordcount', 'wordwrap', 'xmlattr'],227     'tests': ['!=', '<', '<=', '==', '>', '>=', 'callable', 'defined',228               ..., 'odd', 'sameas', 'sequence', 'string', 'undefined', 'upper']}229 230.. versionadded:: 2.11.0231�debugr[rrc���URRS5Rn[R"5nURSU/US9n[R"U/US9$)Nz232name:debug�_renderrb)rWr�r`r�ContextReferencerlr)rr[r`r/�results     rr^�DebugExtension.parse~sV�����%�%�l�3�:�:���(�(�*���!�!�)�g�Y�v�!�F���|�|�V�H�V�4�4rr/c��UR5[URRR	55[URR233R	55S.n[R"USSS9$)N)r/�filters�tests�T)�depth�compact)�get_all�sortedrCrB�keysrC�pprint�pformat)rr/r?s   rr=�DebugExtension._render�sb�����(��d�.�.�6�6�;�;�=�>��D�,�,�2�2�7�7�9�:�234���~�~�f�A�t�<�<rrN)
r%r&r'r(rnrArrr^rr)r=r+rrrr:r:gs:���(
�9�D�5�H�5����5�=�w�=�3�=rr:T�astr��babel_stylec#�z# �UR[R5GH�n[UR[R2355(aURRU;aMI/nURHon[U[R5(a<[UR[5(aURUR5 M^URS5 Mq URHnURS5 M URbURS5 URbURS5 U(d[SU55nU(dGMMO [!U5S:XaUSnO[U5nUR"URRU4v� GM� g7f)aWExtract localizable strings from the given template node.  Per236default this function returns matches in babel style that means non string237parameters as well as keyword arguments are returned as `None`.  This238allows Babel to figure out what you really meant if you are using239gettext functions that allow keyword arguments for placeholder expansion.240If you don't want that behavior set the `babel_style` parameter to `False`241which causes only strings to be returned and parameters are always stored242in tuples.  As a consequence invalid gettext calls (calls without a single243string parameter or string parameters after non-string parameters) are244skipped.245 246This example explains the behavior:247 248>>> from jinja2 import Environment249>>> env = Environment()250>>> node = env.parse('{{ (_("foo"), _(), ngettext("foo", "bar", 42)) }}')251>>> list(extract_from_ast(node))252[(1, '_', 'foo'), (1, '_', ()), (1, 'ngettext', ('foo', 'bar', None))]253>>> list(extract_from_ast(node, babel_style=False))254[(1, '_', ('foo',)), (1, 'ngettext', ('foo', 'bar'))]255 256For every string found this function yields a ``(lineno, function,257message)`` tuple, where:258 259* ``lineno`` is the number of the line on which the string was found,260* ``function`` is the name of the ``gettext`` function used (if the261  string was extracted from embedded Python code), and262*   ``message`` is the string, or a tuple of strings for functions263     with multiple string arguments.264 265This extraction function operates on the AST and is because of that unable266to extract any comments.  For comment support you have to use the babel267extraction interface or extract comments yourself.268Nc3�.# �UHocMUv� M
 g7frr)�.0�xs  r�	<genexpr>�#extract_from_ast.<locals>.<genexpr>�s���<�7�a���7�s��	rr)�find_allrrkr�r�r�rRrfrr�r)rrgrhri�tuple�lenr`)rMr�rNr��strings�argr6�outs        rr�r��s8���V���U�Z�Z�(���4�9�9�e�j�j�1�1��y�y�~�~�%6�6��+-���9�9�C��#�u�{�{�+�+�269�3�9�9�c�0J�0J����s�y�y�)����t�$�	����A��N�N�4� ���=�=�$��N�N�4� ��?�?�&��N�N�4� ���<�7�<�<�C�����7�|�q� ��a�j���G�n���k�k�4�9�9�>�>�3�.�.�C)�s�F9F;c���\rSrSrSrS\R\R\\	\	4S\R\	SS4Sjr270S\S\R\	4S	jrS271\S\R\	4Sjr
Srg)
�_CommentFinderi�z�Helper class to find comments in a token stream.  Can only272find comments for gettext calls forwards.  Once the comment273from line 4 is found, a comment for line 1 will not return a274usable value.275�tokens�comment_tagsrNc�8�XlX lSUlSUlg)Nr)r]r^�offset�last_lineno)rr]r^s   rrF�_CommentFinder.__init__�s����(�������rr`c�.�[URURU5HKup#nUS;dMURSS5upVXPR276;dM4UR
5/s Xl$ /Xl$![a Mdf=f!Xlf=f)N)�comment�linecommentr)�reversedr]r`�split�277ValueErrorr^�rstrip)rr`r6�278token_type�token_value�prefixrds       r�find_backwards�_CommentFinder.find_backwards�s���
	!�.6����D�K�K�&�1�/�*��{��!;�;�!�*5�*;�*;�D�!�*D����!2�!2�2� '��� 0�1�1�!�K�/�� �K��
&�!� �!��!�K�s:�,B�A;�
B�B�1B�;279B	�B�B	�	B�Br`c�:�UR(aURU:�a/$[URURS5H/unun nX1:�dMURURU-5s $ UR[
UR55$r)r^ra�	enumerater]r`rmrW)rr`�idx�token_linenor6s     r�
find_comments�_CommentFinder.find_comments�s���� � �D�$4�$4�v�$=��I�)2�4�;�;�t�{�{�}�3M�)N�%�C�%�,��1��$��*�*�4�;�;��+<�=�=�*O��"�"�3�t�{�{�#3�4�4r)r^rar`r])r%r&r'r(rnror%r'r*r)rFryrmrsr+rrrr\r\�s{�����j�j�����c�3��!7�8��HI�280�281�SV���	
��!�S�!�Q�V�V�C�[�!� 5�C�5�A�F�F�3�K�5rr\�fileobj�keywordsr^�optionsc#�# �0nURSS5RS5H*nUR5nU(dMSU[U5'M, [U;a	SU['SS[282R[[4S[S[S	[4S283jjnU"USS5n[URS
[R5URS[R5URS[R5URS[R5URS[R5URS[R 5URS5=(d [R"URS5=(d [R$U"US[R&5U"US[R(5[R*U"US[R,5[/U5SSS9nU"US5(aSUR0S'U"US5(aSUlUR55R7URSS55n	UR9U	5n284[;UR=UR?U	555n[CX�5n[EX�5Hup�nX�X�RGU
54v� M g![@a U(degf=f7f) a�Babel extraction method for Jinja templates.285 286.. versionchanged:: 2.3287   Basic support for translation comments was added.  If `comment_tags`288   is now set to a list of keywords for extraction, the extractor will289   try to find the best preceding comment that begins with one of the290   keywords.  For best results, make sure to not have more than one291   gettext call in one line of code and the matching comment in the292   same line or the line before.293 294.. versionchanged:: 2.5.1295   The `newstyle_gettext` flag can be set to `True` to enable newstyle296   gettext calls.297 298.. versionchanged:: 2.7299   A `silent` option can now be provided.  If set to `False` template300   syntax errors are propagated instead of being ignored.301 302:param fileobj: the file-like object the messages should be extracted from303:param keywords: a list of keywords (i.e. function names) that should be304                 recognized as translation functions305:param comment_tags: a list of translator tags to search for and include306                     in the results.307:param options: a dictionary of additional options (optional)308:return: an iterator over ``(lineno, funcname, message, comments)`` tuples.309         (comments will be empty currently)310�311extensions��,NFrwr��defaultrc�Z�URU[U55R5S;$)N>�1�on�yes�true)�getr)�lower)rwr�r|s   r�getbool�babel_extract.<locals>.getbool8s&���{�{�3��G��-�3�3�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)�312cache_size�auto_reloadr�r�r��encodingzutf-8)F)$r�rgrr
r�ro�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_NEWLINErVr�r��read�decoder^�list�lexrUr	r\r�rs)rurvr^rwry�extension_namer�r�rCrQr�r]�finderr`r�rs                r�
babel_extractr�s����J35�J�!�+�+�l�B�7�=�=�c�B��'�-�-�/����48�313�=��0�1�
C�%�J�6�48�314�0�1�T����3��8�,�T�3�T��T�RV�T��W�h��
-�F�����(�(�*E�*E�F����&��(A�(A�B����+�X�-K�-K�L����)�8�+G�+G�H����*�H�,I�,I�J����(�(�*E�*E�F����+�,�N��0N�0N����)�*�J�h�.J�.J�����(<�(<�=����(�*@�*@�A��!�!���0�(�2P�2P�Q�
�j�����K�$�w�	�"�"�37����/�0��w�*�+�+�'+��$�
�\�\�^�
"�
"�7�;�;�z�7�#C�
D�F��� � ��(���k�o�o�k�&<�&<�V�&D�E�F���F�
1�F�!1�$�!A���g��G�%9�%9�&�%A�A�A�"B�������	�s*�I6L�9:K)�36L�)K>�;L�=K>�>L)ErnrJ�re�typingro�315markupsaferrzrrrCr�316exceptionsrr	�runtimer317rr�utilsr
r�
TYPE_CHECKING�typing_extensions�te�lexerrrr[r�Protocolrr-rvr�r7r'r)rq�compiler�r9r�r�r#r�r*r�r�r�r�r+r2r:r$r%r�r&rur�r\�BinaryIOrryr��i18nr,�loopcontrolsr;rrr�<module>r�sp��8�
�	�����$�.�+���� ���?�?�"��"���R�[�[���1���W�W�%7�9M�%M�N��318(��1�7�7�3��8�$��319���K�	 ��j320�j321�Z�I��I� �u�u�I�01���I��W�W�Q�U�U�I�
��I��I��A�J�J��u�c�z�2��q�z�z�#�s�(�7K���Q�Z�Z��c�3���(<�=��!�*�*�S�RU�X�BV��&�Q�Z�Z��c�322�C��8��Q�Z�Z��S��=Q��"�323�*�*�c�3��S�)�3�.�324/���Z�Z��S����2U$�I�U$�p325 326�	�327�	3�9�	3�%=�Y�%=�T*;��L/�	���L/��z�z�#��L/��L/��Z�Z��G�G�C��a�g�g�a�j�j��o�q�w�w�q�z�z�#���7K�/L�L�M�M�N��	L/�^%5�%5�PYB�
�Z�Z�YB��j�j��o�YB��*�*�S�/�YB��V�V�C����J�
�	YB�328�Z�Z��G�G��S�!�'�'�!�*�*�S�/�1�7�7�1�:�:�c�?�C�3G�+H�H�I�1�6�6�RU�;�V���YB�z%����#���r
codekingpro/portable-devtools · Team Ai