
    F\h                     .   S SK r S SKrS SKrS SKrS SKJr  S SKJrJrJ	r	  S SK
Jr  \" \5      S-  S-  S-  r\ R                  " S\ R                  5      r\ R                  " S	5      rS
S.S jrS rS r\	" 5        " S S\R(                  5      5       rS rg)    N)Path)	REPO_ROOTTEST_HOME_DIRrequires_subprocess)skip_if_missingToolsi18nzpygettext.pyz)msgid(.*?)(?:msgid_plural|msgctxt|msgstr)z"((?:\\"|[^"])*)"Tstdout_onlyc                    [         R                  " [        R                  [        SSSU /[         R
                  [         R
                  SS9nU(       a  UR                  $ U$ )Nz--no-locationz-o-T)stdoutstderrtext)
subprocessrunsys
executable	pygettextPIPEr   )pathr   ress      //usr/lib/python3.13/test/support/i18n_helper.py_generate_po_filer      sJ    
..#..))4d< *
"$C zzJ    c                     / n[         R                  U 5       HS  nSR                  [        R                  U5      5      nUR	                  SS5      nU(       d  MB  UR                  U5        MU     [        U5      $ )N z\"")msgid_patternfindalljoinmsgid_string_patternreplaceappendsorted)pomsgidsmsgidmsgid_strings       r   _extract_msgidsr*      se    F&&r*ww3;;EBC#++E37<MM,'	 +
 &>r   c                 2    [        [        5      S-  U -  S-  $ )Ntranslationdataz
msgids.txt)r   r   )module_names    r   _get_snapshot_pathr.   %   s    !22[@<OOr   c                       \ rS rSrS rSrg)TestTranslationsBase)   c                 d   [        S5        [        UR                  SS9nU R                  UR                  S5        U R                  UR
                  S5        [        UR                  5      n[        UR                  5      nUR                  5       R                  5       nU R                  X55        g)zDAssert that msgids extracted from a given module match a
snapshot.

r	   Fr
   r   r   N)r   r   __file__assertEqual
returncoder   r*   r   r.   __name__	read_text
splitlinesassertListEqual)selfmoduler   r'   snapshot_pathsnapshots         r   assertMsgidsEqual&TestTranslationsBase.assertMsgidsEqual,   s    
 	UC+R( ,*6??; **,779V.r    N)r6   
__module____qualname____firstlineno__r>   __static_attributes__r@   r   r   r0   r0   )   s    /r   r0   c                     [        U R                  5      n[        U5      n[        U R                  5      nUR                  SR                  U5      5        g )N
)r   r3   r*   r.   r6   
write_textr!   )r;   contentsr'   r<   s       r   update_translation_snapshotsrI   ;   s?     1HX&F&v7MTYYv./r   )rer   r   unittestpathlibr   test.supportr   r   r   test.test_toolsr   r   compileDOTALLr   r"   r   r*   r.   TestCaser0   rI   r@   r   r   <module>rR      s    	  
   F F + Og%.?	

G99&zz"67  ,0 P /8,, / /"0r   