diff options
author | Laurent DAVERIO <laurent@daverio.net> | 2015-05-04 21:13:20 +0200 |
---|---|---|
committer | Laurent DAVERIO <laurent@daverio.net> | 2015-05-04 21:13:20 +0200 |
commit | 8febe540b571f45b23884a27ed9d149f2de2a31d (patch) | |
tree | 6a1d8efea16016f727739852a3ffc0b13b554dfa | |
parent | f9695e395f8ff6e6d9d04ba75f72380ae959ed5b (diff) | |
download | external_python_mako-8febe540b571f45b23884a27ed9d149f2de2a31d.tar.gz external_python_mako-8febe540b571f45b23884a27ed9d149f2de2a31d.tar.bz2 external_python_mako-8febe540b571f45b23884a27ed9d149f2de2a31d.zip |
Added some cleanup to the section of the Lingua extractor handling compound statements:
- try, except and else are replaced with '' (i.e. ignored)
- elif is replaced with if
-rw-r--r-- | mako/ext/linguaplugin.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/mako/ext/linguaplugin.py b/mako/ext/linguaplugin.py index 09ef560..8126df3 100644 --- a/mako/ext/linguaplugin.py +++ b/mako/ext/linguaplugin.py @@ -26,14 +26,11 @@ 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" + if source in ('try:', 'else:') or source.startswith('except'): + source = compat.b('') # Ignore try/except and else elif source.startswith('elif'): source = source[2:] # Replace "elif" with "if" - if source == 'try:' or source.startswith('except'): - source = compat.b('') # Ignore "try/except" altogether - else: - source += compat.b(' pass') + source += compat.b('pass') code = io.BytesIO(source) for msg in self.python_extractor( self.filename, self.options, code, code_lineno -1): |