HEX
Server: LiteSpeed
System: Linux server.nevid-deploma.com 4.18.0-553.111.1.lve.el8.x86_64 #1 SMP Fri Mar 13 13:42:17 UTC 2026 x86_64
User: smilepac (1037)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/cppython/lib/python3.8/test/test_tools/__pycache__/test_i18n.cpython-38.opt-2.pyc
U

1D�gV#�@slddlZddlZddlZddlmZddlmZddlmZm	Z	ddl
mZmZe�Gdd�dej
�ZdS)�N)�dedent)�assert_python_ok)�skip_if_missing�toolsdir)�temp_cwd�temp_dirc@s�eZdZej�edd�Zdd�Zdd�Z	dd�Z
d	d
�Ze�
ej�d�d�d
d��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Z d-S).�Test_pygettextZi18nzpygettext.pycCsNi}|�d�D]:}|r|�d�r"q|�d�}|�dd�\}}|��||<q|S)N�
)�#�msgidZmsgstr�"�:�)�split�
startswith�strip)�self�dataZheaders�line�key�val�r�8/opt/cppython/lib/python3.8/test/test_tools/test_i18n.py�
get_headers
zTest_pygettext.get_headercCs�g}d}g}|�d�D]l}|rT|�d�r:|�|�d��n|�d�|��g}d}q|�d�r|td�d�}|�|�d��d}q|r�|�d�|��|S)NFr	rzmsgid T)rr�appendr�join�len)rr�msgidsZ
reading_msgidZ	cur_msgidrrrr�
get_msgids s$

zTest_pygettext.get_msgidsc
Csld}td��P}t|d��}|�|�W5QRXt|jd|�td��}|��}W5QRXW5QRX|�|�S)Nztest_docstrings.py�wz-D�messages.pot)r�open�writer�script�readr)rZmodule_content�filename�cwd�fprrrr�extract_docstrings_from_str8s

z*Test_pygettext.extract_docstrings_from_strc
Cs�td���}t|j�td��}|��}W5QRX|�|�}|�d|�|�d|�|�d|�|�d|�|�d|�|�d|�|�d|�|�d	|�|�d
|�W5QRXdS)Nr zProject-Id-Version�POT-Creation-DatezPO-Revision-DatezLast-Translatorz
Language-TeamzMIME-VersionzContent-TypezContent-Transfer-EncodingzGenerated-By)rrr#r!r$r�assertIn)rr&r'r�headerrrr�test_headerCs



zTest_pygettext.test_headerZaixzbpo-29972: broken test on AIXc
Cs�ddlm}td��f}t|j�td��}|��}W5QRX|�|�}|d}|�d�rj|dtd��}|�	|d�W5QRXdS)Nr)�datetimer r)z\nz%Y-%m-%d %H:%M%z)
r-rrr#r!r$r�endswithr�strptime)rr-r&r'rr+ZcreationDaterrr�test_POT_Creation_Date]s




z%Test_pygettext.test_POT_Creation_Datec
CsBdD]8}|�|��$|�td|��}|�d|�W5QRXqdS)N�z	"""doc"""z
r'''doc'''zR'doc'zu"doc"zE                def foo(bar):
                    %s
                �doc�ZsubTestr(rr*�rr2rrrr�test_funcdocstringps�z!Test_pygettext.test_funcdocstringcCs&|�td��}|�dd�|D��dS)Nz5        def foo(bar):
            b"""doc"""
        cSsg|]}d|kr|�qS�r2r��.0rrrr�
<listcomp>~sz;Test_pygettext.test_funcdocstring_bytes.<locals>.<listcomp>�r(r�assertFalse�rrrrr�test_funcdocstring_bytesysz'Test_pygettext.test_funcdocstring_bytescCs&|�td��}|�dd�|D��dS)Nz5        def foo(bar):
            f"""doc"""
        cSsg|]}d|kr|�qSr6rr7rrrr9�sz=Test_pygettext.test_funcdocstring_fstring.<locals>.<listcomp>r:r<rrr�test_funcdocstring_fstring�sz)Test_pygettext.test_funcdocstring_fstringc
