Mercurial > babel > mirror
comparison babel/messages/pofile.py @ 586:46410022772a trunk
fix doctests on Python 2.4: In 2.4 re.sub(..., ..., u'') will return '' (str, not unicode) so just fill in some msgstr to avoid that problem
author | fschwarz |
---|---|
date | Mon, 06 Aug 2012 07:41:21 +0000 |
parents | 5c9dba5dd311 |
children |
comparison
equal
deleted
inserted
replaced
585:5c9dba5dd311 | 586:46410022772a |
---|---|
91 >>> from StringIO import StringIO | 91 >>> from StringIO import StringIO |
92 >>> buf = StringIO(''' | 92 >>> buf = StringIO(''' |
93 ... #: main.py:1 | 93 ... #: main.py:1 |
94 ... #, fuzzy, python-format | 94 ... #, fuzzy, python-format |
95 ... msgid "foo %(name)s" | 95 ... msgid "foo %(name)s" |
96 ... msgstr "" | 96 ... msgstr "quux %(name)s" |
97 ... | 97 ... |
98 ... # A user comment | 98 ... # A user comment |
99 ... #. An auto comment | 99 ... #. An auto comment |
100 ... #: main.py:3 | 100 ... #: main.py:3 |
101 ... msgid "bar" | 101 ... msgid "bar" |
102 ... msgid_plural "baz" | 102 ... msgid_plural "baz" |
103 ... msgstr[0] "" | 103 ... msgstr[0] "bar" |
104 ... msgstr[1] "" | 104 ... msgstr[1] "baaz" |
105 ... ''') | 105 ... ''') |
106 >>> catalog = read_po(buf) | 106 >>> catalog = read_po(buf) |
107 >>> catalog.revision_date = datetime(2007, 04, 01) | 107 >>> catalog.revision_date = datetime(2007, 04, 01) |
108 | 108 |
109 >>> for message in catalog: | 109 >>> for message in catalog: |
110 ... if message.id: | 110 ... if message.id: |
111 ... print (message.id, message.string) | 111 ... print (message.id, message.string) |
112 ... print ' ', (message.locations, message.flags) | 112 ... print ' ', (message.locations, message.flags) |
113 ... print ' ', (message.user_comments, message.auto_comments) | 113 ... print ' ', (message.user_comments, message.auto_comments) |
114 (u'foo %(name)s', u'') | 114 (u'foo %(name)s', u'quux %(name)s') |
115 ([(u'main.py', 1)], set([u'fuzzy', u'python-format'])) | 115 ([(u'main.py', 1)], set([u'fuzzy', u'python-format'])) |
116 ([], []) | 116 ([], []) |
117 ((u'bar', u'baz'), (u'', u'')) | 117 ((u'bar', u'baz'), (u'bar', u'baaz')) |
118 ([(u'main.py', 3)], set([])) | 118 ([(u'main.py', 3)], set([])) |
119 ([u'A user comment'], [u'An auto comment']) | 119 ([u'A user comment'], [u'An auto comment']) |
120 | 120 |
121 :param fileobj: the file-like object to read the PO file from | 121 :param fileobj: the file-like object to read the PO file from |
122 :param locale: the locale identifier or `Locale` object, or `None` | 122 :param locale: the locale identifier or `Locale` object, or `None` |