HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/test_tools/__pycache__/test_i18n.cpython-312.opt-2.pyc
�

h�ej0���	ddlZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZmZe�Gd�dej�Zy)�N)�dedent)�assert_python_ok)�skip_if_missing�toolsdir)�temp_cwd�temp_dirc�r�eZdZ	ejjedd�Zd�Zd�Z	d�Z
d�Zejejj!d�d�d	��Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd �Z(d!�Z)d"�Z*d#�Z+d$�Z,d%�Z-d&�Z.y')(�Test_pygettext�i18nzpygettext.pyc���	i}|jd�D]O}|r|jd�r�|jd�}|jdd�\}}|j�||<�Q|S)N�
)�#�msgid�msgstr�"�:�)�split�
startswith�strip)�self�data�headers�line�key�vals      �@/opt/alt/python312/lib64/python3.12/test/test_tools/test_i18n.py�
get_headerzTest_pygettext.get_headersk��H����J�J�t�$�	'�D��4�?�?�+B�C���:�:�c�?�D��z�z�#�a�(�H�C���9�9�;�G�C�L�	'���c��	g}d}g}|jd�D]�}|rW|jd�r!|j|jd��n%|jdj	|��g}d}�\|jd�s�n|td�d}|j|jd��d}��|r |jdj	|��|S)NFr
rzmsgid T)rr�appendr�join�len)rr�msgids�
reading_msgid�	cur_msgidrs      r�
get_msgidszTest_pygettext.get_msgids s���K����
��	��J�J�t�$�	4�D���?�?�3�'��$�$�T�Z�Z��_�5��M�M�$�)�)�I�"6�7� "�I�$)�M�����x�(��C��M�N�+��� � ����C��1� $�
�	4���
�
�d�i�i�	�2�3��
rc�d�	d}td�5}t|dd��5}|j|�ddd�t|jd|�tdd��5}|j�}ddd�ddd�|j
�S#1swY�_xYw#1swY�.xYw#1swY�2xYw)Nztest_docstrings.py�w�utf-8��encodingz-D�messages.pot)r�open�writer�script�readr')r�module_content�filename�cwd�fprs      r�extract_docstrings_from_strz*Test_pygettext.extract_docstrings_from_str8s���H�'��
�d�^�	!�s��h��g�6�
)�"�����(�
)��T�[�[�$��9��n�w�7�
!�2��w�w�y��
!�		!����t�$�$�
)�
)��
!�
!��		!�	!�s9�B&�B�,B&�B�-B&�B	�B&�B#	�B&�&B/c�:�	td�5}t|j�tdd��5}|j	�}ddd�|j�}|j
d|�|j
d|�|j
d|�|j
d|�|j
d|�|j
d	|�|j
d
|�|j
d|�|j
d|�ddd�y#1swY��xYw#1swYyxYw)
Nr-r*r+zProject-Id-Version�POT-Creation-DatezPO-Revision-DatezLast-Translatorz
Language-TeamzMIME-VersionzContent-TypezContent-Transfer-EncodingzGenerated-By)rrr0r.r1r�assertIn)rr4r5r�headers     r�test_headerzTest_pygettext.test_headerCs���	��d�^�	2�s��T�[�[�)��n�w�7�
!�2��w�w�y��
!��_�_�T�*�F��M�M�.��7��M�M�-�v�6��M�M�,�f�5��M�M�+�V�4��M�M�/�6�2��M�M�.�&�1��M�M�.�&�1��M�M�5�v�>��M�M�.�&�1�	2�	2�
!�
!��	2�	2�s#�#D�D�B;D�D	�
D�D�aixzbpo-29972: broken test on AIXc�p�	ddlm}td�5}t|j�t	dd��5}|j�}ddd�|j
�}|d}|jd�r|dtd�}|j|d�ddd�y#1swY�ZxYw#1swYyxYw)	Nr)�datetimer-r*r+r8z\nz%Y-%m-%d %H:%M%z)
r>rrr0r.r1r�endswithr#�strptime)rr>r4r5rr:�creationDates       r�test_POT_Creation_Datez%Test_pygettext.test_POT_Creation_Date]s���	J�%�
�d�^�	@�s��T�[�[�)��n�w�7�
!�2��w�w�y��
!��_�_�T�*�F�!�"5�6�L��$�$�U�+�+�L�c�%�j�[�9��
���l�,>�?�	@�	@�
!�
!��	@�	@�s#�#B,�B �AB,� B)	�%B,�,B5c��dD]K}|j|�5|jtd|z��}|jd|�ddd��My#1swY�XxYw)N�z	"""doc"""z
r'''doc'''zR'doc'zu"doc"zE                def foo(bar):
                    %s
                �doc��subTestr6rr9�rrEr$s   r�test_funcdocstringz!Test_pygettext.test_funcdocstringp�o��B�	-�C����c�"�
-��9�9�&�B��B�;����
�
�e�V�,�
-�
-�	-�
-�
-���0A�A	c��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz5        def foo(bar):
            b"""doc"""
        rE�r6r�assertFalse�rr$rs   r�test_funcdocstring_bytesz'Test_pygettext.test_funcdocstring_bytesy�B���1�1�&�:�3
���	
���V�F�E�u��~�%�F�G��F�
�	A�Ac��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz5        def foo(bar):
            f"""doc"""
        rErMrOs   r�test_funcdocstring_fstringz)Test_pygettext.test_funcdocstring_fstring�rQrRc��dD]K}|j|�5|jtd|z��}|jd|�ddd��My#1swY�XxYw)NrDz@                class C:
                    %s
                rErFrHs   r�test_classdocstringz"Test_pygettext.test_classdocstring�rJrKc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz0        class C:
            b"""doc"""
        rErMrOs   r�test_classdocstring_bytesz(Test_pygettext.test_classdocstring_bytes�rQrRc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz0        class C:
            f"""doc"""
        rErMrOs   r�test_classdocstring_fstringz*Test_pygettext.test_classdocstring_fstring�rQrRc��dD]K}|j|�5|jtd|z��}|jd|�ddd��My#1swY�XxYw)NrDz#                %s
                rErFrHs   r�test_moduledocstringz#Test_pygettext.test_moduledocstring�sm��B�	-�C����c�"�
