HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/export_pot.cpython-39.pyc
a

�*�^u.�@s�dZddlmZddlZddlZddlZddlZddlmZ	m
Z
mZmZm
ZddlmZddlmZmZddlmZd	d
�Zdd�Zd%dd�ZGdd�de�ZGdd�de�Zdd�Zdd�Zdd�Zdd�Zd&dd�Z dd�Z!d d!�Z"d'd#d$�Z#dS)(a�Extract docstrings from Bazaar commands.

This module only handles breezy objects that use strings not directly wrapped
by a gettext() call. To generate a complete translation template file, this
output needs to be combined with that of xgettext or a similar command for
extracting those strings, as is done in the bzr Makefile. Sorting the output
is also left to that stage of the process.
�)�absolute_importN�)�commands�errors�help_topics�option�plugin)�PY3)�mutter�note)�gettextcCs0|�dd��dd��dd��dd��d	d
�}|S)N�\z\\�
z\n�
z\r�	z\t�"z\")�replace)�s�r�3/usr/lib/python3/dist-packages/breezy/export_pot.py�_escape3s����rcCsf|�d�}t|�dkr(dt|�d}n:|dsF|d=|dd|d<d}d|�tt|��d}|S)Nrrr���z\n"
"z""
")�split�lenr�join�map)r�linesZlinetermrrr�
_normalize=s
r�	<unknown>cCs|ddl}i}i}|�|�||��D]P}t||j�r@|j||j<q"t||j�r"|jtj	dkr^dn
|j
�d�||j
<q"||fS)z4Get object to lineno mappings from given source_textrN)��r)�ast�walk�parse�
isinstanceZClassDef�lineno�nameZStr�sys�version_infor�count)Zsource_text�filenamer!Z
cls_to_linenoZ
str_to_linenoZnoderrr�
_parse_sourceLs(r+c@s6eZdZdZddd�Zedd��Zdd	�Zd
d�ZdS)
�_ModuleContextz+Record of the location within a source treerNcCs$||_||_|dur |\|_|_dS�N)�pathr%�_cls_to_lineno�_str_to_lineno)�selfr.r%�_source_inforrr�__init__bsz_ModuleContext.__init__cCs:t�|�}tj�|�}||td�t�|�d�|j�d�S)z?Get new context from module object and parse source for linenos�r)r2)	�inspectZ
getsourcefile�osr.�relpathr+rZ
findsource�__file__)�cls�moduleZ
sourcepathr7rrr�from_modulehs

�z_ModuleContext.from_modulec	CsRz|j|j}Wn(ttfy8td||j�|YS0|�|j||j|jf�S)z?Get new context with same details but lineno of class in sourcez Definition of %r not found in %r)r/�__name__�AttributeError�KeyErrorr
r.�	__class__r0)r1r9r%rrr�
from_classqs


�z_ModuleContext.from_classc	CsXz|j|}Wn0ttfy>td|dd�|j�|YS0|�|j||j|jf�S)z@Get new context with same details but lineno of string in sourcezString %r not found in %rN�)r0r=r>r
r.r?r/)r1�stringr%rrr�from_string{s


�z_ModuleContext.from_string)rN)	r<�
__module__�__qualname__�__doc__r3�classmethodr;r@rCrrrrr,_s


r,c@s@eZdZdZddd�Zddd�Zddd	�Zdd
d�Zdd
�ZdS)�_PotExporterz:Write message details to output stream in .pot file formatFcCs$||_|rd|_nt�|_i|_dSr-)�outf�_msgids�set�_module_contexts)r1rI�include_duplicatesrrrr3�s
z_PotExporter.__init__NcCs�|jdur$||jvrdS|j�|�|dur2d}nd|}td|dd�||�dj|||t|�d�}tst|�d�}|j�|�dS)Nr4z# %s
z!Exporting msg %r at line %d in %rrAz3#: {path}:{lineno}
{comment}msgid {msg}
msgstr ""

)r.r%�comment�msgzutf-8)	rJ�addr
�formatrr	�decoderI�write)r1r.r%rrN�linerrr�poentry�s

��
z_PotExporter.poentrycCs"|�|�}|�|j|j||�dSr-)rCrUr.r%)r1�contextrBrNrrr�poentry_in_context�s
z_PotExporter.poentry_in_contextcCsJ|�d�}|durt||�}|D]$}|�|||�||�d�d7}q dS)Nz

