/usr/lib/python2.6/site-packages/babel/messages
Edit: /usr/lib/python2.6/site-packages/babel/messages/pofile.pyc (14569B)
Ñò
zDVc
@ sÄ d Z d d k Z d d k Z d d k l Z l Z d d k l Z d d k l Z d „ Z
d „ Z d d e
d d „ Z e i 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 i d ƒ i | | d d !ƒ S( s¾ Reverse `escape` the given string.
>>> print unescape('"Say:\\n \\"hello, world!\\"\\n"')
Say:
"hello, world!"
:param string: the string to unescape
c S sI | i d ƒ } | d j o d S| d j o d S| d j o d S| S( Ni t ns
t ts t rs
( t group( t matcht m( ( s4 /tmp/pip-build-lt8jXN/Babel/babel/messages/pofile.pyt replace_escapes s
s \\([\\trn"])i iÿÿÿÿ( t ret compilet sub( t stringR
( ( s4 /tmp/pip-build-lt8jXN/Babel/babel/messages/pofile.pyt unescape s
c C sb d | j oG | i ƒ } | i d ƒ o | d } n t t | ƒ } d i | ƒ St | ƒ Sd S( sê Reverse the normalization done by the `normalize` function.
>>> print denormalize(r'''""
... "Say:\n"
... " \"hello, world!\"\n"''')
Say:
"hello, world!"
>>> print denormalize(r'''""
... "Say:\n"
... " \"Lorem ipsum dolor sit "
... "amet, consectetur adipisicing"
... " elit, \"\n"''')
Say:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
:param string: the string to denormalize
s
s ""i t N( t
splitlinest
startswitht mapR t join( R t
escaped_linest lines( ( s4 /tmp/pip-build-lt8jXN/Babel/babel/messages/pofile.pyt denormalize, s
c sR 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 † } xt | i ƒ ƒ D]
\ } } | i ƒ } t | t ƒ p | i ˆ i ƒ } n | i d ƒ o¯t ˆ d <ˆ d <ˆ o ˆ o ˆ ƒ n | d i d ƒ o xi| d
i
ƒ i ƒ D]n } | i d ƒ } | d j oL y t
| | d ƒ } Wn t j
o
q†n Xˆ i | | | f ƒ q†q†Wqì| d i d ƒ o; xÈ | d
i
ƒ i d ƒ D] }
ˆ i |
i ƒ ƒ q*Wqì| d i d ƒ o% t ˆ d <| | | d
i
ƒ ƒ qì| d i d
ƒ o, | d
i ƒ } | o ˆ i | ƒ qÛqìˆ i | d i ƒ ƒ qâ | | | ƒ qâ Wˆ o ˆ ƒ nM ˆ
d o@ ˆ p ˆ p ˆ o+ ˆ i d ƒ ˆ i 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ç ˆ i ƒ t ˆ ƒ d j o1 t g } ˆ D] } | t | ƒ q+ ~ ƒ } n t ˆ d ƒ } t | t t f ƒ o“ g } xU t ˆ i ƒ D]D } y | i ˆ | ƒ WqŠ t j
o | i | d f ƒ qŠ XqŠ Wt g } | D] } | t | d ƒ qà ~ ƒ } n t ˆ d d ƒ } ˆ
o t d i
ˆ
ƒ ƒ } n d } t | | t ˆ ƒ t
ˆ ƒ ˆ ˆ d ˆ d d d | ƒ} ˆ d o ˆ p | ˆ i |