add configurables and discovery of files

add argparse-style support to each doctype module, for path-configurables
also add the runtime discovery of files needed for document handling (e.g. XSL
and DSSSL files)
This commit is contained in:
Martin A. Brown 2016-02-22 12:32:35 -08:00
parent 468f0f6317
commit 3f37d09fe9
4 changed files with 105 additions and 40 deletions

View File

@ -1,19 +1,52 @@
#! /usr/bin/python #! /usr/bin/python
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
from ..utils import logger, which from ..utils import logger, which, firstfoundfile
from .common import SignatureChecker from .common import SignatureChecker
def xslchunk_finder():
l = ['/usr/share/xml/docbook/stylesheet/ldp/html/tldp-sections.xsl',
'/home/mabrown/vcs/LDP/LDP/builder/xsl/ldp-html-chunk.xsl',
]
return firstfoundfile(l)
def uniconf(p):
parser.add_argument('--docbook4xml-xsltproc', type=which, def xslsingle_finder():
help='fully qualified path to xsltproc') l = ['/usr/share/xml/docbook/stylesheet/ldp/html/tldp-one-page.xsl',
parser.add_argument('--docbook4xml-html2text', type=which, '/home/mabrown/vcs/LDP/LDP/builder/xsl/ldp-html.xsl',
help='fully qualified path to html2text') ]
parser.add_argument('--docbook4xml-fop', type=which, return firstfoundfile(l)
help='fully qualified path to fop')
parser.add_argument('--docbook4xml-dblatex', type=which,
help='fully qualified path to dblatex') def xslprint_finder():
l = ['/usr/share/xml/docbook/stylesheet/ldp/fo/tldp-print.xsl',
'/home/mabrown/vcs/LDP/LDP/builder/xsl/ldp-print.xsl',
]
return firstfoundfile(l)
def config_fragment(p):
p.add_argument('--docbook4xml-xslchunk', type=str,
default=xslchunk_finder(),
help='full path to LDP HTML section chunker XSL')
p.add_argument('--docbook4xml-xslsingle', type=str,
default=xslsingle_finder(),
help='full path to LDP HTML single-page XSL')
p.add_argument('--docbook4xml-xslprint', type=str,
default=xslprint_finder(),
help='full path to LDP FO print XSL')
p.add_argument('--docbook4xml-xsltproc', type=which,
default=which('xsltproc'),
help='fully qualified path to executable xsltproc')
p.add_argument('--docbook4xml-html2text', type=which,
default=which('html2text'),
help='fully qualified path to executable html2text')
p.add_argument('--docbook4xml-fop', type=which,
default=which('fop'),
help='fully qualified path to executable fop')
p.add_argument('--docbook4xml-dblatex', type=which,
default=which('dblatex'),
help='fully qualified path to executable dblatex')
class Docbook4XML(SignatureChecker): class Docbook4XML(SignatureChecker):

View File

@ -5,15 +5,19 @@ from ..utils import logger, which
from .common import SignatureChecker from .common import SignatureChecker
def uniconf(p): def config_fragment(p):
parser.add_argument('--docbook5xml-xsltproc', type=which, p.add_argument('--docbook5xml-xsltproc', type=which,
help='fully qualified path to xsltproc') default=which('xsltproc'),
parser.add_argument('--docbook5xml-html2text', type=which, help='fully qualified path to executable xsltproc')
help='fully qualified path to html2text') p.add_argument('--docbook5xml-html2text', type=which,
parser.add_argument('--docbook5xml-fop', type=which, default=which('html2text'),
help='fully qualified path to fop') help='fully qualified path to executable html2text')
parser.add_argument('--docbook5xml-dblatex', type=which, p.add_argument('--docbook5xml-fop', type=which,
help='fully qualified path to dblatex') default=which('fop'),
help='fully qualified path to executable fop')
p.add_argument('--docbook5xml-dblatex', type=which,
default=which('dblatex'),
help='fully qualified path to executable dblatex')
class Docbook5XML(SignatureChecker): class Docbook5XML(SignatureChecker):

View File

@ -1,21 +1,47 @@
#! /usr/bin/python #! /usr/bin/python
# -*- coding: utf8 -*- # -*- coding: utf8 -*-
from ..utils import logger, which import os
from ..utils import logger, which, firstfoundfile
from .common import SignatureChecker from .common import SignatureChecker
def uniconf(p): def docbookdsl_finder():
parser.add_argument('--docbooksgml-jw', type=which, locations = [
help='fully qualified path to jw') '/usr/share/sgml/docbook/stylesheet/dsssl/ldp/ldp.dsl',
parser.add_argument('--docbooksgml-html2text', type=which, '/usr/share/sgml/docbook/dsssl-stylesheets/html/docbook.dsl']
help='fully qualified path to html2text') return firstfoundfile(locations)
parser.add_argument('--docbooksgml-openjade', type=which,
help='fully qualified path to openjade')
parser.add_argument('--docbooksgml-dblatex', type=which, def ldpdsl_finder():
help='fully qualified path to dblatex') locations = [
parser.add_argument('--docbooksgml-collateindex', type=which, '/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl']
help='fully qualified path to collateindex') return firstfoundfile(locations)
def config_fragment(p):
p.add_argument('--docbooksgml-docbookdsl', type=str,
default=docbookdsl_finder(),
help='full path to html/docbook.dsl')
p.add_argument('--docbooksgml-ldpdsl', type=str,
default=ldpdsl_finder(),
help='full path to ldp/ldp.dsl')
p.add_argument('--docbooksgml-jw', type=which,
default=which('jw'),
help='fully qualified path to executable jw')
p.add_argument('--docbooksgml-html2text', type=which,
default=which('html2text'),
help='fully qualified path to executable html2text')
p.add_argument('--docbooksgml-openjade', type=which,
default=which('openjade'),
help='fully qualified path to executable openjade')
p.add_argument('--docbooksgml-dblatex', type=which,
default=which('dblatex'),
help='fully qualified path to executable dblatex')
p.add_argument('--docbooksgml-collateindex', type=which,
default=which('collateindex'),
help='fully qualified path to executable collateindex')
class DocbookSGML(SignatureChecker): class DocbookSGML(SignatureChecker):

View File

@ -4,19 +4,21 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import os import os
import argparse
from ..utils import logger, execute from ..utils import logger, which, execute
from .common import BaseDoctype, SignatureChecker from .common import BaseDoctype, SignatureChecker
def uniconf(p): def config_fragment(p):
parser.add_argument('--linuxdoc-sgml2html', type=str, p.add_argument('--linuxdoc-sgml2html', type=str,
help='fully qualified path to sgml2html') default=which('sgml2html'),
parser.add_argument('--linuxdoc-html2text', type=str, help='fully qualified path to executable sgml2html')
help='fully qualified path to html2text') p.add_argument('--linuxdoc-html2text', type=str,
parser.add_argument('--linuxdoc-htmldoc', type=str, default=which('html2text'),
help='fully qualified path to htmldoc') help='fully qualified path to executable html2text')
p.add_argument('--linuxdoc-htmldoc', type=str,
default=which('htmldoc'),
help='fully qualified path to executable htmldoc')
class Linuxdoc(BaseDoctype, SignatureChecker): class Linuxdoc(BaseDoctype, SignatureChecker):