Your IP : 3.15.142.42


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/gettext.cpython-35.pyc



��YfT�@s|dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	dddddd	d
ddd
dddddddgZ
ejjej
dd�ZejdejejB�Zdd�Zdd�ZdOZd)d*�eed+�D�Zdd,dd-d'd.iZdPd/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
    ccsnxbtjt|�D]N}|j}|dkr1q|j|�}|dkr\td|��|VqWdVdS)NZWHITESPACESZINVALIDz invalid token in plural form: %s�)�re�finditer�_token_pattern�	lastgroup�group�
ValueError)�pluralZmoZkind�value�r�,/opt/alt/python35/lib64/python3.5/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Cs<d}t|�}x&|dkr:|d7}t|�}qW|dkr�t|�\}}d||f}|dkr�td��nf|dkr�d	||f}nGyt|d
�}Wn!tk
r�t|�d�YnXd||f}t|�}d}x�|tkr�t|}||kr"P|dkrD|dkrDd|}tj||�}t||d�\}	}d|||	f}|}q�W||ko�dknr�d|}|dkr2|dkr2t|d�\}
}|dkr�t|��t|�\}}d|
||f}|dkr2d|}||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
rPcCs�t|�dkrtd��y�tt|��\}}|rKt|��d}xU|D]M}|dkr�|d7}|dkr�td��qX|dkrX|d8}qXWd	ti}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�RecursionError)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}
xrt|d�D]`}||@s.|	}||@rY||7}||@rm||7}||@r�||7}|
j|�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)rNcCsAi|_d|_d|_d|_|dk	r=|j|�dS)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.gettextcCsE|jr|jj|�S|jr2|j|j�S|jtj��S)N)rirrh�encoder�getpreferredencoding)rjrorrrrs
		zNullTranslations.lgettextcCs7|jr|jj|||�S|dkr/|S|SdS)Nr3)rir)rj�msgid1�msgid2r9rrrrs
	zNullTranslations.ngettextcCsf|jr|jj|||�S|dkr4|}n|}|jrS|j|j�S|jtj��S)Nr3)rirrhrprrq)rjrrrsr9�tmsgrrrrs			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)rjrvrrr�set_output_charset1sz#NullTranslations.set_output_charsetcCs�ddl}|j|jd<t|d�r�d|krK|jd|jd<d|krg|j|jd<d|kr�|j|jd<d|kr�|j|jd<dS)Nrr\�__contains__rrrr)�builtinsr�__dict__�hasattrrrr)rj�namesrzrrrr4szNullTranslations.install)rO�
__module__�__qualname__rlrArmrrrrrurvrwrxrrrrrr�sc@sjeZdZdZdZdZdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)rl�*l�$<rr3cCs|d?|d@fS)z/Returns a tuple of major version, minor version�i��r)rj�versionrrr�
_get_versionsJszGNUTranslations._get_versionsc"Cs�tj}t|dd�}i|_}dd�|_|j�}t|�}|d|dd��d}||jkr�|d	|dd
��\}}	}
}d}nO||jkr�|d|dd
��\}}	}
}d
}nt	dd|��|j
|�\}
}|
|jkr8t	ddt|
�|��x�t
d|	�D]�}||||
|
d��\}}||}|||||d��\}}||}||kr�||kr�|||�}|||�}nt	dd|��|dkrd}x|jd�D]}|j�j�}|s8qd}}d|kr�|jdd�\}}|j�j�}|j�}||j|<|}n|r�|j|d|7<|dkr�|jd�d|_q|dkr|jd�}|djd�d}t|�|_qW|jp+d}d|kr�|jd�\}} |jd�}t||�}xRt|�D]%\}}!t|!|�|||f<qzWnt||�|t||�<|
d7}
|d7}qHWdS)z8Override this method to support alternative .mo formats.�namercSst|dk�S)Nr3)rB)r9rrr�<lambda>Usz(GNUTranslations._parse.<locals>.<lambda>z<INr=rz<4IrQz<IIz>4Iz>IIzBad magic numberzBad version number �zFile is corrupts
r?r3�
zcontent-typezcharset=zplural-forms�;zplural=�asciis)�struct�unpack�getattr�_catalogr�readrS�LE_MAGIC�BE_MAGIC�OSErrorr��VERSIONS�strr]�split�decode�strip�lowerrfrgrX�	enumerate)"rjrkr��filenameZcatalogZbufZbuflen�magicr�ZmsgcountZ	masteridxZtransidxZiiZ
major_versionZ
minor_versionr0ZmlenZmoffZmendZtlenZtoffZtend�msgrtZlastkZb_item�item�k�vrrvrrrs�xrrrrANsr	
%	%	#
#


	
 
zGNUTranslations._parsecCsut�}|jj||�}||krI|jrC|jj|�S|}|jrb|j|j�S|jtj��S)N)	�objectr�rErirrhrprrq)rjro�missingrtrrrr�s			zGNUTranslations.lgettextcCs�y |j||j|�f}WnLtk
rn|jrO|jj|||�S|dkrd|}n|}YnX|jr�|j|j�S|jtj��S)Nr3)	r�r�KeyErrorrirrhrprrq)rjrrrsr9rtrrrr�s 
			zGNUTranslations.lngettextcCsKt�}|jj||�}||krG|jrC|jj|�S|S|S)N)r�r�rErir)rjror�rtrrrr�s		zGNUTranslations.gettextcCssy |j||j|�f}WnLtk
rn|jrO|jj|||�S|dkrd|}n|}YnX|S)Nr3)r�rr�rir)rjrrrsr9rtrrrr�s 
		zGNUTranslations.ngettextN)rr3)rOr~rr�r�r�r�rArrrrrrrrrBsT	FcCs?|dkrt}|dkrvg}x6dD].}tjj|�}|r+|jd�}Pq+Wd|krv|jd�g}x>|D]6}x-t|�D]}||kr�|j|�q�Wq�W|r�g}	nd}	xf|D]^}|dkr�Ptjj||dd|�}
tjj	|
�r�|r3|	j|
�q�|
Sq�W|	S)	N�LANGUAGE�LC_ALL�LC_MESSAGES�LANGr?�Cz%s.mo)r�r�r�r�)
�_default_localedir�os�environrEr�r^re�path�join�exists)�domain�	localedir�	languages�allZenvarrdZnelangsZlangZnelangrG�mofilerrrr�s8


	
cCs|dkrt}t|||dd�}|sO|r=t�Sttd|��d}x�|D]�}|tjj|�f}	tj	|	�}
|
dkr�t
|d��}tj|	||��}
WdQRXtj|
�}
|r�|
j
|�|dkr�|
}q\|j|
�q\W|S)Nr�Tz$No translation file found for domain�rb)rrrr�rr�r��abspath�
_translationsrE�open�
setdefault�copyrxrm)r�r�r�Zclass_rnrcZmofilesrGr��key�trkrrrr�s*

	cCs,t||ddd|�}|j|�dS)NrnTrc)rr)r�r�rcr}r�rrrrsZmessagescCs|dk	r|atS)N)�_current_domain)r�rrrr	'scCs&|dk	r|t|<tj|t�S)N)�_localedirsrEr�)r�r�rrrr
.s
cCs#|dk	r|t|<tj|�S)N)�_localecodesetsrE)r�rcrrrr5s
cCsTy.t|tj|d�dtj|��}Wntk
rF|SYnX|j|�S)Nrc)rr�rEr�r�r)r�ror�rrrr<s
	cCsotj|�}y%t|tj|d�d|�}Wn+tk
ra|j|pYtj��SYnX|j|�S)Nrc)	r�rErr�r�rprrqr)r�rorcr�rrrrDs%
cCsjy.t|tj|d�dtj|��}Wn&tk
rV|dkrN|S|SYnX|j|||�S)Nrcr3)rr�rEr�r�r)r�rrrsr9r�rrrr
Ls
	cCs�tj|�}y%t|tj|d�d|�}WnFtk
r||dkrY|}n|}|j|pttj��SYnX|j|||�S)Nrcr3)	r�rErr�r�rprrqr)r�rrrsr9rcr�rtrrrrWs%
	cCs
tt|�S)N)rr�)rorrrrcscCs
tt|�S)N)rr�)rorrrrfscCstt|||�S)N)r
r�)rrrsr9rrrriscCstt|||�S)N)rr�)rrrsr9rrrrls�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$*K�&

?>