changeset 394:afa3582f7e1f

Fixed not in plural rules
author aronacher
date Tue, 15 Jul 2008 10:13:55 +0000
parents dd0df1242ae3
children 98f06b9c44a7
files babel/plural.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/babel/plural.py
+++ b/babel/plural.py
@@ -363,6 +363,11 @@
     return lambda self, l, r: tmpl % (self.compile(l), self.compile(r))
 
 
+def _unary_compiler(tmpl):
+    """Compiler factory for the `_Compiler`."""
+    return lambda self, x: tmpl % self.compile(x)
+
+
 class _Compiler(object):
     """The compilers are able to transform the expressions into multiple
     output formats.
@@ -375,7 +380,7 @@
     compile_value = lambda x, v: str(v)
     compile_and = _binary_compiler('(%s && %s)')
     compile_or = _binary_compiler('(%s || %s)')
-    compile_not = _binary_compiler('(!%s)')
+    compile_not = _unary_compiler('(!%s)')
     compile_mod = _binary_compiler('(%s %% %s)')
     compile_is = _binary_compiler('(%s == %s)')
     compile_isnot = _binary_compiler('(%s != %s)')
@@ -390,7 +395,7 @@
 
     compile_and = _binary_compiler('(%s and %s)')
     compile_or = _binary_compiler('(%s or %s)')
-    compile_not = _binary_compiler('(not %s)')
+    compile_not = _unary_compiler('(not %s)')
     compile_mod = _binary_compiler('MOD(%s, %s)')
 
 
Copyright (C) 2012-2017 Edgewall Software