From 8abf984f02e3220a02b0f0865b8d551bc4aaceea Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Thu, 31 May 2007 17:07:49 +0000 Subject: [PATCH] Recognize python-format messages also for unnamed parameters. --- babel/catalog/pofile.py | 2 +- babel/catalog/tests/pofile.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) 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__': -- 2.47.2