
bc           @   sI  d  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 m Z d d d d d d	 d
 d d d d d d d d d d g Z	 e j
 j e j d d  Z e j d e j e j B Z d   Z d   Z dB dC dD dE dF dG f Z d'   e e d(  D Z i d) d 6d* d 6d+ d% 6Z d d,  Z d-   Z d.   Z d/   Z d dH d0     YZ d e f d1     YZ d d d2 d3  Z i  Z d d d e  d d4  Z! d e  d d d5  Z" i  a# i  a$ d6 a% d d7  Z& d d8  Z' d d9  Z( d:   Z) d;   Z* d<   Z+ d=   Z, d>   Z- d?   Z. d@   Z/ dA   Z0 e! Z1 d S(I   s  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.

iN(   t   ENOENTt   NullTranslationst   GNUTranslationst   Catalogt   findt   translationt   installt
   textdomaint   bindtextdomaint   bind_textdomain_codesett   dgettextt	   dngettextt   gettextt   lgettextt	   ldgettextt
   ldngettextt	   lngettextt   ngettextt   sharet   locales  
        (?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
    c         c   st   xh t  j t |   D]T } | j } | d k r4 q n  | j |  } | d k rb t d |   n  | Vq Wd Vd  S(   Nt   WHITESPACESt   INVALIDs    invalid token in plural form: %st    (   t   ret   finditert   _token_patternt	   lastgroupt   groupt
   ValueError(   t   pluralt   mot   kindt   value(    (    s   /usr/lib/python2.7/gettext.pyt	   _tokenizeT   s    		c         C   s"   |  r t  d |   St  d  Sd  S(   Ns#   unexpected token in plural form: %ss   unexpected end of plural form(   R   (   R    (    (    s   /usr/lib/python2.7/gettext.pyt   _error_   s    s   ||s   &&s   ==s   !=t   <t   >s   <=s   >=t   +t   -t   *t   /t   %c         C   s,   i  |  ]" \ } } | D] } | |  q q S(    (    (   t   .0t   it   opst   op(    (    s   /usr/lib/python2.7/gettext.pys
   <dictcomp>m   s   	 i   t   ort   ands   //c         C   sM  d } t  |   } x& | d k r: | d 7} t  |   } q W| d k r t |   \ } } d | | f } | d k r t d   q nb | d k r d	 | | f } nC y t | d
  } Wn t k
 r t |   n Xd | | f } t  |   } d } x | t k rt | } | | k  r$Pn  | d k rI| d k rId | } n  t j | |  } t |  | d  \ }	 } d | | |	 f } | } q W| | k od k n rd | } n  | d k rC| d k rCt |  d  \ }
 } | d k rt |   n  t |   \ } } d |
 | | f } | d k rCd | } qCn  | | f S(   NR   t   !s   not t   (s   %s(%s)t   )s%   unbalanced parenthesis in plural formt   ns   %s%si
   s   %s%did   i   i   s   (%s)i   s   %s %s %st   ?i    t   :s   %s if %s else %s(   i   i   (   i   i   (   t   nextt   _parseR   t   intR"   t   _binary_opst	   _c2py_opst   get(   t   tokenst   priorityt   resultt   nexttokt   subR    t   jR+   R-   t   rightt   if_truet   if_false(    (    s   /usr/lib/python2.7/gettext.pyR7   p   sP    


c         C   sA   y t  |   } Wn* t k
 r< t d |  j j f   n X|  S(   Ns'   Plural value must be an integer, got %s(   t   roundt	   TypeErrort	   __class__t   __name__(   R3   R+   (    (    s   /usr/lib/python2.7/gettext.pyt   _as_int   s    c         B   s   e  |   d k r! e d   n  y e e |    \ } } | rQ e |   n  d } x[ | D]S } | d k r | d 7} | d k r e d   q q^ | d k r^ | d 8} q^ q^ Wi e d	 6} d
 | | U| d SWn e k
 r e d   n Xd S(   s   Gets a C expression as used in PO files for plural forms and returns a
    Python function that implements an equivalent expression.
    i  s"   plural form expression is too longi    R1   i   i   s%   plural form expression is too complexR2   RI   s   if 1:
            def func(n):
                if not isinstance(n, int):
                    n = _as_int(n)
                return int(%s)
            t   funcN(   t   lenR   R7   R!   R"   RI   t   RuntimeError(   R   R>   R?   t   deptht   ct   ns(    (    s   /usr/lib/python2.7/gettext.pyt   c2py   s&    
c         C   s  d d l  m } | |   }  d
 } d } d } d } |  j d  } | d k rp |  | } |  |  }  | | O} n d } |  j d  } | d k r |  | } |  |  }  | | O} n d } |  j d	  } | d k r |  | }	 |  |  }  | | O} n d }	 |  }
 g  } x~ t | d  D]l } | | @s|
 } | | @rE| |	 7} n  | | @r\| | 7} n  | | @rs| | 7} n  | j |  qqW| j   | S(   Ni(   t	   normalizei   i    i   t   @R   t   .t   _i   i   i   (   R   RQ   R   t   ranget   appendt   reverse(   R   RQ   t   COMPONENT_CODESETt   COMPONENT_TERRITORYt   COMPONENT_MODIFIERt   maskt   post   modifiert   codesett	   territoryt   languaget   retR+   t   val(    (    s   /usr/lib/python2.7/gettext.pyt   _expand_lang   sL    






 
 
 
c           B   s   e  Z d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z e d d  Z RS(   c         C   sD   i  |  _  d  |  _ d  |  _ d  |  _ | d  k	 r@ |  j |  n  d  S(   N(   t   _infot   Nonet   _charsett   _output_charsett	   _fallbackR7   (   t   selft   fp(    (    s   /usr/lib/python2.7/gettext.pyt   __init__   s    				c         C   s   d  S(   N(    (   Ri   Rj   (    (    s   /usr/lib/python2.7/gettext.pyR7     s    c         C   s)   |  j  r |  j  j |  n	 | |  _  d  S(   N(   Rh   t   add_fallback(   Ri   t   fallback(    (    s   /usr/lib/python2.7/gettext.pyRl     s    	c         C   s   |  j  r |  j  j |  S| S(   N(   Rh   R   (   Ri   t   message(    (    s   /usr/lib/python2.7/gettext.pyR   
  s    	c         C   s   |  j  r |  j  j |  S| S(   N(   Rh   R   (   Ri   Rn   (    (    s   /usr/lib/python2.7/gettext.pyR     s    	c         C   s7   |  j  r |  j  j | | |  S| d k r/ | S| Sd  S(   Ni   (   Rh   R   (   Ri   t   msgid1t   msgid2R3   (    (    s   /usr/lib/python2.7/gettext.pyR     s
    	c         C   s7   |  j  r |  j  j | | |  S| d k r/ | S| Sd  S(   Ni   (   Rh   R   (   Ri   Ro   Rp   R3   (    (    s   /usr/lib/python2.7/gettext.pyR     s
    	c         C   s#   |  j  r |  j  j |  St |  S(   N(   Rh   t   ugettextt   unicode(   Ri   Rn   (    (    s   /usr/lib/python2.7/gettext.pyRq   $  s    	c         C   sC   |  j  r |  j  j | | |  S| d k r5 t |  St |  Sd  S(   Ni   (   Rh   t	   ungettextRr   (   Ri   Ro   Rp   R3   (    (    s   /usr/lib/python2.7/gettext.pyRs   )  s
    	
c         C   s   |  j  S(   N(   Rd   (   Ri   (    (    s   /usr/lib/python2.7/gettext.pyt   info1  s    c         C   s   |  j  S(   N(   Rf   (   Ri   (    (    s   /usr/lib/python2.7/gettext.pyt   charset4  s    c         C   s   |  j  S(   N(   Rg   (   Ri   (    (    s   /usr/lib/python2.7/gettext.pyt   output_charset7  s    c         C   s   | |  _  d  S(   N(   Rg   (   Ri   Ru   (    (    s   /usr/lib/python2.7/gettext.pyt   set_output_charset:  s    c         C   s   d d  l  } | r |  j p! |  j | j d <t | d  r d | k r] | j d | j d <n  d | k r | rx |  j p~ |  j | j d <n  d | k r |  j | j d <n  d | k r |  j | j d <q n  d  S(   NiRT   t   __contains__R   R   R   R   (	   t   __builtin__Rq   R   t   __dict__t   hasattrRs   R   R   R   (   Ri   Rr   t   namesRy   (    (    s   /usr/lib/python2.7/gettext.pyR   =  s    N(   RH   t
   __module__Re   Rk   R7   Rl   R   R   R   R   Rq   Rs   Rt   Ru   Rv   Rw   t   FalseR   (    (    (    s   /usr/lib/python2.7/gettext.pyR      s   												c           B   sS   e  Z d  Z d Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   l   * l   $< c         C   s  t  j } t | d d  } i  |  _ } d   |  _ | j   } t |  } | d | d   d } | |  j k r | d | d d ! \ } }	 }
 } d	 } nL | |  j k r | d
 | d d ! \ } }	 }
 } d } n t	 d d |   xt
 d |	  D]} | | | |
 |
 d ! \ } } | | } | | | | | d ! \ } } | | } | | k  r| | k  r| | | !} | | | !} n t	 d d |   | d k rd } x| j   D]	} | j   } | sqn  d } } d | k r9| j d d  \ } } | j   j   } | j   } | |  j | <| } n  | rY|  j | c d | 7<n  | d k r~| j d  d |  _ q| d k r| j d  } | d j d  d } t |  |  _ qqWn  d | k rp| j d  \ } } | j d  } |  j r<t | |  j  } g  | D] } t | |  j  ^ q} n  xk t t |   D] } | | | | | f <qOWn: |  j rt | |  j  } t | |  j  } n  | | | <|
 d 7}
 | d 7} q Wd S(   s8   Override this method to support alternative .mo formats.t   nameR   c         S   s   t  |  d k  S(   Ni   (   R8   (   R3   (    (    s   /usr/lib/python2.7/gettext.pyt   <lambda>X  R   s   <Ii   i    s   <4Ii   s   <IIs   >4Is   >IIs   Bad magic numberi   s   File is corruptR5   i   s   
s   content-types   charset=s   plural-formst   ;s   plural=s    N(   t   structt   unpackt   getattrt   _catalogR   t   readRK   t   LE_MAGICt   BE_MAGICt   IOErrort   xrangeRe   t
   splitlinest   stript   splitt   lowerRd   Rf   RP   Rr   RU   (   Ri   Rj   R   t   filenamet   catalogt   buft   buflent   magict   versiont   msgcountt	   masteridxt   transidxt   iiR+   t   mlent   mofft   mendt   tlent   tofft   tendt   msgt   tmsgt   lastkt   itemt   kt   vR   Ro   Rp   t   x(    (    s   /usr/lib/python2.7/gettext.pyR7   Q  st    	"	"	 
 

	
	(	

c         C   s}   t    } |  j j | |  } | | k rG |  j rC |  j j |  S| S|  j r` | j |  j  S|  j ry | j |  j  S| S(   N(   t   objectR   R;   Rh   R   Rg   t   encodeRf   (   Ri   Rn   t   missingR   (    (    s   /usr/lib/python2.7/gettext.pyR     s    				c         C   ss   t    } |  j j | |  } | | k rG |  j rC |  j j |  S| S|  j r` | j |  j  S| j t j    S(   N(	   R   R   R;   Rh   R   Rg   R   R   t   getpreferredencoding(   Ri   Rn   R   R   (    (    s   /usr/lib/python2.7/gettext.pyR     s    			c         C   s   yV |  j  | |  j |  f } |  j r8 | j |  j  S|  j rQ | j |  j  S| SWnD t k
 r |  j r |  j j | | |  S| d k r | S| Sn Xd  S(   Ni   (   R   R   Rg   R   Rf   t   KeyErrorRh   R   (   Ri   Ro   Rp   R3   R   (    (    s   /usr/lib/python2.7/gettext.pyR     s    			c         C   s   yL |  j  | |  j |  f } |  j r8 | j |  j  S| j t j    SWnD t k
 r |  j r{ |  j j | | |  S| d k r | S| Sn Xd  S(   Ni   (	   R   R   Rg   R   R   R   R   Rh   R   (   Ri   Ro   Rp   R3   R   (    (    s   /usr/lib/python2.7/gettext.pyR     s    		c         C   sQ   t    } |  j j | |  } | | k rM |  j rC |  j j |  St |  S| S(   N(   R   R   R;   Rh   Rq   Rr   (   Ri   Rn   R   R   (    (    s   /usr/lib/python2.7/gettext.pyRq     s    		
c         C   s~   y  |  j  | |  j |  f } WnW t k
 ry |  j rO |  j j | | |  S| d k rj t |  } qz t |  } n X| S(   Ni   (   R   R   R   Rh   Rs   Rr   (   Ri   Ro   Rp   R3   R   (    (    s   /usr/lib/python2.7/gettext.pyRs     s     	(   RH   R}   R   R   R7   R   R   R   R   Rq   Rs   (    (    (    s   /usr/lib/python2.7/gettext.pyR   L  s   	R						i    c         C   s  | d  k r t } n  | d  k r g  } x9 d	 D]1 } t j j |  } | r. | j d  } Pq. q. Wd | k r | j d  q n  g  } xA | D]9 } x0 t |  D]" } | | k r | j |  q q Wq W| r g  }	 n d  }	 x | D] } | d k r Pn  t j j	 | | d d |   }
 t j j	 d | d d |   } t j j
 |
  rk| rd|	 j |
  qk|
 Sn  t j j
 |  r | r|	 j |  q| Sq q W|	 S(
   Nt   LANGUAGEt   LC_ALLt   LC_MESSAGESt   LANGR5   t   Cs   %s.mos   /usr/share/locale-langpack(   R   R   R   R   (   Re   t   _default_localedirt   ost   environR;   R   RV   Rc   t   patht   joint   exists(   t   domaint	   localedirt	   languagest   allt   envarRb   t   nelangst   langt   nelangR>   t   mofilet	   mofile_lp(    (    s   /usr/lib/python2.7/gettext.pyR     sD    		c      	   C   s  | d  k r t } n  t |  | | d d } | sU | r@ t   St t d |    n  d  } x | D] } | t j j |  f }	 t	 j
 |	  }
 |
 d  k r t | d   } t	 j |	 | |   }
 Wd  QXn  t j |
  }
 | r |
 j |  n  | d  k r|
 } qb | j |
  qb W| S(   NR   i   s$   No translation file found for domaint   rb(   Re   R   R   R   R   R    R   R   t   abspatht   _translationsR;   t   opent
   setdefaultt   copyRw   Rl   (   R   R   R   t   class_Rm   R^   t   mofilesR>   R   t   keyt   tRj   (    (    s   /usr/lib/python2.7/gettext.pyR   (  s*    	!	c         C   s/   t  |  | d t d | } | j | |  d  S(   NRm   R^   (   R   t   TrueR   (   R   R   Rr   R^   R|   R   (    (    s   /usr/lib/python2.7/gettext.pyR   G  s    t   messagesc         C   s   |  d  k	 r |  a n  t S(   N(   Re   t   _current_domain(   R   (    (    s   /usr/lib/python2.7/gettext.pyR   U  s    	c         C   s)   | d  k	 r | t |  <n  t j |  t  S(   N(   Re   t   _localedirsR;   R   (   R   R   (    (    s   /usr/lib/python2.7/gettext.pyR   \  s    c         C   s&   | d  k	 r | t |  <n  t j |   S(   N(   Re   t   _localecodesetsR;   (   R   R^   (    (    s   /usr/lib/python2.7/gettext.pyR	   c  s    c         C   sP   y. t  |  t j |  d   d t j |   } Wn t k
 rB | SX| j |  S(   NR^   (   R   R   R;   Re   R   R   R   (   R   Rn   R   (    (    s   /usr/lib/python2.7/gettext.pyR
   j  s    c         C   sP   y. t  |  t j |  d   d t j |   } Wn t k
 rB | SX| j |  S(   NR^   (   R   R   R;   Re   R   R   R   (   R   Rn   R   (    (    s   /usr/lib/python2.7/gettext.pyR   r  s    c         C   si   y. t  |  t j |  d   d t j |   } Wn% t k
 rU | d k rN | S| Sn X| j | | |  S(   NR^   i   (   R   R   R;   Re   R   R   R   (   R   Ro   Rp   R3   R   (    (    s   /usr/lib/python2.7/gettext.pyR   z  s    c         C   si   y. t  |  t j |  d   d t j |   } Wn% t k
 rU | d k rN | S| Sn X| j | | |  S(   NR^   i   (   R   R   R;   Re   R   R   R   (   R   Ro   Rp   R3   R   (    (    s   /usr/lib/python2.7/gettext.pyR     s    c         C   s   t  t |   S(   N(   R
   R   (   Rn   (    (    s   /usr/lib/python2.7/gettext.pyR     s    c         C   s   t  t |   S(   N(   R   R   (   Rn   (    (    s   /usr/lib/python2.7/gettext.pyR     s    c         C   s   t  t |  | |  S(   N(   R   R   (   Ro   Rp   R3   (    (    s   /usr/lib/python2.7/gettext.pyR     s    c         C   s   t  t |  | |  S(   N(   R   R   (   Ro   Rp   R3   (    (    s   /usr/lib/python2.7/gettext.pyR     s    (   s   ||(   s   &&(   s   ==s   !=(   R#   R$   s   <=s   >=(   R%   R&   (   R'   R(   R)   (    (2   t   __doc__R   R   R   R   R   t   syst   errnoR    t   __all__R   R   t   prefixR   t   compilet   VERBOSEt   DOTALLR   R!   R"   R9   t	   enumerateR:   R7   RI   RP   Rc   R   R   Re   R   R   R~   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   (    (    (    s   /usr/lib/python2.7/gettext.pyt   <module>   s\   &H				1		$	+T5								