From: Christopher Lenz Date: Thu, 31 May 2007 17:07:49 +0000 (+0000) Subject: Recognize python-format messages also for unnamed parameters. X-Git-Tag: 1.0~612 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8abf984f02e3220a02b0f0865b8d551bc4aaceea;p=thirdparty%2Fbabel.git Recognize python-format messages also for unnamed parameters. --- diff --git a/babel/catalog/pofile.py b/babel/catalog/pofile.py index 966ddaf6..0a05fa28 100644 --- a/babel/catalog/pofile.py +++ b/babel/catalog/pofile.py @@ -51,7 +51,7 @@ msgstr "" """ % VERSION -PYTHON_FORMAT = re.compile(r'(\%\(([\w]+)\)[diouxXeEfFgGcrs])').search +PYTHON_FORMAT = re.compile(r'\%(\([\w]+\))?[diouxXeEfFgGcrs]').search def escape(string): r"""Escape the given string so that it can be included in double-quoted diff --git a/babel/catalog/tests/pofile.py b/babel/catalog/tests/pofile.py index 7152df3a..b0f08e77 100644 --- a/babel/catalog/tests/pofile.py +++ b/babel/catalog/tests/pofile.py @@ -16,9 +16,19 @@ import unittest from babel.catalog import pofile + +class PythonFormatFlagUnitTest(unittest.TestCase): + + def test_without_name(self): + assert pofile.PYTHON_FORMAT('foo %d bar') + assert pofile.PYTHON_FORMAT('foo %s bar') + assert pofile.PYTHON_FORMAT('foo %r bar') + + def suite(): suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite(pofile)) + suite.addTest(unittest.makeSuite(PythonFormatFlagUnitTest)) return suite if __name__ == '__main__':