https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/util/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/util/__pycache__/translation.cpython-310.pyc
o

�k�`�=�@sbdZddlZddlZddlmZmZddlmZddlm	Z	gd�Z
dd�Zd	d
�Zdd�Z
d
d�ZZe	Zdd�Zdd�Ze�d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zdd"lmZGd#d$�d$e�Zd%Zzgdd&l m!Z!m"Z"dd'l#m$Z$m%Z%Gd(d)�d)e&�Z'e'�Z(d*d!�Ze(jZeZ)e(j*Z*e(j+Z+e(j,Z,e(j-Z-e-Z.e(j/Z/e(j0Z0e0Z1e(j2Z2d+d�ZdJd,d-�Z3d.d/�Z4d0d1�Z5dJd2d3�Z6d4d5�Z7d6d7�Z8d8d9�Z9d:d;�Z:d<ZWnGe;�ydZ!eZZ)e
Z*eZ+eZ,eZ-Z.eZ/eZ0Z1eZ2e�Z(dJd=d-�Z3d>d/�Z4d?d1�Z5dJd@d3�Z6dAd5�Z7dBd7�Z8dCd9�Z9dDd;�Z:YnwdEdF�Z<dGdH�Z=ee<e,e=e+e.dI�Z>dS)Kz,Utilities for text translation with gettext.�N)�ThreadLocal�	threading)�tag)�cleandoc)�gettext�ngettext�gettext_noop�
ngettext_noop�tgettext�
tgettext_noop�	tngettext�tngettext_noopcCs(|rz||WStyY|Sw|S�N)�KeyError��string�kwargs�r�7/usr/lib/python3/dist-packages/trac/util/translation.py�safefmts
�rcKs
t||�Sr)rrrrrr%�
rcK�t|fi|��Sr)r��domainrrrrr�
dgettext_noop(�rcCs|Srr)rrrr�<lambda>+�rcK�&|dkr|n|}|�d|�t||�S�N��num)�
setdefaultr��singular�pluralr!rrrrrr	.�
r	cK�t|||fi|��Sr)r	�rr$r%r!rrrr�dngettext_noop3�r)z#%\((\w+)\)(?:s|[\d]*d|\d*.?\d*[fg])cCs<t�|�}tdt|�d�D]}|�||d�||<q
t|�S)Nr �z???)�	_param_re�split�range�len�getr)�transr�
trans_elts�irrr�_tag_kwargs7s
r4cKs|rt||�S|Sr)r4rrrrr=�rcKrr)rrrrr�dtgettext_noop@rr6cKrr)r"r4r#rrrr
Cr&r
cKr'r)r
r(rrr�dtngettext_noopHr*r7cC�dSrr�r�env_path�
locale_dirrrr�
add_domainK�r<c
sH|r
t|dt�s
|d}ttttttttdd�d�	��fdd�|D�S)NrcSr8rr)r:r;rrrrZrz"domain_functions.<locals>.<lambda>)	r�_�N_rr
�tag_r�tagn_r<csg|]}�|�qSrr��.0�s��
_functionsrr�
<listcomp>\��$domain_functions.<locals>.<listcomp>)�
isinstance�str�	s_gettextr�_noopr	rr
�r�symbolsrrEr�domain_functionsNs�rP)�NullTranslationsc@s eZdZdZdd�Zdd�ZdS)�NullTranslationsBabelz9NullTranslations doesn't have the domain related methods.cCs
|�|�Sr)r)�selfrrrrr�	dugettextdrzNullTranslationsBabel.dugettextcCs|�|||�Sr)r)rSrr$r%r!rrr�
dungettextg�z NullTranslationsBabel.dungettextN)�__name__�
__module__�__qualname__�__doc__rTrUrrrrrRasrRF)�Locale�UnknownLocaleError)�	LazyProxy�Translationsc@s�eZdZdZdd�Zdd�Zd'dd�Zd'd	d
�Zdd�Zd
d�Z	e
dd��Ze
dd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdS)(�TranslationsProxya�Delegate Translations calls to the currently active Translations.

        If there's none, wrap those calls in LazyProxy objects.

        Activation is controlled by `activate` and `deactivate` methods.
        However, if retrieving the locale information is costly, it's also
        possible to enable activation on demand only, by providing a callable
        to `make_activable`.
        cCs0tddd�|_t�|_i|_t��|_d|_dS)N)�args�translationsF)	r�_currentrR�_null_translations�_plugin_domainsr�RLock�_plugin_domains_lock�_activate_failed�rSrrr�__init__{s


zTranslationsProxy.__init__cCsB|j�|j�|i�}|||<Wd�dS1swYdSr)rfrdr")rSrr:�locales_dir�domainsrrrr<�s
"�zTranslationsProxy.add_domainNcCs||f|j_dSr)rbr`�rS�
get_localer:rrr�make_activable�rz TranslationsProxy.make_activablec	Cs�zt�dd�}Wn
tyd|_YdSwt�||pd�}t|t�s'|j}nA|�|t�||p0dd��|rh|j	�|j
�|i�}t|�
��}Wd�n1sQwY|D]\}}|�|t�|||��qX||j_d|_dS)N�trac�localeT�en_US�traciniF)�
pkg_resources�resource_filename�	Exceptionrgr^�loadrJrc�_addrfrdr0�list�itemsrbra)rSrpr:r;�trkr�dirnamerrr�activate�s.�
���
zTranslationsProxy.activatecCsd|j_|jjd}|j_|Sr)rbr`ra�rSrzrrr�
deactivate�szTranslationsProxy.deactivatecCs|r||j_dSdSr)rbrar}rrr�
reactivate�s�zTranslationsProxy.reactivatecCs|jjp|jSr)rbrarcrhrrr�active�szTranslationsProxy.activecCs@|jjdur|jj\}}d|j_|�|�|�|jjdup|jSr)rbr`r|rargrlrrr�isactive�s�zTranslationsProxy.isactivecCst|t�r|�|�dSdSr)rJr^�add)rSrzrarrrrw�s
�zTranslationsProxy._addcCst|j|�Sr)�getattrr�)rS�namerrr�__getattr__�szTranslationsProxy.__getattr__c�$���fdd�}�jst|�S|�S)Ncst�j�����Sr)rr�rr�rrSrrr�_gettext�r5z+TranslationsProxy.gettext.<locals>._gettext�r�r])rSrrr�rr�rr�szTranslationsProxy.gettextc�&����fdd�}�jst|�S|�S)Ncst�j������Sr)rr�rTr�rrrSrrr�	_dgettext�r*z-TranslationsProxy.dgettext.<locals>._dgettextr�)rSrrrr�rr�r�dgettext�szTranslationsProxy.dgettextc�<������d�������fdd�}�jst|�S|�S)Nr!c��j�����}t|��Sr)r�rr�r1�rr!r%rSr$rr�	_ngettext��
z-TranslationsProxy.ngettext.<locals>._ngettext��copyr"r�r])rSr$r%r!rr�rr�rr��zTranslationsProxy.ngettextcs>������d��������fdd�}�jst|�S|�S)Nr!cs�j������}t|��Sr)r�rUrr��rrr!r%rSr$rr�
_dngettext�s
z/TranslationsProxy.dngettext.<locals>._dngettextr�)rSrr$r%r!rr�rr�r�	dngettext�szTranslationsProxy.dngettextcr�)Ncs�j���}�r
t|��S|Sr)r�rr4r�r�rr�	_tgettext�sz-TranslationsProxy.tgettext.<locals>._tgettextr�)rSrrr�rr�rr
�szTranslationsProxy.tgettextcr�)Ncs �j����}�rt|��S|Sr)r�rTr4r�r�rr�
_dtgettext�sz/TranslationsProxy.dtgettext.<locals>._dtgettextr�)rSrrrr�rr�r�	dtgettext�szTranslationsProxy.dtgettextcr�)Nr!cr�r)r�rr4r�r�rr�
_tngettext�r�z/TranslationsProxy.tngettext.<locals>._tngettextr�)rSr$r%r!rr�rr�rr�r�zTranslationsProxy.tngettextcs2����������fdd�}�jst|�S|�S)Ncs8�j������}d|vr�j�d��rt|��S|S)Nz%(num))r!)r�rU�updater4r�r�rr�_dtngettextsz1TranslationsProxy.dtngettext.<locals>._dtngettext)r�r�r])rSrr$r%r!rr�rr�r�
dtngettexts
zTranslationsProxy.dtngettextr)rWrXrYrZrir<rnr|r~r�propertyr�r�rwr�rr�rr�r
r�rr�rrrrr_ps,
	






r_c	s^|r
t|dt�s
|d}ttjtjtjtjtjtjtjd����fdd���fdd�|D�S)aqPrepare partial instantiations of domain translation functions.

        :param domain: domain used for partial instantiation
        :param symbols: remaining parameters are the name of commonly used
                        translation function which will be bound to the domain

        Note: the symbols can also be given as an iterable in the 2nd argument.
        r)rr>rr
r@rrAr<cs�dkrtS���fdd�S)Nr?cs���g|�Ri|��Srr)r`�kw)rFr�symbolrrr'sz6domain_functions.<locals>.wrapdomain.<locals>.<lambda>)rM�r�)rFrr�r�
wrapdomain$sz$domain_functions.<locals>.wrapdomaincsg|]}�|��qSrrrB)r�rrrG(rHrI)	rJrK�
s_dgettextrar�r�r�r�r<rNr)rFrr�rrPs	�
cCst�|||�dSr)rar<r9rrrr<6r5cCst�||�dSr)rar|�rpr:rrrr|9rr|cCst��S)zSDeactivate translations.
        :return: the current Translations, if any
        )rar~rrrrr~<sr~cCs
t�|�S)zxReactivate previously deactivated translations.
        :param t: the Translations, as returned by `deactivate`
        )rar�rzrrrrBs
rcCst�||�dS)z�Defer activation of translations.
        :param get_locale: a callable returning a Babel Locale object
        :param env_path: the environment to use for looking up catalogs
        N)rarn�rmr:rrrrnHsrncC�tSr�rarrrr�get_translationsOr=r�cCs4zdd�t�dd�D�}|WStygYSw)ziReturn a list of locale identifiers of the locales for which
        translations are available.
        cSs(g|]}d|vrt�dd|�r|�qS)�.roz!locale/%s/LC_MESSAGES/messages.mo)rs�resource_exists)rCr{rrrrGWs���z)get_available_locales.<locals>.<listcomp>rorp)rs�resource_listdirru)�localesrrr�get_available_localesRs
��r�cCsddd�}t�}d|vr|�d�t�||�||��}|r0t|�|vr0|jd|_t|�|vs0J�|S)NcSsdd�|D�S)NcSsg|]
}|r|�dd��qS)�-r>)�replace)rC�idrrrrGbsz<get_negotiated_locale.<locals>.normalize.<locals>.<listcomp>r)�
locale_idsrrr�	normalizearVz(get_negotiated_locale.<locals>.normalizerq)r��appendr[�	negotiaterK�_data�script)�preferred_localesr��available_localesrprrr�get_negotiated_locale`s