-��9�9�&�B��B�;����
�
�e�V�,�	
-�
-�	-�
-�
-�rKc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz        b"""doc"""
        rErMrOs   r�test_moduledocstring_bytesz)Test_pygettext.test_moduledocstring_bytes��B���1�1�&�:�3
���	
���V�F�E�u��~�%�F�G��FrRc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz        f"""doc"""
        rErMrOs   r�test_moduledocstring_fstringz+Test_pygettext.test_moduledocstring_fstring�r_rRc�J�|jd�}|jd|�y)Nz_("""doc""" r'str' u"ing")�	docstring)r6r9�rr$s  r�
test_msgidzTest_pygettext.test_msgid�s#���1�1�0�2���
�
�k�6�*rc�x�|jd�}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz
_(b"""doc""")rE�r6rNrOs   r�test_msgid_byteszTest_pygettext.test_msgid_bytes��4���1�1�/�B�����V�F�E�u��~�%�F�G��F��	7�7c�x�|jd�}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz
_(f"""doc""")rErgrOs   r�test_msgid_fstringz!Test_pygettext.test_msgid_fstring�rirjc�^�	|jtd��}|jd|�y)Nz9        def foo(bar: str):
            """doc"""
        rE�r6rr9rds  r�!test_funcdocstring_annotated_argsz0Test_pygettext.test_funcdocstring_annotated_args�s1��A��1�1�&�:�3
���	
�
�
�e�V�$rc�^�	|jtd��}|jd|�y)Nz;        def foo(bar) -> str:
            """doc"""
        rErnrds  r�#test_funcdocstring_annotated_returnz2Test_pygettext.test_funcdocstring_annotated_return�s1��H��1�1�&�:�3
���	
�
�
�e�V�$rc�^�	|jtd��}|jd|�y)Nz7        def foo(bar=()):
            """doc"""
        rErnrds  r� test_funcdocstring_defvalue_argsz/Test_pygettext.test_funcdocstring_defvalue_args�s1��D��1�1�&�:�3
���	
�
�
�e�V�$rc��	|jtd��}|jd|�|jd|�|jd|�y)Nz�        def foo1(bar: tuple=()) -> str:
            """doc1"""

        def foo2(bar: List[1:2]) -> (lambda x: x):
            """doc2"""

        def foo3(bar: 'func'=lambda x: x) -> {1: 2}:
            """doc3"""
        �doc1�doc2�doc3rnrds  r�!test_funcdocstring_multiple_funcsz0Test_pygettext.test_funcdocstring_multiple_funcs�sQ��	��1�1�&�	:�	3
�	��	
�
�
�f�f�%��
�
�f�f�%��
�
�f�f�%rc�^�	|jtd��}|jd|�y)Nz\        class D(L[1:2], F({1: 2}), metaclass=M(lambda x: x)):
            """doc"""
        rErnrds  r�test_classdocstring_early_colonz.Test_pygettext.test_classdocstring_early_colon�s5��	��1�1�&�:�3
���	
�
�
�e�V�$rc�\�|jtd��}|jd|�y)Nz"        f"{_('foo bar')}"
        �foo barrnrds  r�test_calls_in_fstringsz%Test_pygettext.test_calls_in_fstrings��.���1�1�&�:�3
���	
�
�
�i��(rc�\�|jtd��}|jd|�y)Nz#        rf"{_('foo bar')}"
        r|rnrds  r�test_calls_in_fstrings_rawz)Test_pygettext.test_calls_in_fstrings_raw�r~rc�\�|jtd��}|jd|�y)Nz+        f"""{f'{_("foo bar")}'}"""
        r|rnrds  r�test_calls_in_fstrings_nestedz,Test_pygettext.test_calls_in_fstrings_nested�r~rc�\�|jtd��}|jd|�y)Nz&        f"{obj._('foo bar')}"
        r|rnrds  r� test_calls_in_fstrings_attributez/Test_pygettext.test_calls_in_fstrings_attributer~rc�\�|jtd��}|jd|�y)Nz*        f"{type(str)('foo bar')}"
        r|�r6r�assertNotInrds  r�(test_calls_in_fstrings_with_call_on_callz7Test_pygettext.test_calls_in_fstrings_with_call_on_calls0���1�1�&�:�3
���	
����F�+rc�\�|jtd��}|jd|�y)Nz6        f"{_('foo {bar}').format(bar='baz')}"
        �	foo {bar}rnrds  r�"test_calls_in_fstrings_with_formatz1Test_pygettext.test_calls_in_fstrings_with_formats.���1�1�&�:�3
