[FIX] Remove leftover instances of libxslt and libxml2, replace them by lxml
bzr revid: xmo@tinyerp.com-20091128100104-n0s3sv3p1601mn50
This commit is contained in:
parent
fdcbed339b
commit
752e88e521
|
@ -34,11 +34,10 @@ from osv.orm import browse_null
|
|||
from osv.orm import browse_record_list
|
||||
import pooler
|
||||
from xml.dom import minidom
|
||||
import libxml2
|
||||
import libxslt
|
||||
from pychart import *
|
||||
import misc
|
||||
import cStringIO
|
||||
from lxml import etree
|
||||
|
||||
class external_pdf(render.render):
|
||||
def __init__(self, pdf):
|
||||
|
@ -351,11 +350,11 @@ class report_custom(report_int):
|
|||
|
||||
new_doc.childNodes[0].appendChild(lines)
|
||||
|
||||
styledoc = libxml2.parseFile(os.path.join(tools.config['root_path'],'addons/base/report/custom_new.xsl'))
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
doc = libxml2.parseDoc(new_doc.toxml())
|
||||
rml_obj = style.applyStylesheet(doc, None)
|
||||
rml = style.saveResultToString(rml_obj)
|
||||
transform = etree.XSLT(
|
||||
etree.parse(os.path.join(tools.config['root_path'],
|
||||
'addons/base/report/custom_new.xsl')))
|
||||
rml = etree.tostring(
|
||||
transform(etree.fromstring(new_doc.toxml())))
|
||||
|
||||
self.obj = render.rml(rml)
|
||||
self.obj.render()
|
||||
|
@ -649,13 +648,11 @@ class report_custom(report_int):
|
|||
|
||||
new_doc.childNodes[0].appendChild(lines)
|
||||
|
||||
# file('/tmp/terp.xml','w+').write(new_doc.toxml())
|
||||
|
||||
styledoc = libxml2.parseFile(os.path.join(tools.config['root_path'],'addons/base/report/custom_new.xsl'))
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
doc = libxml2.parseDoc(new_doc.toxml())
|
||||
rml_obj = style.applyStylesheet(doc, None)
|
||||
rml = style.saveResultToString(rml_obj)
|
||||
transform = etree.XSLT(
|
||||
etree.parse(os.path.join(tools.config['root_path'],
|
||||
'addons/base/report/custom_new.xsl')))
|
||||
rml = etree.tostring(
|
||||
transform(etree.fromstring(new_doc.toxml())))
|
||||
|
||||
self.obj = render.rml(rml)
|
||||
self.obj.render()
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
import libxml2
|
||||
import libxslt
|
||||
from lxml import etree
|
||||
import netsvc
|
||||
import pooler
|
||||
|
@ -145,48 +143,34 @@ class report_rml(report_int):
|
|||
if not self.xsl:
|
||||
return xml
|
||||
|
||||
# load XSL (parse it to the XML level)
|
||||
styledoc = libxml2.parseDoc(tools.file_open(self.xsl).read())
|
||||
xsl_path, tail = os.path.split(self.xsl)
|
||||
for child in styledoc.children:
|
||||
if child.name == 'import':
|
||||
if child.hasProp('href'):
|
||||
imp_file = child.prop('href')
|
||||
_x, imp_file = tools.file_open(imp_file, subdir=xsl_path, pathinfo=True)
|
||||
child.setProp('href', urllib.quote(str(imp_file)))
|
||||
stylesheet = etree.parse(tools.file_open(self.xsl))
|
||||
xsl_path, _ = os.path.split(self.xsl)
|
||||
for import_child in stylesheet.findall('./import'):
|
||||
if 'href' in import_child.attrib:
|
||||
imp_file = import_child.get('href')
|
||||
_, imp_file = tools.file_open(imp_file, subdir=xsl_path, pathinfo=True)
|
||||
import_child.set('href', urllib.quote(str(imp_file)))
|
||||
|
||||
#TODO: get all the translation in one query. That means we have to:
|
||||
# * build a list of items to translate,
|
||||
# * issue the query to translate them,
|
||||
# * (re)build/update the stylesheet with the translated items
|
||||
|
||||
# translate the XSL stylesheet
|
||||
def look_down(child, lang):
|
||||
while child is not None:
|
||||
if (child.type == "element") and child.hasProp('t'):
|
||||
#FIXME: use cursor
|
||||
res = service.execute(cr.dbname, uid, 'ir.translation',
|
||||
'_get_source', self.name2, 'xsl', lang, child.content)
|
||||
if res:
|
||||
child.setContent(res.encode('utf-8'))
|
||||
look_down(child.children, lang)
|
||||
child = child.next
|
||||
def translate(doc, lang):
|
||||
for node in doc.xpath('//*[@t]'):
|
||||
translation = service.execute(
|
||||
cr.dbname, uid, 'ir.translation', '_get_source',
|
||||
self.name2, 'xsl', lang, node.text)
|
||||
if translation:
|
||||
node.text = translation
|
||||
|
||||
if context.get('lang', False):
|
||||
look_down(styledoc.children, context['lang'])
|
||||
translate(stylesheet, context['lang'])
|
||||
|
||||
# parse XSL
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
# load XML (data)
|
||||
doc = libxml2.parseMemory(xml,len(xml))
|
||||
# create RML (apply XSL to XML data)
|
||||
result = style.applyStylesheet(doc, None)
|
||||
# save result to string
|
||||
xml = style.saveResultToString(result)
|
||||
transform = etree.XSLT(stylesheet)
|
||||
xml = etree.tostring(
|
||||
transform(etree.fromstring(xml)))
|
||||
|
||||
style.freeStylesheet()
|
||||
doc.freeDoc()
|
||||
result.freeDoc()
|
||||
return xml
|
||||
|
||||
def create_pdf(self, rml, localcontext = None, logo=None, title=None):
|
||||
|
|
|
@ -26,8 +26,6 @@ import tools
|
|||
|
||||
from report import render
|
||||
from lxml import etree
|
||||
import libxml2
|
||||
import libxslt
|
||||
|
||||
import time, os
|
||||
|
||||
|
@ -140,11 +138,11 @@ class report_printscreen_list(report_int):
|
|||
lines.append(node_line)
|
||||
new_doc.append(node_line)
|
||||
|
||||
styledoc = libxml2.parseFile(os.path.join(tools.config['root_path'],'addons/base/report/custom_new.xsl'))
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
doc = libxml2.parseDoc(new_doc.toxml())
|
||||
rml_obj = style.applyStylesheet(doc, None)
|
||||
rml = style.saveResultToString(rml_obj)
|
||||
transform = etree.XSLT(
|
||||
etree.parse(os.path.join(tools.config['root_path'],
|
||||
'addons/base/report/custom_new.xsl')))
|
||||
rml = etree.tostring(transform(new_doc))
|
||||
|
||||
self.obj = render.rml(rml, self.title)
|
||||
self.obj.render()
|
||||
return True
|
||||
|
|
|
@ -25,8 +25,6 @@ import pooler
|
|||
import tools
|
||||
from lxml import etree
|
||||
from report import render
|
||||
import libxml2
|
||||
import libxslt
|
||||
import locale
|
||||
|
||||
import time, os
|
||||
|
@ -236,11 +234,12 @@ class report_printscreen_list(report_int):
|
|||
lines.append(node_line)
|
||||
|
||||
new_doc.append(lines)
|
||||
styledoc = libxml2.parseFile(os.path.join(tools.config['root_path'],'addons/base/report/custom_new.xsl'))
|
||||
style = libxslt.parseStylesheetDoc(styledoc)
|
||||
doc = libxml2.parseDoc(etree.tostring(new_doc))
|
||||
rml_obj = style.applyStylesheet(doc, None)
|
||||
rml = style.saveResultToString(rml_obj)
|
||||
|
||||
transform = etree.XSLT(
|
||||
etree.parse(os.path.join(tools.config['root_path'],
|
||||
'addons/base/report/custom_new.xsl')))
|
||||
rml = etree.tostring(transform(new_doc))
|
||||
|
||||
self.obj = render.rml(rml, title=self.title)
|
||||
self.obj.render()
|
||||
return True
|
||||
|
|
|
@ -35,12 +35,6 @@ from config import config
|
|||
import logging
|
||||
|
||||
import sys
|
||||
try:
|
||||
from lxml import etree
|
||||
except:
|
||||
sys.stderr.write("ERROR: pythonic binding for the libxml2 and libxslt libraries is missing\n")
|
||||
sys.stderr.write("ERROR: Try to install python-lxml package\n")
|
||||
sys.exit(2)
|
||||
import pickle
|
||||
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -55,8 +55,6 @@ py_short_version = '%s.%s' % sys.version_info[:2]
|
|||
required_modules = [
|
||||
('psycopg2', 'PostgreSQL module'),
|
||||
('xml', 'XML Tools for python'),
|
||||
('libxml2', 'libxml2 python bindings'),
|
||||
('libxslt', 'libxslt python bindings'),
|
||||
('reportlab', 'reportlab module'),
|
||||
('pychart', 'pychart module'),
|
||||
('pydot', 'pydot module'),
|
||||
|
|
Loading…
Reference in New Issue