�r�c	Cs,z	t�|�}W|jSttfyYdSw)zb"Return locale name from locale identifier, or `None` if
        identifier is not valid.
        N)r[�parser\�
ValueError�display_name)�	locale_idrprrr�get_locale_namess��r�TcCr8rrr�rrrr|�r=cCr8rrrrrrr~�r=cCr8rrr�rrrr�r=cCr8rrr�rrrrn�r=cCr�rr�rrrrr��r=cCsgSrrrrrrr��r=cCr8rr)r�rrrr��r=cCr8rr)r�rrrr��r=cKs d�|���}t||fi|��S)zoRetrieves translations for "squeezed" messages, in a domain.

    See `s_gettext` for additional details.

    � )�joinr-r�)r�msgidrrrrr��sr�cKsd�|���}t|fi|��S)aRetrieves translations for "squeezed" messages (in default domain).

    Squeezed messages are text blocks in which white-space has been
    simplified during extraction (see `trac.dist.extract_html`). The
    catalog contain msgid with minimal whitespace.  As a consequence,
    the msgid have to be normalized as well at retrieval time
    (i.e. here).

    This typically happens for trans blocks and gettext functions in
    Jinja2 templates, as well as all the text extracted from legacy
    Genshi templates.

    r�)r�r-r)r�rrrrrL�srL)r>r�r�rrr@r)?rZrs�re�trac.util.concurrencyrr�trac.util.htmlr�trac.util.textr�__all__rrrr?rM�	cleandoc_r	r)�compiler,r4rr6r
r7r<rPrrQrR�	has_babel�babelr[r\�
babel.supportr]r^�objectr_rar>r�rr�r
r@r�rrAr�r|r~rrnr�r�r�r��ImportErrorr�rL�	functionsrrrr�<module>s�
	
	



�'	
�

https://t.me/RX1948 - 2025