CsBdD]8}|�|��$|�td|��}|�d|�W5QRXqdS)Nr1z@                class C:
                    %s
                r2r3r4rrr�test_classdocstring�s�z"Test_pygettext.test_classdocstringcCs&|�td��}|�dd�|D��dS)Nz0        class C:
            b"""doc"""
        cSsg|]}d|kr|�qSr6rr7rrrr9�sz<Test_pygettext.test_classdocstring_bytes.<locals>.<listcomp>r:r<rrr�test_classdocstring_bytes�sz(Test_pygettext.test_classdocstring_bytescCs&|�td��}|�dd�|D��dS)Nz0        class C:
            f"""doc"""
        cSsg|]}d|kr|�qSr6rr7rrrr9�sz>Test_pygettext.test_classdocstring_fstring.<locals>.<listcomp>r:r<rrr�test_classdocstring_fstring�sz*Test_pygettext.test_classdocstring_fstringcCs|�d�}|�d|�dS)Nz_("""doc""" r'str' u"ing")Z	docstring)r(r*r<rrr�
test_msgid�s�zTest_pygettext.test_msgidcCs"|�d�}|�dd�|D��dS)Nz
_(b"""doc""")cSsg|]}d|kr|�qSr6rr7rrrr9�sz3Test_pygettext.test_msgid_bytes.<locals>.<listcomp>�r(r;r<rrr�test_msgid_bytes�s
zTest_pygettext.test_msgid_bytescCs"|�d�}|�dd�|D��dS)Nz
_(f"""doc""")cSsg|]}d|kr|�qSr6rr7rrrr9�sz5Test_pygettext.test_msgid_fstring.<locals>.<listcomp>rCr<rrr�test_msgid_fstring�s
z!Test_pygettext.test_msgid_fstringcCs|�td��}|�d|�dS)Nz9        def foo(bar: str):
            """doc"""
        r2�r(rr*r<rrr�!test_funcdocstring_annotated_args�sz0Test_pygettext.test_funcdocstring_annotated_argscCs|�td��}|�d|�dS)Nz;        def foo(bar) -> str:
            """doc"""
        r2rFr<rrr�#test_funcdocstring_annotated_return�sz2Test_pygettext.test_funcdocstring_annotated_returncCs|�td��}|�d|�dS)Nz7        def foo(bar=()):
            """doc"""
        r2rFr<rrr� test_funcdocstring_defvalue_args�sz/Test_pygettext.test_funcdocstring_defvalue_argscCs6|�td��}|�d|�|�d|�|�d|�dS)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"""
        Zdoc1Zdoc2Zdoc3rFr<rrr�!test_funcdocstring_multiple_funcs�s
z0Test_pygettext.test_funcdocstring_multiple_funcscCs|�td��}|�d|�dS)Nz\        class D(L[1:2], F({1: 2}), metaclass=M(lambda x: x)):
            """doc"""
        r2rFr<rrr�test_classdocstring_early_colon�sz.Test_pygettext.test_classdocstring_early_coloncCspd}d}d}td���Ptd���:}t�tj�|d��ttj�|dd�d��}|�d|�d��W5QRXt�tj�|d	��ttj�|d	d
�d��}|�d|�d��W5QRXt�tj�|d��ttj�|dd�d��}|�d|�d��W5QRXt|j	|�td
��}|�
�}W5QRX|�d|�d�|�|�d|�d�|�|�||�W5QRXW5QRXdS)NzText to translate1zText to translate2zText to ignoreZpypkgzpymod.pyrz_(�)zpkg.pyz	pymod2.pyZCVSz	pymod3.pyr zmsgid "r)
rr�os�mkdir�pathrr!r"rr#r$r*ZassertNotIn)rZtext1Ztext2Ztext3ZsdirZsfiler'rrrr�test_files_list�s&
zTest_pygettext.test_files_listN)!�__name__�
__module__�__qualname__rMrOrrr#rrr(r,�unittestZskipIf�sys�platformrr0r5r=r>r?r@rArBrDrErGrHrIrJrKrPrrrrrs0�
		
r)rMrUrT�textwraprZtest.support.script_helperrZtest.test_toolsrrZtest.supportrrZTestCaserrrrr�<module>s