Mercurial > repos > pieterlukasse > nist_wrapper
view report_generator.py @ 10:bde3e4dc4476
fix
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 23 Jan 2015 09:42:18 +0100 |
parents | cce6989ed423 |
children |
line wrap: on
line source
''' Created on Nov 14, 2014 @author: linda ''' import jinja2 import sys reload(sys) sys.setdefaultencoding("utf-8") class ReportGenerator(object): def __init__(self, templatedir, templatename, hits_dict, spectra_dict): self.templatename = templatename self.hits_dict = hits_dict self.spectra_dict = spectra_dict self.loader = jinja2.FileSystemLoader(searchpath=templatedir) self.environment = jinja2.Environment(loader=self.loader, lstrip_blocks=True, trim_blocks=True, autoescape=True, extensions=['jinja2.ext.autoescape']) def render(self, output): template = self.environment.get_template(self.templatename) result = template.stream(hits_dict=self.hits_dict, spectra_dict=self.spectra_dict) result.dump(output)