/usr/share/pyshared/dbtexmf/xslt/xsltproc.py is in dblatex 0.3.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #
# Basic wrapper for xsltproc. Maybe we should directly use the lixslt Python
# API.
#
import os
import logging
import re
from subprocess import call, Popen, PIPE
class XsltProc:
def __init__(self):
self.catalogs = os.getenv("SGML_CATALOG_FILES")
self.use_catalogs = 1
self.log = logging.getLogger("dblatex")
self.run_opts = ["--xinclude"]
# If --xincludestyle is supported we *must* use it to support external
# listings (see mklistings.xsl and pals)
if self._has_xincludestyle():
self.run_opts.append("--xincludestyle")
def get_deplist(self):
return ["xsltproc"]
def run(self, xslfile, xmlfile, outfile, opts=None, params=None):
cmd = ["xsltproc", "-o", outfile] + self.run_opts
if self.use_catalogs and self.catalogs:
cmd.append("--catalogs")
if params:
for param, value in params.items():
cmd += ["--param", param, "'%s'" % value]
if opts:
cmd += opts
cmd += [xslfile, xmlfile]
self.system(cmd)
def system(self, cmd):
self.log.debug(" ".join(cmd))
rc = call(cmd)
if rc != 0:
raise ValueError("xsltproc failed")
def _has_xincludestyle(self):
# check that with help output the option is there
p = Popen(["xsltproc"], stdout=PIPE)
data = p.communicate()[0]
m = re.search("--xincludestyle", data, re.M)
if not(m):
return False
else:
return True
class Xslt(XsltProc):
"Plugin Class to load"
|