summaryrefslogtreecommitdiffstats
path: root/rteval-cmd
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2013-03-13 19:56:22 +0100
committerDavid Sommerseth <davids@redhat.com>2013-03-13 19:56:22 +0100
commit99253169b347346a96cc08d767f04dea615db79d (patch)
treebbf4ecc2bf54f234f27013e121f61ff48dc909d7 /rteval-cmd
parent27783aa01e41bce0e2b7b6e3db5d4b453f438ffe (diff)
downloadrteval-99253169b347346a96cc08d767f04dea615db79d.tar.gz
rteval-99253169b347346a96cc08d767f04dea615db79d.tar.xz
rteval-99253169b347346a96cc08d767f04dea615db79d.zip
Migrated from libxslt to lxml
To avoid depending on libxslt-python, use the more standard Python lxml module for XSLT processing. Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'rteval-cmd')
-rwxr-xr-xrteval-cmd27
1 files changed, 13 insertions, 14 deletions
diff --git a/rteval-cmd b/rteval-cmd
index 13003a7..4111e03 100755
--- a/rteval-cmd
+++ b/rteval-cmd
@@ -35,7 +35,7 @@
#
import sys, os, time, optparse, tempfile
-import libxml2, libxslt
+import libxml2, lxml.etree
from datetime import datetime
from rteval.Log import Log
from rteval import RtEval, rtevalConfig
@@ -68,25 +68,24 @@ def summarize(repfile, xslt):
isarchive = True
# Load the XSLT template
- xsltdoc = libxml2.parseFile(xslt)
- xsltprs = libxslt.parseStylesheetDoc(xsltdoc)
+ xsltfp = open(xslt, "r")
+ xsltdoc = lxml.etree.parse(xsltfp)
+ xsltprs = lxml.etree.XSLT(xsltdoc)
+ xsltfp.close()
# Load the summay.xml report - with some simple sanity checks
- xmldoc = libxml2.parseFile(summaryfile)
- if xmldoc.name != summaryfile:
- raise RuntimeError("Failed to load the report")
- if xmldoc.children.name != 'rteval':
- raise RuntimeError("The report doesn't seem like a rteval summary report")
+ xmlfp = open(summaryfile, "r")
+ xmldoc = lxml.etree.parse(xmlfp)
+ xmlfp.close()
- # Parse the report through the XSLT template - preserve proper encoding
- resdoc = xsltprs.applyStylesheet(xmldoc, None)
- report = xsltprs.saveResultToString(resdoc).encode(xsltprs.encoding())
+ if xmldoc.docinfo.root_name != 'rteval':
+ raise RuntimeError("The report doesn't seem like a rteval summary report")
- # Dump the report to stdout - as UTF-8
- print report.encode('UTF-8')
+ # Parse and print the report through the XSLT template - preserve proper encoding
+ resdoc = xsltprs(xmldoc)
+ print unicode(resdoc).encode('UTF-8')
# Clean up
- del report
del resdoc
del xmldoc
del xsltprs