r�)r�filterrUr))r1r.r%ZmsgidZincludeZ
paragraphs�prrr�poentry_per_paragraph�s

z"_PotExporter.poentry_per_paragraphcCs\t�|�}z|j|j}Wn(tyBt�|�}||j|j<Yn0t�|�rX|�|�}|Sr-)	r5Z	getmodulerLr<r>r,r;�isclassr@)r1�objr:rVrrr�get_context�s



z_PotExporter.get_context)F)N)N)N)	r<rDrErFr3rUrWr[r^rrrrrH�s



	rHc	Cs�t|dd�rdS|j}t|dd�r<|�||jdj||d��|��D]J\}}}}||krr|�|�rdqDd�||g�}|rD|�||dj||d��qDdS)N�hiddenF�titleztitle of {name!r} {what})r&Zwhat�=zhelp of {name!r} {what})�getattrr&rWr`rQZ
iter_switchesZ	is_hiddenr)�exporterrV�optrZoptnamer&�_Zhelptxtrrr�
_write_option�s 
�
�rfcCs@tjj}|�t�}t|�D] }||}t||�|�|d�qdS)Nr)rZOption�OPTIONSr^�sortedrfrC)rcrgrVr&rdrrr�_standard_options�s

ricCs6d�|���}|jD]}t|t�st||||�qdS)Nzoption of {0!r} command)rQr&Z
takes_optionsr$�strrf)rcrV�cmdrrdrrr�_command_options�s

rlcCsR|�|j�}|j}|�|�}t�|�}dd�}|�|j|j||�t	|||�dS)NcSs|��ddkrdSdS)Nrz:Usage:T)�
splitlines)rZrrr�
exclude_usage�sz*_write_command_help.<locals>.exclude_usage)
r^r?rFrCr5Zcleandocr[r.r%rl)rcrkrVZrawdocZdcontext�docrnrrr�_write_command_help�s

�rpcs�t��D]:}t�|d�}|jr q|dur*qttd�|�t||�qt���|durn|�vrnt	�
td|���t�fdd��D��}t��D]f}t�|d�}|jr�q�|dur�|�
�|kr�q�|dur�|�
�|vr�q�ttd��||�
���t||�q�dS)z�Extract docstrings from path.

    This respects the Bazaar cmdtable/table convention and will
    only extract docstrings from functions mentioned in these tables.
    FNz+Exporting messages from builtin command: %szPlugin %s is not loadedc3s*|]"}�|���tjd�r|VqdS)rN)r.�
startswith�breezy�__path__)�.0r&��pluginsrr�	<genexpr>s�z!_command_helps.<locals>.<genexpr>z2Exporting messages from plugin command: {0} in {1})�
_mod_commandsZbuiltin_command_namesZget_cmd_objectr_rrrp�_mod_pluginrvr�BzrErrorrKZplugin_command_names�plugin_namerQ)rcr{Zcmd_nameZcommandZcore_pluginsrrur�_command_helps�s4�
�r|cCs�|�t�}tj}tt�D]b}tt|�}t�|�s2qt||�s>q||urHq|jrPqt|dd�}|rt	t
d�|�|�||�qdS)z&Extract fmt string from breezy.errors.Z_fmtNz Exporting message from error: %s)r^rrz�dirrbr5r\�
issubclassZinternal_errorrrrW)rcrVZ
base_klassr&�klassZfmtrrr�_error_messagess 



r�cCs�tj}|��D]z}|�|�}t|t�r>|�d|dd|�n"t|�r`|�d|dd||��|�|�}|dur|�	d|dd|�qdS)Nzdummy/help_topics/z/detail.txtrzen/help_topics/z.txtz/summary.txt)
r�topic_registry�keys�getr$rjr[�callableZget_summaryrU)rcr��keyroZsummaryrrr�_help_topics/s$


�
�
�r�FcCsBt||�}|dur4t|�t|�t|�t|�n
t||�dSr-)rHrir|r�r�)rIrrMrcrrr�
export_potAs

r�)r)N)NF)$rFZ
__future__rr5r6r'rrr4rrxrrrrryZsixishr	Ztracer
rZi18nrrrr+�objectr,rHrfrirlrpr|r�r�r�rrrr�<module>s,	

'9
*