|
@ -186,32 +186,27 @@ class TexRenderer(object): |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
subvariables = {} |
|
|
subvariables = {} |
|
|
template_file = None |
|
|
|
|
|
templatename = self.texenv.get_template(template).filename |
|
|
templatename = self.texenv.get_template(template).filename |
|
|
try: |
|
|
with encoding.open_read(templatename, 'r') as template_file: |
|
|
template_file = encoding.open_read(templatename, 'r') |
|
|
|
|
|
content = template_file.read() |
|
|
content = template_file.read() |
|
|
subtemplates = list(find_templates(self.texenv.parse(content))) |
|
|
subtemplates = list(find_templates(self.texenv.parse(content))) |
|
|
match = re.findall(_VARIABLE_REGEXP, content) |
|
|
match = re.findall(_VARIABLE_REGEXP, content) |
|
|
if match: |
|
|
if match: |
|
|
for var in match: |
|
|
for var in match: |
|
|
try: |
|
|
try: |
|
|
subvariables.update(json.loads(var)) |
|
|
subvariables.update(json.loads(var)) |
|
|
except ValueError as exception: |
|
|
except ValueError as exception: |
|
|
raise errors.TemplateError( |
|
|
raise errors.TemplateError( |
|
|
exception, |
|
|
exception, |
|
|
( |
|
|
( |
|
|
"Error while parsing json in file " |
|
|
"Error while parsing json in file " |
|
|
"{filename}. The json string was:" |
|
|
"{filename}. The json string was:" |
|
|
"\n'''\n{jsonstring}\n'''" |
|
|
"\n'''\n{jsonstring}\n'''" |
|
|
).format( |
|
|
).format( |
|
|
filename=templatename, |
|
|
filename=templatename, |
|
|
jsonstring=var, |
|
|
jsonstring=var, |
|
|
) |
|
|
|
|
|
) |
|
|
) |
|
|
finally: |
|
|
) |
|
|
if template_file: |
|
|
|
|
|
template_file.close() |
|
|
|
|
|
|
|
|
|
|
|
return (subvariables, subtemplates) |
|
|
return (subvariables, subtemplates) |
|
|
|
|
|
|
|
|