
mKc           @   s  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k l Z d d d d d d	 d
 d d d d d g Z	 e i
 i e i d d  Z d   Z d   Z d   Z d d' d     YZ d e f d     YZ d d d d  Z h  Z d d d e d d  Z d e d d d  Z h  a h  a d a d d  Z d d  Z d d  Z d   Z d    Z  d!   Z! d"   Z" d#   Z# d$   Z$ d%   Z% d&   Z& e Z' d S((   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   dgettextt	   dngettextt   gettextt   ngettextt   sharet   localec         C   s   |  o | S| Sd S(   sy   
    Implements the C expression:

      condition ? true : false

    Required to correctly interpret plural forms.
    N(    (   t	   conditiont   truet   false(    (    s   /usr/lib/python2.6/gettext.pyt   test=   s    c            s  y d d k  l } Wn# t j
 o d d k l } n Xd d k } d d k } | i | |   i  } yN g  } | D]6 } | d | i j o | d d j o | | qx qx ~ } Wn | i j
 o t	 d  n X| o t	 d  n |  i
 d	 d
  }  |  i
 d d  }  t i d      i d |   }  t i d       f d    d g } x |  D] }	 |	 d j o | i d  qd|	 d j oP t |  d j o t	 d  n   i  | i    }
 | d c d |
 7<qd| d c |	 7<qdW  i  | i    }  t d |   S(   s   Gets a C expression as used in PO files for plural forms and returns a
    Python lambda function that implements an equivalent expression.
    i(   t   StringIONi    i   t   ns;   plural forms expression error, maybe unbalanced parenthesiss*   plural forms expression could be dangerouss   &&s    and s   ||s    or s   \!([^=])s    not \1s   (.*?)\?(.*?):(.*)c            s8   d |  i  d  |  i  d   i   |  i  d   f S(   Ns   test(%s, %s, %s)i   i   i   (   t   groupt   sub(   t   x(   t   replt   expr(    s   /usr/lib/python2.6/gettext.pyR   i   s    t    t   (t   )s%   unbalanced parenthesis in plural forms   (%s)s   lambda n: int(%s)(   t	   cStringIOR   t   ImportErrort   tokent   tokenizet   generate_tokenst   readlinet   NAMEt
   TokenErrort
   ValueErrort   replacet   ret   compileR   t   appendt   lent   popt   eval(   t   pluralR   R   R    t   tokenst   _[1]R   t   dangert   stackt   ct   s(    (   R   R   s   /usr/lib/python2.6/gettext.pyt   c2pyK   s@    N	 c      
   C   s  d d k  l } | |   }  d
 } d } d } d } |  i d  } | d j o" |  | } |  |  }  | | O} n d } |  i d  } | d j o" |  | } |  |  }  | | O} n d } |  i d	  } | d j o" |  | }	 |  |  }  | | O} n d }	 |  }
 g  } x t | d  D]t } | | @pb |
 } | | @o | |	 7} n | | @o | | 7} n | | @o | | 7} n | i |  qqW| i   | S(   Ni(   t	   normalizei   i    i   t   @R   t   .t   _i   i   i   (   R   R5   R   t   rangeR)   t   reverse(   R   R5   t   COMPONENT_CODESETt   COMPONENT_TERRITORYt   COMPONENT_MODIFIERt   maskt   post   modifiert   codesett	   territoryt   languaget   rett   it   val(    (    s   /usr/lib/python2.6/gettext.pyt   _expand_lang   sN    





    
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   sF   h  |  _  d  |  _ d  |  _ d  |  _ | d  j	 o |  i |  n d  S(   N(   t   _infot   Nonet   _charsett   _output_charsett	   _fallbackt   _parse(   t   selft   fp(    (    s   /usr/lib/python2.6/gettext.pyt   __init__   s    				c         C   s   d  S(   N(    (   RN   RO   (    (    s   /usr/lib/python2.6/gettext.pyRM      s    c         C   s+   |  i  o |  i  i |  n
 | |  _  d  S(   N(   RL   t   add_fallback(   RN   t   fallback(    (    s   /usr/lib/python2.6/gettext.pyRQ      s    
c         C   s   |  i  o |  i  i |  S| S(   N(   RL   R   (   RN   t   message(    (    s   /usr/lib/python2.6/gettext.pyR      s    
c         C   s   |  i  o |  i  i |  S| S(   N(   RL   t   lgettext(   RN   RS   (    (    s   /usr/lib/python2.6/gettext.pyRT      s    
c         C   s;   |  i  o |  i  i | | |  S| d j o | S| Sd  S(   Ni   (   RL   R   (   RN   t   msgid1t   msgid2R   (    (    s   /usr/lib/python2.6/gettext.pyR      s
    
c         C   s;   |  i  o |  i  i | | |  S| d j o | S| Sd  S(   Ni   (   RL   t	   lngettext(   RN   RU   RV   R   (    (    s   /usr/lib/python2.6/gettext.pyRW      s
    
c         C   s%   |  i  o |  i  i |  St |  S(   N(   RL   t   ugettextt   unicode(   RN   RS   (    (    s   /usr/lib/python2.6/gettext.pyRX      s    
c         C   sG   |  i  o |  i  i | | |  S| d j o t |  St |  Sd  S(   Ni   (   RL   t	   ungettextRY   (   RN   RU   RV   R   (    (    s   /usr/lib/python2.6/gettext.pyRZ      s
    
c         C   s   |  i  S(   N(   RH   (   RN   (    (    s   /usr/lib/python2.6/gettext.pyt   info   s    c         C   s   |  i  S(   N(   RJ   (   RN   (    (    s   /usr/lib/python2.6/gettext.pyt   charset   s    c         C   s   |  i  S(   N(   RK   (   RN   (    (    s   /usr/lib/python2.6/gettext.pyt   output_charset   s    c         C   s   | |  _  d  S(   N(   RK   (   RN   R\   (    (    s   /usr/lib/python2.6/gettext.pyt   set_output_charset   s    c         C   s   d d  k  } | o
 |  i p |  i | i d <t | d  o d | j o | i d | i d <n d | j o% | o
 |  i p |  i | i d <n d | j o |  i | i d <n d | j o |  i | i d <q n d  S(   NiR8   t   __contains__R   R   RT   RW   (	   t   __builtin__RX   R   t   __dict__t   hasattrRZ   R   RT   RW   (   RN   RY   t   namesR`   (    (    s   /usr/lib/python2.6/gettext.pyR      s    !N(   t   __name__t
   __module__RI   RP   RM   RQ   R   RT   R   RW   RX   RZ   R[   R\   R]   R^   t   FalseR   (    (    (    s   /usr/lib/python2.6/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  i } t | d d  } h  |  _ } d   |  _ | i   } t |  } | d | d   d } | |  i j o, | d | d d ! \ } }	 }
 } d	 } nO | |  i j o, | d
 | d d ! \ } }	 }
 } d } n t	 d d |   xt
 d |	  D]} | | | |
 |
 d ! \ } } | | } | | | | | d ! \ } } | | } | | j  o+ | | j  o | | | !} | | | !} n t	 d d |   | d j o(d } } x| i   D]	} | i   } | p qn d | j oM | i d d  \ } } | i   i   } | i   } | |  i | <| } n# | o |  i | c d | 7<n | d j o | i d  d |  _ q| d j o9 | i d  } | d i d  d } t |  |  _ qqWn d | j o | i d  \ } } | i d  } |  i oC t | |  i  } g  } | D] } | t | |  i  q.~ } n xn t t |   D] } | | | | | f <qgWn= |  i o( t | |  i  } t | |  i  } n | | | <|
 d 7}
 | d 7} q Wd S(   s8   Override this method to support alternative .mo formats.t   nameR   c         S   s   t  |  d  j  S(   i   (   t   int(   R   (    (    s   /usr/lib/python2.6/gettext.pyt   <lambda>  s    s   <Ii   i    s   <4Ii   s   <IIs   >4Is   >IIs   Bad magic numberi   s   File is corruptt   :i   s   
s   content-types   charset=s   plural-formst   ;s   plural=t    N(   t   structt   unpackt   getattrt   _catalogR-   t   readR*   t   LE_MAGICt   BE_MAGICt   IOErrort   xrangeRI   t
   splitlinest   stript   splitt   lowerRH   RJ   R4   RY   R9   (   RN   RO   Rn   t   filenamet   catalogt   buft   buflent   magict   versiont   msgcountt	   masteridxt   transidxt   iiRE   t   mlent   mofft   mendt   tlent   tofft   tendt   msgt   tmsgt   lastkt   kt   itemt   vR-   RU   RV   R/   R   (    (    s   /usr/lib/python2.6/gettext.pyRM     sx    	"
"
  
 

 


1 


c         C   s   t    } |  i i | |  } | | j o  |  i o |  i i |  S| S|  i o | i |  i  S|  i o | i |  i  S| S(   N(   t   objectRp   t   getRL   R   RK   t   encodeRJ   (   RN   RS   t   missingR   (    (    s   /usr/lib/python2.6/gettext.pyR   W  s    	


c         C   sy   t    } |  i i | |  } | | j o  |  i o |  i i |  S| S|  i o | i |  i  S| i t i    S(   N(	   R   Rp   R   RL   RT   RK   R   R   t   getpreferredencoding(   RN   RS   R   R   (    (    s   /usr/lib/python2.6/gettext.pyRT   e  s    	

c         C   s   yZ |  i  | |  i |  f } |  i o | i |  i  S|  i o | i |  i  S| SWnJ t j
 o> |  i o |  i i | | |  S| d j o | S| Sn Xd  S(   Ni   (   Rp   R-   RK   R   RJ   t   KeyErrorRL   R   (   RN   RU   RV   R   R   (    (    s   /usr/lib/python2.6/gettext.pyR   p  s    


c         C   s   yN |  i  | |  i |  f } |  i o | i |  i  S| i t i    SWnJ t j
 o> |  i o |  i i | | |  S| d j o | S| Sn Xd  S(   Ni   (	   Rp   R-   RK   R   R   R   R   RL   RW   (   RN   RU   RV   R   R   (    (    s   /usr/lib/python2.6/gettext.pyRW     s    

c         C   sU   t    } |  i i | |  } | | j o& |  i o |  i i |  St |  S| S(   N(   R   Rp   R   RL   RX   RY   (   RN   RS   R   R   (    (    s   /usr/lib/python2.6/gettext.pyRX     s    	
c         C   s   y  |  i  | |  i |  f } Wn] t j
 oQ |  i o |  i i | | |  S| d j o t |  } q t |  } n X| S(   Ni   (   Rp   R-   R   RL   RZ   RY   (   RN   RU   RV   R   R   (    (    s   /usr/lib/python2.6/gettext.pyRZ     s     
(   Rd   Re   Rr   Rs   RM   R   RT   R   RW   RX   RZ   (    (    (    s   /usr/lib/python2.6/gettext.pyR     s   	Q						i    c         C   s  | d  j o
 t } n | d  j of g  } x; d	 D]3 } t i i |  } | o | i d  } Pq1 q1 Wd | j o | i d  q n g  } xC | D]; } x2 t |  D]$ } | | j o | i |  q q Wq W| o
 g  }	 n d  }	 x | D] } | d j o Pn t i i	 | | d d |   }
 t i i	 d | d d |   } t i i
 |
  o  | o |	 i |
  q}|
 Sn t i i
 |  o  | o |	 i |  q| Sq q W|	 S(
   Nt   LANGUAGEt   LC_ALLt   LC_MESSAGESt   LANGRj   t   Cs   %s.mos   /usr/share/locale-langpack(   R   R   R   R   (   RI   t   _default_localedirt   ost   environR   Rx   R)   RG   t   patht   joint   exists(   t   domaint	   localedirt	   languagest   allt   envarRF   t   nelangst   langt   nelangt   resultt   mofilet	   mofile_lp(    (    s   /usr/lib/python2.6/gettext.pyR     sL    
 	  
 c         C   s  | d  j o
 t } n t |  | | d d } | p% | o t   St t d |    n d  } x | D] } t i i |  }	 t	 i
 |	  }
 |
 d  j o% t	 i |	 | t | d    }
 n t i |
  }
 | o |
 i |  n | d  j o
 |
 } qh | i |
  qh W| S(   NR   i   s$   No translation file found for domaint   rb(   RI   R   R   R   Rt   R    R   R   t   abspatht   _translationsR   t
   setdefaultt   opent   copyR^   RQ   (   R   R   R   t   class_RR   RA   t   mofilesR   R   t   keyt   t(    (    s   /usr/lib/python2.6/gettext.pyR     s*    
 %
c         C   s/   t  |  | d t d | } | i | |  d  S(   NRR   RA   (   R   t   TrueR   (   R   R   RY   RA   Rc   R   (    (    s   /usr/lib/python2.6/gettext.pyR     s    t   messagesc         C   s   |  d  j	 o
 |  a n t S(   N(   RI   t   _current_domain(   R   (    (    s   /usr/lib/python2.6/gettext.pyR   	  s    
c         C   s+   | d  j	 o | t |  <n t i |  t  S(   N(   RI   t   _localedirsR   R   (   R   R   (    (    s   /usr/lib/python2.6/gettext.pyR     s    c         C   s(   | d  j	 o | t |  <n t i |   S(   N(   RI   t   _localecodesetsR   (   R   RA   (    (    s   /usr/lib/python2.6/gettext.pyt   bind_textdomain_codeset  s    c      	   C   sR   y. t  |  t i |  d   d t i |   } Wn t j
 o | SX| i |  S(   NRA   (   R   R   R   RI   R   Rt   R   (   R   RS   R   (    (    s   /usr/lib/python2.6/gettext.pyR	     s    c      	   C   sR   y. t  |  t i |  d   d t i |   } Wn t j
 o | SX| i |  S(   NRA   (   R   R   R   RI   R   Rt   RT   (   R   RS   R   (    (    s   /usr/lib/python2.6/gettext.pyt	   ldgettext&  s    c      	   C   sm   y. t  |  t i |  d   d t i |   } Wn) t j
 o | d j o | S| Sn X| i | | |  S(   NRA   i   (   R   R   R   RI   R   Rt   R   (   R   RU   RV   R   R   (    (    s   /usr/lib/python2.6/gettext.pyR
   .  s    	c      	   C   sm   y. t  |  t i |  d   d t i |   } Wn) t j
 o | d j o | S| Sn X| i | | |  S(   NRA   i   (   R   R   R   RI   R   Rt   RW   (   R   RU   RV   R   R   (    (    s   /usr/lib/python2.6/gettext.pyt
   ldngettext9  s    	c         C   s   t  t |   S(   N(   R	   R   (   RS   (    (    s   /usr/lib/python2.6/gettext.pyR   D  s    c         C   s   t  t |   S(   N(   R   R   (   RS   (    (    s   /usr/lib/python2.6/gettext.pyRT   G  s    c         C   s   t  t |  | |  S(   N(   R
   R   (   RU   RV   R   (    (    s   /usr/lib/python2.6/gettext.pyR   J  s    c         C   s   t  t |  | |  S(   N(   R   R   (   RU   RV   R   (    (    s   /usr/lib/python2.6/gettext.pyRW   M  s    (    ((   t   __doc__R   R   R   R'   Rm   t   syst   errnoR    t   __all__R   R   t   prefixR   R   R4   RG   R   R   RI   R   R   Rf   R   R   R   R   R   R   R   R   R	   R   R
   R   R   RT   R   RW   R   (    (    (    s   /usr/lib/python2.6/gettext.pyt   <module>   s>   &H			7	+T5								