Your IP : 3.135.247.237


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/gettext.cpython-34.pyc

�
i fQ�@sdZddlZddlZddlZddlZddlZddlZddlZddlm	Z	dddddd	d
ddd
dddddddgZ
ejjej
dd�ZejdejejB�Zdd�Zdd�ZdOZd)d*�eed+�D�Zid,d6d-d6d.d'6ZdPd/d0�Zd1d2�Zd3d4�Zd5d6�ZGd7d�d�ZGd8d�de�Zddd9d:d�ZiZdddd9dd;d�Z dddd<d	�Z!ia"ia#d=a$dd>d
�Z%dd?d�Z&dd@d�Z'dAd
�Z(dBd�Z)dCd�Z*dDd�Z+dEd�Z,dFd�Z-dGd�Z.dHd�Z/e Z0dS)Qa�Internationalization and localization support.

This module provides internationalization (I18N) and localization (L10N)
support for your Python programs by providing an interface to the GNU gettext
message catalog library.

I18N refers to the operation by which a program is made aware of multiple
languages.  L10N refers to the adaptation of your program, once
internationalized, to the local language and cultural habits.

�N)�ENOENT�NullTranslations�GNUTranslations�Catalog�find�translation�install�
textdomain�bindtextdomain�bind_textdomain_codeset�dgettext�	dngettext�gettext�lgettext�	ldgettext�
ldngettext�	lngettext�ngettextZshare�localea�
        (?P<WHITESPACES>[ \t]+)                    | # spaces and horizontal tabs
        (?P<NUMBER>[0-9]+\b)                       | # decimal integer
        (?P<NAME>n\b)                              | # only n is allowed
        (?P<PARENTHESIS>[()])                      |
        (?P<OPERATOR>[-*/%+?:]|[><!]=?|==|&&|\|\|) | # !, *, /, %, +, -, <, >,
                                                     # <=, >=, ==, !=, &&, ||,
                                                     # ? :
                                                     # unary and bitwise ops
                                                     # not allowed
        (?P<INVALID>\w+|.)                           # invalid token
    ccstxhtjt|�D]T}|j}|dkr4qn|j|�}|dkrbtd|��n|VqWdVdS)NZWHITESPACESZINVALIDz invalid token in plural form: %s�)�re�finditer�_token_pattern�	lastgroup�group�
ValueError)�pluralZmoZkind�value�r�,/opt/alt/python34/lib64/python3.4/gettext.py�	_tokenizeTs		r cCs"|rtd|�Std�SdS)Nz#unexpected token in plural form: %szunexpected end of plural form)r)rrrr�_error_sr!�||�&&�==�!=�<�>�<=�>=�+�-�*�/�%cCs,i|]"\}}|D]}||�qqSrr)�.0�iZops�oprrr�
<dictcomp>ms	r2��or�andz//cCsQd}t|�}x&|dkr:|d7}t|�}qW|dkr�t|�\}}d||f}|dkr�td��q�nf|dkr�d	||f}nGyt|d
�}Wn!tk
r�t|�d�YnXd||f}t|�}d}x�|tkr�t|}||kr(Pn|dkrM|dkrMd|}ntj||�}t||d�\}	}d|||	f}|}qW||ko�dknr�d|}n|dkrG|dkrGt|d�\}
}|dkrt|��nt|�\}}d|
||f}|dkrGd|}qGn||fS)Nr�!znot �(z%s(%s)�)z%unbalanced parenthesis in plural form�nz%s%s�
z%s%d�d��z(%s)r3z%s %s %s�?r�:z%s if %s else %s)r<r=)r<r=)�next�_parser�intr!�_binary_ops�	_c2py_ops�get)�tokensZpriority�result�nexttok�subr�jr0r1�rightZif_trueZif_falserrrrApsP





