o
    e.                     @  s   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlZ	e
 Zed ejddd ejdddd ejd	d
dd ejddd ejddg d ejddd d ddZd!ddZdS )"    )annotationsNcommandz--build-dir )default-iz--input-oz--outputz	--itstoolitstoolz--itsappend)actionr   mo_files+)nargs	build_dirstr	its_filesT.List[str]in_fname	out_fnamereturnintc                 C  sj  |st d dS tjtj|| d}g }|D ]e}tj|s0t d|   W d    dS |dsEt d|   W d    dS |d}	|	d tj	d	fratj|	d d d
 }
ntj|	d }
tj
||
d }t|| || qt|}|r|D ]	}|d|g q|d|d|g || t|W  d    S 1 sw   Y  d S )Nz-No mo files specified to use for translation.   )prefixdirzCould not find mo file z.mozFile is not a mo file: LC_MESSAGESr   /r   z-jr   )printtempfileTemporaryDirectoryospathbasenameexistsendswith	partitionsepjoinshutilcopyr	   shlexsplitextend
subprocesscall)r   r   r   r   r   r   Ztmp_dirZlocale_mo_filesZmo_filepartslocaleZtmp_mo_fnamecmdfname r2   ?/usr/lib/python3.10/site-packages/mesonbuild/scripts/itstool.pyrun_join"   s>   



$r4   argsc                 C  s^   t | }|j}tjdt }|jr|j}|dkr)t||j	|j
|j|j|jS td dS )NZMESON_BUILD_ROOTr&   zUnknown subcommand.r   )parser
parse_argsr   r   environgetgetcwdr   r4   r   Zitsr   inputoutputr   )r5   optionsr   r   r2   r2   r3   runG   s   
r>   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r5   r   r   r   )
__future__r   r   argparser,   r   r)   r'   typingTArgumentParserr6   add_argumentr4   r>   r2   r2   r2   r3   <module>   s$   

%