%PDF- %PDF-
Direktori : /proc/self/root/opt/alt/python27/lib/python2.7/site-packages/babel/messages/ |
Current File : //proc/self/root/opt/alt/python27/lib/python2.7/site-packages/babel/messages/pofile.pyc |
� ��Qc @ s� d 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 d e d d � Z e j d � Z d � Z d d d � Z d e e e e e e 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����N( 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( ( sF /opt/alt/python27/lib/python2.7/site-packages/babel/messages/pofile.pyt replace_escapes s s \\([\\trn"])i i����( t ret compilet sub( t stringR ( ( sF /opt/alt/python27/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( ( sF /opt/alt/python27/lib/python2.7/site-packages/babel/messages/pofile.pyt denormalize, s c s6 t d | d | d | � � d g � d g � g � g � g � g � g � g � t g � g � t g � t g � t g � � � � � � � � � � � � � f d � � � � � � � � � � f d � } x t | j � � D]�\ } } | j � } t | t � s| j � j � } n | j d � r�t � d <� d <� rU� rU� � n | d j d � r�x\| d j � j � D]j } | j d � } | d k ry t | | d � } Wn t k r�qn X� j | | | f � qqWq�| d j d � r=x� | d j � j d � D] } � j | j � � qWq�| d j d � rtt � d <| | | d j � � q�| d j d � r�| d j � } | r�� j | � q�q�� j | d j � � q� | | | � q� W� r�� � nG � d r2� s� s� r2� j d � � j d d g � � � n � S( sJ Read messages from a ``gettext`` PO (portable object) file from the given file-like object and return a `Catalog`. >>> from datetime import datetime >>> from StringIO import StringIO >>> buf = StringIO(''' ... #: main.py:1 ... #, fuzzy, python-format ... msgid "foo %(name)s" ... msgstr "quux %(name)s" ... ... # A user comment ... #. An auto comment ... #: main.py:3 ... msgid "bar" ... msgid_plural "baz" ... msgstr[0] "bar" ... msgstr[1] "baaz" ... ''') >>> catalog = read_po(buf) >>> catalog.revision_date = datetime(2007, 04, 01) >>> for message in catalog: ... if message.id: ... print (message.id, message.string) ... print ' ', (message.locations, message.flags) ... print ' ', (message.user_comments, message.auto_comments) (u'foo %(name)s', u'quux %(name)s') ([(u'main.py', 1)], set([u'fuzzy', u'python-format'])) ([], []) ((u'bar', u'baz'), (u'bar', u'baaz')) ([(u'main.py', 3)], set([])) ([u'A user comment'], [u'An auto comment']) .. versionadded:: 1.0 Added support for explicit charset argument. :param fileobj: the file-like object to read the PO file from :param locale: the locale identifier or `Locale` object, or `None` if the catalog is not bound to a locale (which basically means it's a template) :param domain: the message domain :param ignore_obsolete: whether to ignore obsolete messages in the input :param charset: the character set of the catalog. t localet domaint charseti c s� � j � t � � d k rD t g � D] } t | � ^ q&