rAcCsEyt|�}Wn.tk
r@td|jjf�d�YnX|S)Nz'Plural value must be an integer, got %s)�round�	TypeError�	__class__�__name__)r9r0rrr�_as_int�s
rPcCst|�dkr!td��ny�tt|��\}}|rQt|��nd}x[|D]S}|dkr�|d7}|dkr�td��q�q^|dkr^|d8}q^q^Witd	6}td
||�|dSWntk
r�td��YnXdS)
z�Gets a C expression as used in PO files for plural forms and returns a
    Python function that implements an equivalent expression.
    i�z"plural form expression is too longrr7r3�z%plural form expression is too complexr8rPz�if True:
            def func(n):
                if not isinstance(n, int):
                    n = _as_int(n)
                return int(%s)
            �funcN)�lenrrAr r!rP�exec�RuntimeError)rrGrHZdepth�c�nsrrr�c2py�s(



rXc
Cs�tj|�}d}d	}d
}d}|jd�}|dkro||d�}|d|�}||O}nd}|jd�}|dkr�||d�}|d|�}||O}nd}|jd�}|dkr||d�}|d|�}||O}nd}|}	g}
x~t|d�D]l}||@s.|	}||@r\||7}n||@rs||7}n||@r�||7}n|
j|�q.q.W|
j�|
S)Nr3r��@r�.�_r3rYr=)rZ	normalizer�range�append�reverse)
�locZCOMPONENT_CODESETZCOMPONENT_TERRITORYZCOMPONENT_MODIFIER�mask�posZmodifier�codesetZ	territoryZlanguageZretr0�valrrr�_expand_lang�sJ









rec@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
ddd�ZdS)rNcCsDi|_d|_d|_d|_|dk	r@|j|�ndS)N)�_info�_charset�_output_charset�	_fallbackrA)�self�fprrr�__init__�s				zNullTranslations.__init__cCsdS)Nr)rjrkrrrrAszNullTranslations._parsecCs)|jr|jj|�n	||_dS)N)ri�add_fallback)rj�fallbackrrrrms	zNullTranslations.add_fallbackcCs|jr|jj|�S|S)N)rir)rj�messagerrrr	s	zNullTranslations.gettextcCs|jr|jj|�S|S)N)rir)rjrorrrrs	zNullTranslations.lgettextcCs7|jr|jj|||�S|dkr/|S|SdS)Nr3)rir)rj�msgid1�msgid2r9rrrrs
	zNullTranslations.ngettextcCs7|jr|jj|||�S|dkr/|S|SdS)Nr3)rir)rjrprqr9rrrrs
	zNullTranslations.lngettextcCs|jS)N)rf)rjrrr�info#szNullTranslations.infocCs|jS)N)rg)rjrrr�charset&szNullTranslations.charsetcCs|jS)N)rh)rjrrr�output_charset)szNullTranslations.output_charsetcCs
||_dS)N)rh)rjrsrrr�set_output_charset,sz#NullTranslations.set_output_charsetcCs�ddl}|j|jd<t|d�r�d|krN|jd|jd<nd|krm|j|jd<nd|kr�|j|jd<nd|kr�|j|jd<q�ndS)Nrr\�__contains__rrrr)�builtinsr�__dict__�hasattrrrr)rj�namesrwrrrr/szNullTranslations.install)rO�
__module__�__qualname__rlrArmrrrrrrrsrtrurrrrrr�sc@sXeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)rl�*l�$<c Cs�tj}t|dd�}i|_}dd�|_|j�}t|�}|d|dd��d}||jkr�|d	|dd
��\}}	}
}d}nO||jkr�|d|dd
��\}}	}
}d
}nt	dd|��x�t
d|	�D]�}
||||
|
d��\}}||}|||||d��\}}||}||kr�||kr�|||�}|||�}nt	dd|��|dkr�d}x*|jdjd��D]
}|j
�j�}|sq�nd}}d|krf|jdd�\}}|j�j�}|j�}||j|<|}n|r�|j|d|7<n|dkr�|jd�d|_q�|dkr�|jd�}|djd�d}t|�|_q�q�Wn|jpd}d|kr{|jd�\}}|jd�}t||�}xRt|�D]%\}
}t||�|||
f<qOWnt||�|t||�<|
d7}
|d7}qWdS)z8Override this method to support alternative .mo formats.�namercSst|dk�S)Nr3)rB)r9rrr�<lambda>Isz(GNUTranslations._parse.<locals>.<lambda>z<INr=rz<4IrQz<IIz>4Iz>IIzBad magic number�zFile is corrupt�
�asciir?r3zcontent-typezcharset=zplural-forms�;zplural=s)�struct�unpack�getattr�_catalogr�readrS�LE_MAGIC�BE_MAGIC�OSErrorr]�split�encode�decode�strip�lowerrfrgrX�str�	enumerate) rjrkr��filenameZcatalogZbufZbuflen�magic�versionZmsgcountZ	masteridxZtransidxZiir0ZmlenZmoffZmendZtlenZtoffZtend�msg�tmsgZlastkZb_item�item�k�vrrsrprq�xrrrrABsl	
%	%	#
#


	
 
