Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def render(cls, report, report_context):
"calls the underlying templating engine to renders the report"
fd, path = cls._prepare_template_file(report)
mimetype = MIMETYPES[report.template_extension]
rel_report = relatorio.reporting.Report(path, mimetype,
ReportFactory(), relatorio.reporting.MIMETemplateLoader())
if report.translatable:
cls._add_translation_hook(rel_report, report_context)
else:
report_context['set_lang'] = lambda language: None
data = rel_report(**report_context).render()
if hasattr(data, 'getvalue'):
data = data.getvalue()
os.close(fd)
os.remove(path)
return data