���	
�
�
�k�6�*rc��|jtd��}|j|D�cgc]	}d|vs�|��c}�ycc}w)Nz%        f"{_(f'foo {bar}')}"
        r�rMrOs   r�)test_calls_in_fstrings_with_wrong_input_1z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_1sC���1�1�&�:�3
���	
���V�L�E�{�e�7K�%�L�M��LrRc�\�|jtd��}|jd|�y)Nz        f"{_(1)}"
        rr�rds  r�)test_calls_in_fstrings_with_wrong_input_2z8Test_pygettext.test_calls_in_fstrings_with_wrong_input_2s0���1�1�&�:�3
���	
����F�#rc��|jtd��}|jd|�|jd|�y)Nz%        f"{_('foo', 'bar')}"
        �foo�barr�rds  r�(test_calls_in_fstring_with_multiple_argsz7Test_pygettext.test_calls_in_fstring_with_multiple_args#s@���1�1�&�:�3
���	
�����'������'rc��|jtd��}|jd|�|jd|�|jd|�y)Nz)        f"{_('foo', bar='baz')}"
        r�r��bazr�rds  r�'test_calls_in_fstring_with_keyword_argsz6Test_pygettext.test_calls_in_fstring_with_keyword_args*sP���1�1�&�:�3
���	
�����'������'������'rc��|jtd��}|jd|�|jd|�y)Nz*        f"{_(f'foo') + _('bar')}"
        r�r�)r6rr�r9rds  r�5test_calls_in_fstring_with_partially_wrong_expressionzDTest_pygettext.test_calls_in_fstring_with_partially_wrong_expression2s>���1�1�&�:�3
���	
�����'��
�
�e�V�$rc	���	d}d}d}td�5td�5}tjtjj|d��t
tjj|dd�dd��5}|jd	|�d
��ddd�tjtjj|d��t
tjj|dd�dd��5}|jd	|�d
��ddd�tjtjj|d
��t
tjj|d
d�dd��5}|jd	|�d
��ddd�t|j|�t
dd��5}|j�}ddd�|jd|�d��|jd|�d�|�|j||�ddd�ddd�y#1swY���xYw#1swY�� xYw#1swY��xYw#1swY�~xYw#1swY�DxYw#1swYyxYw)NzText to translate1zText to translate2zText to ignore�pypkgzpymod.pyr)r*r+z_(�)zpkg.pyz	pymod2.py�CVSz	pymod3.pyr-zmsgid "r)
rr�os�mkdir�pathr"r.r/rr0r1r9r�)r�text1�text2�text3�sdir�sfiler5rs        r�test_files_listzTest_pygettext.test_files_list9s	��	�%��$�� ��
�d�^�	*�X�d�^�	*�t��H�H�R�W�W�\�\�$��0�1��b�g�g�l�l�4��*�=�s�&�(�
-�+0����b��	��O�,�
-�
�H�H�R�W�W�\�\�$��1�2��b�g�g�l�l�4��;�?��&�(�
-�+0����b��	��O�,�
-�
�H�H�R�W�W�\�\�$��.�/��b�g�g�l�l�4���<�c�&�(�
-�+0����b��	��O�,�
-�
�T�[�[�$�/��n�w�7�
!�2��w�w�y��
!��M�M�G�E�7�!�,�d�3��M�M�G�E�7�!�,�d�3����U�D�)�%	*�	*�	*�
-�
-��
-�
-��
-�
-��
!�
!��	*�	*��	*�	*�s��I#�A!I�H%�A(I�>H2�A(I�<H?�+I�=I�AI�I#�%H/�*I�2H<�7I�?I�I�I�I�I 	�I#�#I,N)/�__name__�
__module__�__qualname__r�r�r"rr0rr'r6r;�unittest�skipIf�sys�platformrrBrIrPrTrVrXrZr\r^rarerhrlrorqrsrxrzr}r�r�r�r�r�r�r�r�r�r�r��rrr
r
s���)�
�W�W�\�\�(�6�>�
:�F�	��0	%�2�4�X�_�_�S�\�\�,�,�U�3�4�6�@�6�@�"-�H�H�-�H�H�-�H�H�+�
H�H�%�%�%�&�$%�)�)�)�)�,�+�N�$�(�(�%�*rr
)r�r�r��textwrapr�test.support.script_helperr�test.test_toolsrr�test.support.os_helperrr�TestCaser
r�rr�<module>r�s9��+�	�
���7�5�5���B*�X�&�&�B*r