zGNUTranslations._parsecCsst�}|jj||�}||krG|jrC|jj|�S|S|jr`|j|j�S|jtj��S)N)	�objectr�rErirrhr�r�getpreferredencoding)rjro�missingr�rrrr�s			zGNUTranslations.lgettextcCs�yL|j||j|�f}|jr8|j|j�S|jtj��SWnEtk
r�|jr{|jj|||�S|dkr�|S|SYnXdS)Nr3)	r�rrhr�rr��KeyErrorrir)rjrprqr9r�rrrr�s	
	zGNUTranslations.lngettextcCsKt�}|jj||�}||krG|jrC|jj|�S|S|S)N)r�r�rErir)rjror�r�rrrr�s		zGNUTranslations.gettextcCssy |j||j|�f}WnLtk
rn|jrO|jj|||�S|dkrd|}n|}YnX|S)Nr3)r�rr�rir)rjrprqr9r�rrrr�s 
		zGNUTranslations.ngettextN)
rOr{r|r�r�rArrrrrrrrr=sN	FcCsT|dkrt}n|dkr�g}x9dD]1}tjj|�}|r.|jd�}Pq.q.Wd|kr�|jd�q�ng}xA|D]9}x0t|�D]"}||kr�|j|�q�q�Wq�W|r�g}	nd}	xl|D]d}|dkr�Pntjj||dd|�}
tjj	|
�r�|rE|	j|
�qL|
Sq�q�W|	S)	N�LANGUAGE�LC_ALL�LC_MESSAGES�LANGr?�Cz%s.mo)r�zLC_ALLzLC_MESSAGESr�)
�_default_localedir�os�environrEr�r^re�path�join�exists)�domain�	localedir�	languages�allZenvarrdZnelangsZlangZnelangrG�mofilerrrr�s8	

	
cCs|dkrt}nt|||dd�}|sU|r@t�Sttd|��nd}x�|D]�}|tjj|�f}	tj	|	�}
|
dkr�t
|d��}tj|	||��}
WdQXntj|
�}
|r�|
j
|�n|dkr|
}qb|j|
�qbW|S)Nr�Tz$No translation file found for domain�rb)rrrr�rr�r��abspath�
_translationsrE�open�
setdefault�copyrurm)r�r�r�Zclass_rnrcZmofilesrGr��key�trkrrrr�s*	
!	cCs,t||ddd|�}|j|�dS)NrnTrc)rr)r�r�rcrzr�rrrrsZmessagescCs|dk	r|antS)N)�_current_domain)r�rrrr	s	cCs)|dk	r|t|<ntj|t�S)N)�_localedirsrEr�)r�r�rrrr
s
cCs&|dk	r|t|<ntj|�S)N)�_localecodesetsrE)r�rcrrrr#s
cCsTy.t|tj|d�dtj|��}Wntk
rF|SYnX|j|�S)Nrc)rr�rEr�r�r)r�ror�rrrr*s
	cCsTy.t|tj|d�dtj|��}Wntk
rF|SYnX|j|�S)Nrc)rr�rEr�r�r)r�ror�rrrr2s
	cCsjy.t|tj|d�dtj|��}Wn&tk
rV|dkrN|S|SYnX|j|||�S)Nrcr3)rr�rEr�r�r)r�rprqr9r�rrrr
:s
	cCsjy.t|tj|d�dtj|��}Wn&tk
rV|dkrN|S|SYnX|j|||�S)Nrcr3)rr�rEr�r�r)r�rprqr9r�rrrrEs
	cCs
tt|�S)N)rr�)rorrrrPscCs
tt|�S)N)rr�)rorrrrSscCstt|||�S)N)r
r�)rprqr9rrrrVscCstt|||�S)N)rr�)rprqr9rrrrYs�r"�r#�r$r%�r&r'r(r)�r*r+�r,r-r.)r�r�r�r�r�r����)1�__doc__rr��ior�rr��sys�errnor�__all__r�r��base_prefixr��compile�VERBOSE�DOTALLrr r!rCr�rDrArPrXrerrrr�rrr�r�r�r	r
rrrr
rrrrrrrrrr�<module>s\&T	1$*F�&

?>