diff options
| author | dsh (Open ERP) <dsh@tinyerp.com> | 2009-05-05 17:12:27 +0530 |
|---|---|---|
| committer | dsh (Open ERP) <dsh@tinyerp.com> | 2009-05-05 17:12:27 +0530 |
| commit | 5c828843a9edd501ca4c80499f15f1ec02263c2a (patch) | |
| tree | 1d8034df2bcec6b578bc7b9302136e2befe55028 /bin/report/render | |
| parent | 3d818a0f1a6e16f44dee3555c6eec4379e0a976d (diff) | |
changes in report engine for html2html
bzr revid: dsh@tinyerp.com-20090505114227-mp9ndr3rkbkycfl7
Diffstat (limited to 'bin/report/render')
| -rw-r--r-- | bin/report/render/__init__.py | 3 | ||||
| -rw-r--r-- | bin/report/render/html2html/__init__.py | 26 | ||||
| -rw-r--r-- | bin/report/render/html2html/html2html.py | 62 | ||||
| -rw-r--r-- | bin/report/render/rml.py | 11 |
4 files changed, 100 insertions, 2 deletions
diff --git a/bin/report/render/__init__.py b/bin/report/render/__init__.py index ebfa37bfa27..819fa0c1546 100644 --- a/bin/report/render/__init__.py +++ b/bin/report/render/__init__.py @@ -21,8 +21,7 @@ ############################################################################## from simple import simple -from rml import rml, rml2html, odt2odt - +from rml import rml, rml2html, odt2odt , html2html from render import render try: diff --git a/bin/report/render/html2html/__init__.py b/bin/report/render/html2html/__init__.py new file mode 100644 index 00000000000..16385ae50a0 --- /dev/null +++ b/bin/report/render/html2html/__init__.py @@ -0,0 +1,26 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from html2html import parseString + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py new file mode 100644 index 00000000000..7894dd78516 --- /dev/null +++ b/bin/report/render/html2html/html2html.py @@ -0,0 +1,62 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from report.render.rml2pdf import utils +from lxml import etree +import copy +import pooler + + +class html2html(object): + def __init__(self, html, localcontext): + self.localcontext = localcontext + self.etree = html + self._node = None + + + def render(self): + def process_text(node,new_node): + if new_node.tag in ['story','tr','section']: + new_node.attrib.clear() + for child in utils._child_get(node, self): + new_child = copy.deepcopy(child) + new_node.append(new_child) + if len(child): + for n in new_child: + new_child.remove(n) + process_text(child, new_child) + else: + if new_child.tag=='img' and new_child.get('name'): + src = utils._process_text(self, new_child.get('name')) + if src : + new_child.set('src','data:image/gif;base64,%s'%src) + new_child.text = utils._process_text(self, child.text) + self._node = copy.deepcopy(self.etree) + for n in self._node: + self._node.remove(n) + process_text(self.etree, self._node) + return self._node + +def parseString(node, localcontext = {}): + r = html2html(node, localcontext) + return r.render() + diff --git a/bin/report/render/rml.py b/bin/report/render/rml.py index faad2c4c0b1..8bac7e32518 100644 --- a/bin/report/render/rml.py +++ b/bin/report/render/rml.py @@ -24,6 +24,7 @@ import render import rml2pdf import rml2html as htmlizer import odt2odt as odt +import html2html as html class rml(render.render): @@ -60,5 +61,15 @@ class odt2odt(render.render): def _render(self): return odt.parseNode(self.rml_dom,self.localcontext) +class html2html(render.render): + def __init__(self, rml, localcontext = None, datas = {}): + render.render.__init__(self, datas) + self.rml_dom = rml + self.localcontext = localcontext + self.output_type = 'html' + + def _render(self): + return html.parseString(self.rml_dom,self.localcontext) + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
