mirror of https://github.com/tLDP/python-tldp
make an end run around the XSL/fop problem
teach the DocBook4 XML utility itself to set fop.extensions = 0 and fop1.extensions = 1 until such time as the upstream ldp-docbook-xsl packages can be repaired and/or adjusted
This commit is contained in:
parent
a4d5c5a4c6
commit
deaee034fc
|
@ -9,6 +9,7 @@ import logging
|
||||||
from tldp.utils import which, firstfoundfile
|
from tldp.utils import which, firstfoundfile
|
||||||
from tldp.utils import arg_isexecutable, isexecutable
|
from tldp.utils import arg_isexecutable, isexecutable
|
||||||
from tldp.utils import arg_isreadablefile, isreadablefile
|
from tldp.utils import arg_isreadablefile, isreadablefile
|
||||||
|
from tldp.utils import arg_isstr, isstr
|
||||||
|
|
||||||
from tldp.doctypes.common import BaseDoctype, SignatureChecker, depends
|
from tldp.doctypes.common import BaseDoctype, SignatureChecker, depends
|
||||||
|
|
||||||
|
@ -17,20 +18,24 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def xslchunk_finder():
|
def xslchunk_finder():
|
||||||
l = ['/usr/share/xml/docbook/stylesheet/ldp/html/tldp-sections.xsl',
|
l = ['/usr/share/xml/docbook/stylesheet/ldp/html/tldp-sections.xsl',
|
||||||
|
'http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl',
|
||||||
]
|
]
|
||||||
return firstfoundfile(l)
|
return firstfoundfile(l)
|
||||||
|
|
||||||
|
|
||||||
def xslsingle_finder():
|
def xslsingle_finder():
|
||||||
l = ['/usr/share/xml/docbook/stylesheet/ldp/html/tldp-one-page.xsl',
|
l = ['/usr/share/xml/docbook/stylesheet/ldp/html/tldp-one-page.xsl',
|
||||||
|
'http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl',
|
||||||
]
|
]
|
||||||
return firstfoundfile(l)
|
return firstfoundfile(l)
|
||||||
|
|
||||||
|
|
||||||
def xslprint_finder():
|
def xslprint_finder():
|
||||||
l = ['/usr/share/xml/docbook/stylesheet/ldp/fo/tldp-print.xsl',
|
l = ['http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl',
|
||||||
|
#'/usr/share/xml/docbook/stylesheet/ldp/fo/tldp-print.xsl',
|
||||||
]
|
]
|
||||||
return firstfoundfile(l)
|
return l[0]
|
||||||
|
#return firstfoundfile(l)
|
||||||
|
|
||||||
|
|
||||||
class Docbook4XML(BaseDoctype, SignatureChecker):
|
class Docbook4XML(BaseDoctype, SignatureChecker):
|
||||||
|
@ -48,7 +53,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
||||||
'docbook4xml_xmllint': isexecutable,
|
'docbook4xml_xmllint': isexecutable,
|
||||||
'docbook4xml_xslchunk': isreadablefile,
|
'docbook4xml_xslchunk': isreadablefile,
|
||||||
'docbook4xml_xslsingle': isreadablefile,
|
'docbook4xml_xslsingle': isreadablefile,
|
||||||
'docbook4xml_xslprint': isreadablefile,
|
'docbook4xml_xslprint': isstr,
|
||||||
}
|
}
|
||||||
|
|
||||||
def make_validated_source(self, **kwargs):
|
def make_validated_source(self, **kwargs):
|
||||||
|
@ -84,6 +89,8 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
||||||
def make_fo(self, **kwargs):
|
def make_fo(self, **kwargs):
|
||||||
'''generate the Formatting Objects intermediate output'''
|
'''generate the Formatting Objects intermediate output'''
|
||||||
s = '''"{config.docbook4xml_xsltproc}" > "{output.name_fo}" \\
|
s = '''"{config.docbook4xml_xsltproc}" > "{output.name_fo}" \\
|
||||||
|
--stringparam fop.extensions 0 \\
|
||||||
|
--stringparam fop1.extensions 1 \\
|
||||||
"{config.docbook4xml_xslprint}" \\
|
"{config.docbook4xml_xslprint}" \\
|
||||||
"{output.validsource}"'''
|
"{output.validsource}"'''
|
||||||
if not self.config.script:
|
if not self.config.script:
|
||||||
|
@ -164,7 +171,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
||||||
gadd('--docbook4xml-xslsingle', type=arg_isreadablefile,
|
gadd('--docbook4xml-xslsingle', type=arg_isreadablefile,
|
||||||
default=xslsingle_finder(),
|
default=xslsingle_finder(),
|
||||||
help='full path to LDP HTML single-page XSL [%(default)s]')
|
help='full path to LDP HTML single-page XSL [%(default)s]')
|
||||||
gadd('--docbook4xml-xslprint', type=arg_isreadablefile,
|
gadd('--docbook4xml-xslprint', type=arg_isstr,
|
||||||
default=xslprint_finder(),
|
default=xslprint_finder(),
|
||||||
help='full path to LDP FO print XSL [%(default)s]')
|
help='full path to LDP FO print XSL [%(default)s]')
|
||||||
gadd('--docbook4xml-xmllint', type=arg_isexecutable,
|
gadd('--docbook4xml-xmllint', type=arg_isexecutable,
|
||||||
|
|
|
@ -103,6 +103,8 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
||||||
def make_fo(self, **kwargs):
|
def make_fo(self, **kwargs):
|
||||||
'''generate the Formatting Objects intermediate output'''
|
'''generate the Formatting Objects intermediate output'''
|
||||||
s = '''"{config.docbook5xml_xsltproc}" > "{output.name_fo}" \\
|
s = '''"{config.docbook5xml_xsltproc}" > "{output.name_fo}" \\
|
||||||
|
--stringparam fop.extensions 0 \\
|
||||||
|
--stringparam fop1.extensions 1 \\
|
||||||
"{config.docbook5xml_xslprint}" \\
|
"{config.docbook5xml_xslprint}" \\
|
||||||
"{output.validsource}"'''
|
"{output.validsource}"'''
|
||||||
if not self.config.script:
|
if not self.config.script:
|
||||||
|
|
|
@ -59,6 +59,12 @@ def arg_isloglevel(l):
|
||||||
return level
|
return level
|
||||||
|
|
||||||
|
|
||||||
|
def arg_isstr(s):
|
||||||
|
if isstr(s):
|
||||||
|
return s
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def arg_isreadablefile(f):
|
def arg_isreadablefile(f):
|
||||||
if isreadablefile(f):
|
if isreadablefile(f):
|
||||||
return f
|
return f
|
||||||
|
@ -217,6 +223,11 @@ def isreadablefile(f):
|
||||||
return os.path.isfile(f) and os.access(f, os.R_OK)
|
return os.path.isfile(f) and os.access(f, os.R_OK)
|
||||||
|
|
||||||
|
|
||||||
|
def isstr(s):
|
||||||
|
'''True if argument is stringy (unicode or string)'''
|
||||||
|
return isinstance(s, basestring)
|
||||||
|
|
||||||
|
|
||||||
def which(program):
|
def which(program):
|
||||||
'''return None or the full path to an executable (respecting $PATH)
|
'''return None or the full path to an executable (respecting $PATH)
|
||||||
http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028
|
http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028
|
||||||
|
|
Loading…
Reference in New Issue