# -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. import logging import os import mako from mako.lookup import TemplateLookup from mako.template import Template from lxml import etree _logger = logging.getLogger(__name__) class makohtml2html(object): def __init__(self, html, localcontext): self.localcontext = localcontext self.html = html def format_header(self, html): head = html.findall('head') header = '' for node in head: header += etree.tostring(node) return header def format_footer(self, footer): html_footer = '' for node in footer[0].getchildren(): html_footer += etree.tostring(node) return html_footer def format_body(self, html): body = html.findall('body') body_list = [] footer = self.format_footer(body[-1].getchildren()) for b in body[:-1]: body_list.append(etree.tostring(b).replace('\t', '').replace('\n','')) html_body ='''