D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
lib
/
python2.7
/
site-packages
/
babel
/
messages
/
Filename :
pofile.pyo
back
Copy
� H��Xc @ s d Z d d l m Z d d l Z d d l Z d d l m Z m Z d d l m Z d d l m Z d � Z d � Z d e f d � � YZ d e f d � � YZ d d e d d � Z e j d � Z d � Z d d d � Z d e e e e e e e d � Z d � Z d S( s� babel.messages.pofile ~~~~~~~~~~~~~~~~~~~~~ Reading and writing of files in the ``gettext`` PO (portable object) format. :copyright: (c) 2013 by the Babel Team. :license: BSD, see LICENSE for more details. i����( t print_functionN( t Catalogt Message( t wraptext( t text_typec C s) d � } t j d � j | | d d !� S( s� Reverse `escape` the given string. >>> print(unescape('"Say:\\n \\"hello, world!\\"\\n"')) Say: "hello, world!" <BLANKLINE> :param string: the string to unescape c S sC | j d � } | d k r d S| d k r/ d S| d k r? d S| S( Ni t ns t ts t rs ( t group( t matcht m( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyt replace_escapes s s \\([\\trn"])i i����( t ret compilet sub( t stringR ( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyt unescape s c C s^ d | k rP | j � } | j d � r4 | d } n t t | � } d j | � St | � Sd S( s� Reverse the normalization done by the `normalize` function. >>> print(denormalize(r'''"" ... "Say:\n" ... " \"hello, world!\"\n"''')) Say: "hello, world!" <BLANKLINE> >>> print(denormalize(r'''"" ... "Say:\n" ... " \"Lorem ipsum dolor sit " ... "amet, consectetur adipisicing" ... " elit, \"\n"''')) Say: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " <BLANKLINE> :param string: the string to denormalize s s ""i t N( t splitlinest startswitht mapR t join( R t escaped_linest lines( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyt denormalize- s t _NormalizedStringc B s, e Z d � Z d � Z d � Z d � Z RS( c G s+ g | _ x | D] } | j | � q Wd S( N( t _strst append( t selft argst arg( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyt __init__N s c C s | j j | j � � d S( N( R R t strip( R t s( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyR S s c C s d j t t | j � � S( NR ( R R R R ( R ( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyR V s c C s t | j � S( N( t boolR ( R ( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyt __nonzero__Y s ( t __name__t __module__R R R R# ( ( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyR L s t PoFileParserc B s� e Z d Z d d d d g Z e d � Z d � Z d � Z d � Z e d � Z e d � Z d � Z d � Z d � Z d � Z RS( s� Support class to read messages from a ``gettext`` PO (portable object) file and add them to a `Catalog` See `read_po` for simple cases. t msgidt msgstrt msgctxtt msgid_pluralc C s2 | | _ | | _ d | _ d | _ | j � d S( Ni ( t catalogt ignore_obsoletet countert offsett _reset_message_state( R R+ R, ( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyR k s c C sg g | _ g | _ g | _ g | _ g | _ g | _ d | _ t | _ t | _ t | _ t | _ d S( N( t messagest translationst locationst flagst user_commentst auto_commentst Nonet contextt Falset obsoletet in_msgidt in_msgstrt in_msgctxt( R ( ( s9 /usr/lib/python2.7/site-packages/babel/messages/pofile.pyR/ r s c C s� | j j � t | j � d k rM t g | j D] } | j � ^ q/ � } n | j d j � } t | t t f � rg t | j j � D] } d ^ q� } xU | j D]J \ } } | | j j k r� | j d | j d � q� n | j � | | <q� Wt | � } n | j d d j � } | j r3| j j � } n d } t | | t | j � t | j � | j | j d | j d d | �} | j r�| j s�| | j j | <q�n | | j | <| j d 7_ | j � d S( s� Add a message to the catalog based on the current parser state and clear the state ready to process the next message. i i R s5 msg has more translations than num_plurals of catalogt linenoR7 N( R1 t sortt lenR0 t tupleR t isinstancet listt rangeR+ t num_pluralst _invalid_pofileR. R7 R6 R R2 t setR3 R5 R4 R9 R, R- R/ ( R R R'