From 9de06705e8bd302753e2750f37c16bed2d3260df Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 5 Mar 2022 11:16:58 +0100 Subject: [PATCH] creole_legacy and creole have differents compilers --- src/rougail/template/engine/creole.py | 12 ++++++------ src/rougail/template/engine/creole_legacy.py | 6 +++++- .../40ifin_leadershipauto/result/etc/mailname | 2 -- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/rougail/template/engine/creole.py b/src/rougail/template/engine/creole.py index fac4fa70c..61171a1b6 100644 --- a/src/rougail/template/engine/creole.py +++ b/src/rougail/template/engine/creole.py @@ -38,12 +38,12 @@ from ...error import TemplateError def cl_compile(kls, *args, **kwargs): """Rewrite compile methode to force some settings """ - kwargs['compilerSettings'] = {'directiveStartToken' : '%', - 'cheetahVarStartToken' : '%%', - 'EOLSlurpToken' : '%', - 'commentStartToken' : '#', - 'multiLineCommentStartToken' : '#*', - 'multiLineCommentEndToken' : '*#', + kwargs['compilerSettings'] = {'directiveStartToken': '%', + 'cheetahVarStartToken': '%%', + 'EOLSlurpToken': '%', + 'commentStartToken': '#', + 'multiLineCommentStartToken': '#*', + 'multiLineCommentEndToken': '*#', } return kls.old_compile(*args, **kwargs) # pylint: disable=E1101 Template.old_compile = Template.compile diff --git a/src/rougail/template/engine/creole_legacy.py b/src/rougail/template/engine/creole_legacy.py index 6afd30667..fa042959c 100644 --- a/src/rougail/template/engine/creole_legacy.py +++ b/src/rougail/template/engine/creole_legacy.py @@ -49,7 +49,6 @@ def cl_compile(kls, *args, **kwargs): 'multiLineCommentStartToken' : u'µ' * 10, 'multiLineCommentEndToken' : u'µ' * 10} return kls.old_compile(*args, **kwargs) # pylint: disable=E1101 -oriCheetahTemplate.compile = cl_compile class IsDefined: @@ -126,6 +125,8 @@ def process(filename: str, """Process a cheetah template """ # full path of the destination file + ori_compile = oriCheetahTemplate.compile + oriCheetahTemplate.compile = cl_compile try: extra_context = {'normalize_family': normalize_family, 'rougail_filename': true_destfilename, @@ -148,13 +149,16 @@ def process(filename: str, msg = f"Error: unknown variable used in template {filename} to {destfilename}: {varname}" else: msg = f"Error: unknown variable used in file {destfilename}: {varname}" + oriCheetahTemplate.compile = ori_compile raise TemplateError(_(msg)) from err except Exception as err: # pragma: no cover if filename: msg = _(f"Error while instantiating template {filename} to {destfilename}: {err}") else: msg = _(f"Error while instantiating filename {destfilename}: {err}") + oriCheetahTemplate.compile = ori_compile raise TemplateError(msg) from err with open(destfilename, 'w') as file_h: file_h.write(data) + oriCheetahTemplate.compile = ori_compile diff --git a/tests/dictionaries/40ifin_leadershipauto/result/etc/mailname b/tests/dictionaries/40ifin_leadershipauto/result/etc/mailname index 6da0a4c21..614ffd2da 100644 --- a/tests/dictionaries/40ifin_leadershipauto/result/etc/mailname +++ b/tests/dictionaries/40ifin_leadershipauto/result/etc/mailname @@ -1,6 +1,4 @@ -#attr leader: a follower2: -#key leader: a follower2: