Commit f84deb81 by dorp

added generic template as fallback

parent 1baed6ba
......@@ -13,6 +13,8 @@ from jinja_filters.filter import (
)
from rest_import.rest import create_request_url, request_firmware_data
GENERIC_TEMPLATE = 'generic.tex'
def _set_jinja_env(templates_to_use='default'):
template_directory = Path(Path(__file__).parent.parent, 'templates', templates_to_use)
......@@ -54,11 +56,18 @@ def generate_main_code(firmware_analyses, firmware_meta_data, jinja_environment)
def generate_analysis_codes(environment, analysis):
return [('{}.tex'.format(analysis_plugin), _render_analysis_result(analysis[analysis_plugin], environment, analysis_plugin)) for analysis_plugin in analysis]
return [
('{}.tex'.format(analysis_plugin), _render_analysis_result(analysis[analysis_plugin], environment, analysis_plugin)) for analysis_plugin in analysis
]
def _render_analysis_result(analysis, environment, analysis_plugin):
template = environment.get_template('{}.tex'.format(analysis_plugin))
try:
template = environment.get_template('{}.tex'.format(analysis_plugin))
except jinja2.TemplateNotFound:
logging.debug('Falling back on generic template for {}'.format(analysis_plugin))
template = environment.get_template(GENERIC_TEMPLATE)
return template.render(selected_analysis=analysis)
......
import json
import requests
......
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
\begin{longtable}{|p{3cm}|p{11.5cm}|}
\hline
Time of Analysis & \VAR{selected_analysis['analysis_date'] | nice_unix_time} \\
\hline
Plugin Version & \VAR{selected_analysis['plugin_version']} \\
\hline
\BLOCK{if selected_analysis['summary']}
Summary
\BLOCK{for selected_summary in selected_analysis['summary']}
& \VAR{selected_summary | filter_chars} \\
\BLOCK{endfor}
\hline
\BLOCK{endif}
\end{longtable}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment