diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-12-23 22:49:38 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-12-23 22:49:38 (GMT) |
commit | a91dd1e411c405ec3b5eba9a9e917c43f9f20223 (patch) | |
tree | 148d16da82870b25883a541cc16611c963884eb3 /Lib/gettext.py | |
parent | 5793e6f4b02b3c377906c639e5d5412f942837d4 (diff) | |
download | cpython-a91dd1e411c405ec3b5eba9a9e917c43f9f20223.zip cpython-a91dd1e411c405ec3b5eba9a9e917c43f9f20223.tar.gz cpython-a91dd1e411c405ec3b5eba9a9e917c43f9f20223.tar.bz2 |
use native tenary condition
Diffstat (limited to 'Lib/gettext.py')
-rw-r--r-- | Lib/gettext.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/Lib/gettext.py b/Lib/gettext.py index f9392d8..0ad3bae 100644 --- a/Lib/gettext.py +++ b/Lib/gettext.py @@ -58,20 +58,6 @@ __all__ = ['NullTranslations', 'GNUTranslations', 'Catalog', _default_localedir = os.path.join(sys.prefix, 'share', 'locale') -def test(condition, true, false): - """ - Implements the C expression: - - condition ? true : false - - Required to correctly interpret plural forms. - """ - if condition: - return true - else: - return false - - def c2py(plural): """Gets a C expression as used in PO files for plural forms and returns a Python lambda function that implements an equivalent expression. @@ -99,8 +85,8 @@ def c2py(plural): # "a?b:c" to "test(a,b,c)". expr = re.compile(r'(.*?)\?(.*?):(.*)') def repl(x): - return "test(%s, %s, %s)" % (x.group(1), x.group(2), - expr.sub(repl, x.group(3))) + return "(%s if %s else %s)" % (x.group(2), x.group(1), + expr.sub(repl, x.group(3))) # Code to transform the plural expression, taking care of parentheses stack = [''] |