creole_legacy and creole have differents compilers
This commit is contained in:
parent
5c526cf2b4
commit
9de06705e8
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,6 +1,4 @@
|
||||
#attr
|
||||
leader: a
|
||||
follower2:
|
||||
#key
|
||||
leader: a
|
||||
follower2:
|
||||
|
Loading…
Reference in New Issue
Block a user