diff --git a/src/rougail/template/engine/creole.py b/src/rougail/template/engine/creole.py index fac4fa70..61171a1b 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 6afd3066..fa042959 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 6da0a4c2..614ffd2d 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: