aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent DAVERIO <laurent@daverio.net>2015-05-01 18:18:17 +0200
committerLaurent DAVERIO <laurent@daverio.net>2015-05-01 18:18:17 +0200
commitf9c2dd493a46e8093c97d17881d0305661d5dbfd (patch)
tree39d3840fa30a96441172a425f6648d729a652b55
parentf07e53dc08dcd8ed4a991539185c3e983413de06 (diff)
downloadexternal_python_mako-f9c2dd493a46e8093c97d17881d0305661d5dbfd.tar.gz
external_python_mako-f9c2dd493a46e8093c97d17881d0305661d5dbfd.tar.bz2
external_python_mako-f9c2dd493a46e8093c97d17881d0305661d5dbfd.zip
Continued partial statements (else, elif, ...) cannot be handled directly by the Python extractor, they need to be transformed first.
-rw-r--r--mako/ext/linguaplugin.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/mako/ext/linguaplugin.py b/mako/ext/linguaplugin.py
index 27a1984..0e2065e 100644
--- a/mako/ext/linguaplugin.py
+++ b/mako/ext/linguaplugin.py
@@ -26,6 +26,10 @@ class LinguaMakoExtractor(Extractor, MessageExtractor):
def process_python(self, code, code_lineno, translator_strings):
source = code.getvalue().strip()
if source.endswith(compat.b(':')):
+ if source == 'else:':
+ source = compat.b('if 1:') # Replace "else" with "if 1"
+ elif source.startswith('elif'):
+ source = source[2:] # Replace "elif" with "if"
source += compat.b(' pass')
code = io.BytesIO(source)
for msg in self.python_extractor(