mirror of https://github.com/tLDP/python-tldp
pass **kwargs through all processor tools
adjust all processor tools so they take runtime parameters through **kwargs
This commit is contained in:
parent
2d75d3c4de
commit
94ab1ac5d2
|
@ -23,17 +23,17 @@ class Asciidoc(Docbook4XML):
|
|||
}
|
||||
required.update(Docbook4XML.required)
|
||||
|
||||
def make_docbook45(self):
|
||||
def make_docbook45(self, **kwargs):
|
||||
s = '''"{config.asciidoc_asciidoc}" \\
|
||||
--backend docbook45 \\
|
||||
--out-file {output.validsource} \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_docbook45)
|
||||
def make_validated_source(self):
|
||||
def make_validated_source(self, **kwargs):
|
||||
s = '"{config.asciidoc_xmllint}" --noout --valid "{output.validsource}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def argparse(cls, p):
|
||||
|
|
|
@ -99,7 +99,7 @@ class BaseDoctype(object):
|
|||
assert validator(thing)
|
||||
return True
|
||||
|
||||
def clear_output(self):
|
||||
def clear_output(self, **kwargs):
|
||||
'''remove the entire output directory
|
||||
|
||||
This method must be --script aware. The method execute_shellscript()
|
||||
|
@ -110,12 +110,12 @@ class BaseDoctype(object):
|
|||
self.output.stem, self.output.dirname)
|
||||
if self.config.script:
|
||||
s = 'test -d "{output.dirname}" && rm -rf -- "{output.dirname}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
if os.path.exists(self.output.dirname):
|
||||
shutil.rmtree(self.output.dirname)
|
||||
return True
|
||||
|
||||
def mkdir_output(self):
|
||||
def mkdir_output(self, **kwargs):
|
||||
'''create a new output directory
|
||||
|
||||
This method must be --script aware. The method execute_shellscript()
|
||||
|
@ -126,13 +126,13 @@ class BaseDoctype(object):
|
|||
self.output.stem, self.output.dirname)
|
||||
if self.config.script:
|
||||
s = 'mkdir -p -- "{output.logdir}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
for d in (self.output.dirname, self.output.logdir):
|
||||
if not os.path.isdir(d):
|
||||
os.mkdir(d)
|
||||
return True
|
||||
|
||||
def chdir_output(self):
|
||||
def chdir_output(self, **kwargs):
|
||||
'''chdir to the output directory (or write the script that would)'''
|
||||
logger.debug("%s chdir to dir %s.",
|
||||
self.output.stem, self.output.dirname)
|
||||
|
@ -141,7 +141,7 @@ class BaseDoctype(object):
|
|||
# - - - - - {source.stem} - - - - - -
|
||||
|
||||
cd -- "{output.dirname}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
os.chdir(self.output.dirname)
|
||||
return True
|
||||
|
||||
|
@ -158,7 +158,7 @@ class BaseDoctype(object):
|
|||
logger.debug("%s no images or resources to copy", self.source.stem)
|
||||
return True
|
||||
s = 'rsync --archive --verbose %s ./' % (' '.join(source))
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
def hook_build_prepare(self):
|
||||
stem = self.source.stem
|
||||
|
@ -203,18 +203,20 @@ class BaseDoctype(object):
|
|||
raise Exception(etext % (self.source.stem,))
|
||||
|
||||
@logtimings(logger.debug)
|
||||
def dump_shellscript(self, script, preamble=preamble, postamble=postamble):
|
||||
def dump_shellscript(self, script, preamble=preamble,
|
||||
postamble=postamble, **kwargs):
|
||||
source = self.source
|
||||
output = self.output
|
||||
config = self.config
|
||||
file = kwargs.get('file', sys.stdout)
|
||||
s = script.format(output=output, source=source, config=config)
|
||||
print('', file=sys.stdout)
|
||||
print(s, file=sys.stdout)
|
||||
print('', file=file)
|
||||
print(s, file=file)
|
||||
return True
|
||||
|
||||
@logtimings(logger.debug)
|
||||
def execute_shellscript(self, script, preamble=preamble,
|
||||
postamble=postamble):
|
||||
postamble=postamble, **kwargs):
|
||||
source = self.source
|
||||
output = self.output
|
||||
config = self.config
|
||||
|
@ -257,7 +259,7 @@ class BaseDoctype(object):
|
|||
return order
|
||||
|
||||
@logtimings(logger.debug)
|
||||
def buildall(self):
|
||||
def buildall(self, **kwargs):
|
||||
stem = self.source.stem
|
||||
order = self.determinebuildorder()
|
||||
logger.debug("%s build order %r", self.source.stem, order)
|
||||
|
@ -265,14 +267,14 @@ class BaseDoctype(object):
|
|||
classname = self.__class__.__name__
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, method.__name__)
|
||||
if not method():
|
||||
if not method(**kwargs):
|
||||
logger.error("%s called method %s.%s failed, skipping...",
|
||||
stem, classname, method.__name__)
|
||||
return False
|
||||
return True
|
||||
|
||||
@logtimings(logger.info)
|
||||
def generate(self):
|
||||
def generate(self, **kwargs):
|
||||
# -- perform build preparation steps;
|
||||
# - check for all executables and data files
|
||||
# - clear output dir
|
||||
|
@ -286,7 +288,7 @@ class BaseDoctype(object):
|
|||
|
||||
# -- build
|
||||
#
|
||||
result = self.buildall()
|
||||
result = self.buildall(**kwargs)
|
||||
|
||||
# -- report on result and/or cleanup
|
||||
#
|
||||
|
|
|
@ -50,17 +50,17 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
'docbook4xml_xslprint': isreadablefile,
|
||||
}
|
||||
|
||||
def make_validated_source(self):
|
||||
def make_validated_source(self, **kwargs):
|
||||
s = '''"{config.docbook4xml_xmllint}" > "{output.validsource}" \\
|
||||
--nonet \\
|
||||
--noent \\
|
||||
--xinclude \\
|
||||
--postvalid \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_validated_source)
|
||||
def make_name_htmls(self):
|
||||
def make_name_htmls(self, **kwargs):
|
||||
'''create a single page HTML output'''
|
||||
s = '''"{config.docbook4xml_xsltproc}" > "{output.name_htmls}" \\
|
||||
--nonet \\
|
||||
|
@ -68,62 +68,62 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
--stringparam base.dir . \\
|
||||
"{config.docbook4xml_xslsingle}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_name_txt(self):
|
||||
def make_name_txt(self, **kwargs):
|
||||
'''create text output'''
|
||||
s = '''"{config.docbook4xml_html2text}" > "{output.name_txt}" \\
|
||||
-style pretty \\
|
||||
-nobs \\
|
||||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_validated_source)
|
||||
def make_fo(self):
|
||||
def make_fo(self, **kwargs):
|
||||
'''generate the Formatting Objects intermediate output'''
|
||||
s = '''"{config.docbook4xml_xsltproc}" > "{output.name_fo}" \\
|
||||
"{config.docbook4xml_xslprint}" \\
|
||||
"{output.validsource}"'''
|
||||
self.removals.append(self.output.name_fo)
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
# -- this is conditionally built--see logic in make_name_pdf() below
|
||||
# @depends(make_fo)
|
||||
def make_pdf_with_fop(self):
|
||||
def make_pdf_with_fop(self, **kwargs):
|
||||
'''use FOP to create a PDF'''
|
||||
s = '''"{config.docbook4xml_fop}" \\
|
||||
-fo "{output.name_fo}" \\
|
||||
-pdf "{output.name_pdf}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
# -- this is conditionally built--see logic in make_name_pdf() below
|
||||
# @depends(make_validated_source)
|
||||
def make_pdf_with_dblatex(self):
|
||||
def make_pdf_with_dblatex(self, **kwargs):
|
||||
'''use dblatex (fallback) to create a PDF'''
|
||||
s = '''"{config.docbook4xml_dblatex}" \\
|
||||
-F xml \\
|
||||
-t pdf \\
|
||||
-o "{output.name_pdf}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_validated_source, make_fo)
|
||||
def make_name_pdf(self):
|
||||
def make_name_pdf(self, **kwargs):
|
||||
stem = self.source.stem
|
||||
classname = self.__class__.__name__
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, 'make_pdf_with_fop')
|
||||
if self.make_pdf_with_fop():
|
||||
if self.make_pdf_with_fop(**kwargs):
|
||||
return True
|
||||
logger.error("%s %s failed creating PDF, falling back to dblatex...",
|
||||
stem, self.config.docbook4xml_fop)
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, 'make_pdf_with_dblatex')
|
||||
return self.make_pdf_with_dblatex()
|
||||
return self.make_pdf_with_dblatex(**kwargs)
|
||||
|
||||
@depends(make_validated_source)
|
||||
def make_chunked_html(self):
|
||||
def make_chunked_html(self, **kwargs):
|
||||
'''create chunked HTML output'''
|
||||
s = '''"{config.docbook4xml_xsltproc}" \\
|
||||
--nonet \\
|
||||
|
@ -131,25 +131,25 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
--stringparam base.dir . \\
|
||||
"{config.docbook4xml_xslchunk}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_chunked_html)
|
||||
def make_name_html(self):
|
||||
def make_name_html(self, **kwargs):
|
||||
'''rename DocBook XSL's index.html to LDP standard STEM.html'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_indexhtml}" "{output.name_html}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_html)
|
||||
def make_name_indexhtml(self):
|
||||
def make_name_indexhtml(self, **kwargs):
|
||||
'''create final index.html symlink'''
|
||||
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_html, make_name_pdf, make_name_htmls, make_name_txt)
|
||||
def remove_validated_source(self):
|
||||
def remove_validated_source(self, **kwargs):
|
||||
'''create final index.html symlink'''
|
||||
s = 'rm --verbose -- "{output.validsource}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def argparse(cls, p):
|
||||
|
|
|
@ -62,24 +62,24 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
'docbook5xml_xslsingle': isreadablefile,
|
||||
}
|
||||
|
||||
def make_xincluded_source(self):
|
||||
def make_xincluded_source(self, **kwargs):
|
||||
s = '''"{config.docbook5xml_xmllint}" > "{output.validsource}" \\
|
||||
--nonet \\
|
||||
--noent \\
|
||||
--xinclude \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_xincluded_source)
|
||||
def validate_source(self):
|
||||
def validate_source(self, **kwargs):
|
||||
'''consider lxml.etree and other validators'''
|
||||
s = '''"{config.docbook5xml_jing}" \\
|
||||
"{config.docbook5xml_rngfile}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(validate_source)
|
||||
def make_name_htmls(self):
|
||||
def make_name_htmls(self, **kwargs):
|
||||
'''create a single page HTML output'''
|
||||
s = '''"{config.docbook5xml_xsltproc}" > "{output.name_htmls}" \\
|
||||
--nonet \\
|
||||
|
@ -87,62 +87,62 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
--stringparam base.dir . \\
|
||||
"{config.docbook5xml_xslsingle}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_name_txt(self):
|
||||
def make_name_txt(self, **kwargs):
|
||||
'''create text output'''
|
||||
s = '''"{config.docbook5xml_html2text}" > "{output.name_txt}" \\
|
||||
-style pretty \\
|
||||
-nobs \\
|
||||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(validate_source)
|
||||
def make_fo(self):
|
||||
def make_fo(self, **kwargs):
|
||||
'''generate the Formatting Objects intermediate output'''
|
||||
s = '''"{config.docbook5xml_xsltproc}" > "{output.name_fo}" \\
|
||||
"{config.docbook5xml_xslprint}" \\
|
||||
"{output.validsource}"'''
|
||||
self.removals.append(self.output.name_fo)
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
# -- this is conditionally built--see logic in make_name_pdf() below
|
||||
# @depends(make_fo)
|
||||
def make_pdf_with_fop(self):
|
||||
def make_pdf_with_fop(self, **kwargs):
|
||||
'''use FOP to create a PDF'''
|
||||
s = '''"{config.docbook5xml_fop}" \\
|
||||
-fo "{output.name_fo}" \\
|
||||
-pdf "{output.name_pdf}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
# -- this is conditionally built--see logic in make_name_pdf() below
|
||||
# @depends(validate_source)
|
||||
def make_pdf_with_dblatex(self):
|
||||
def make_pdf_with_dblatex(self, **kwargs):
|
||||
'''use dblatex (fallback) to create a PDF'''
|
||||
s = '''"{config.docbook5xml_dblatex}" \\
|
||||
-F xml \\
|
||||
-t pdf \\
|
||||
-o "{output.name_pdf}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_fo, validate_source)
|
||||
def make_name_pdf(self):
|
||||
def make_name_pdf(self, **kwargs):
|
||||
stem = self.source.stem
|
||||
classname = self.__class__.__name__
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, 'make_pdf_with_fop')
|
||||
if self.make_pdf_with_fop():
|
||||
if self.make_pdf_with_fop(**kwargs):
|
||||
return True
|
||||
logger.error("%s %s failed creating PDF, falling back to dblatex...",
|
||||
stem, self.config.docbook5xml_fop)
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, 'make_pdf_with_dblatex')
|
||||
return self.make_pdf_with_dblatex()
|
||||
return self.make_pdf_with_dblatex(**kwargs)
|
||||
|
||||
@depends(make_name_htmls, validate_source)
|
||||
def make_chunked_html(self):
|
||||
def make_chunked_html(self, **kwargs):
|
||||
'''create chunked HTML output'''
|
||||
s = '''"{config.docbook5xml_xsltproc}" \\
|
||||
--nonet \\
|
||||
|
@ -150,25 +150,25 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
--stringparam base.dir . \\
|
||||
"{config.docbook5xml_xslchunk}" \\
|
||||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_chunked_html)
|
||||
def make_name_html(self):
|
||||
def make_name_html(self, **kwargs):
|
||||
'''rename DocBook XSL's index.html to LDP standard STEM.html'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_indexhtml}" "{output.name_html}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_html)
|
||||
def make_name_indexhtml(self):
|
||||
def make_name_indexhtml(self, **kwargs):
|
||||
'''create final index.html symlink'''
|
||||
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls, make_name_html, make_name_pdf, make_name_txt)
|
||||
def remove_xincluded_source(self):
|
||||
def remove_xincluded_source(self, **kwargs):
|
||||
'''remove the xincluded source file'''
|
||||
s = 'rm --verbose -- "{output.validsource}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def argparse(cls, p):
|
||||
|
|
|
@ -47,7 +47,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
'docbooksgml_docbookdsl': isreadablefile,
|
||||
}
|
||||
|
||||
def make_blank_indexsgml(self):
|
||||
def make_blank_indexsgml(self, **kwargs):
|
||||
indexsgml = os.path.join(self.source.dirname, 'index.sgml')
|
||||
self.indexsgml = os.path.isfile(indexsgml)
|
||||
if self.indexsgml:
|
||||
|
@ -57,10 +57,10 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
-N \\
|
||||
-o \\
|
||||
"index.sgml"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_blank_indexsgml)
|
||||
def move_blank_indexsgml_into_source(self):
|
||||
def move_blank_indexsgml_into_source(self, **kwargs):
|
||||
'''move a blank index.sgml file into the source tree'''
|
||||
if self.indexsgml:
|
||||
return True
|
||||
|
@ -68,10 +68,10 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
--no-clobber \\
|
||||
--verbose \\
|
||||
-- "index.sgml" "{source.dirname}/index.sgml"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(move_blank_indexsgml_into_source)
|
||||
def make_data_indexsgml(self):
|
||||
def make_data_indexsgml(self, **kwargs):
|
||||
'''collect document's index entries into a data file (HTML.index)'''
|
||||
if self.indexsgml:
|
||||
return True
|
||||
|
@ -80,10 +80,10 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
-V html-index \\
|
||||
-d "{config.docbooksgml_docbookdsl}" \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_data_indexsgml)
|
||||
def make_indexsgml(self):
|
||||
def make_indexsgml(self, **kwargs):
|
||||
'''generate the final document index file (index.sgml)'''
|
||||
if self.indexsgml:
|
||||
return True
|
||||
|
@ -94,10 +94,10 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
-o "index.sgml" \\
|
||||
"HTML.index" \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_indexsgml)
|
||||
def move_indexsgml_into_source(self):
|
||||
def move_indexsgml_into_source(self, **kwargs):
|
||||
'''move the generated index.sgml file into the source tree'''
|
||||
if self.indexsgml:
|
||||
return True
|
||||
|
@ -106,7 +106,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
--verbose \\
|
||||
--force \\
|
||||
-- "index.sgml" "{source.dirname}/index.sgml"'''
|
||||
moved = self.shellscript(s)
|
||||
moved = self.shellscript(s, **kwargs)
|
||||
if moved:
|
||||
logger.debug("%s created %s", self.source.stem, indexsgml)
|
||||
self.removals.append(indexsgml)
|
||||
|
@ -114,7 +114,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
return False
|
||||
|
||||
@depends(move_indexsgml_into_source)
|
||||
def cleaned_indexsgml(self):
|
||||
def cleaned_indexsgml(self, **kwargs):
|
||||
'''clean the junk from the output dir after building the index.sgml'''
|
||||
# -- be super cautious before removing a bunch of files
|
||||
if not self.config.script:
|
||||
|
@ -126,10 +126,10 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
self.source.stem, self.output.dirname)
|
||||
return False
|
||||
s = '''find . -mindepth 1 -maxdepth 1 -not -type d -delete -print'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(cleaned_indexsgml)
|
||||
def make_htmls(self):
|
||||
def make_htmls(self, **kwargs):
|
||||
'''create a single page HTML output (with incorrect name)'''
|
||||
s = '''"{config.docbooksgml_jw}" \\
|
||||
-f docbook \\
|
||||
|
@ -140,57 +140,57 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
-V '%stock-graphics-extension%=.png' \\
|
||||
--output . \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_htmls)
|
||||
def make_name_htmls(self):
|
||||
def make_name_htmls(self, **kwargs):
|
||||
'''correct the single page HTML output name'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_html}" "{output.name_htmls}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_name_txt(self):
|
||||
def make_name_txt(self, **kwargs):
|
||||
'''create text output (from single-page HTML)'''
|
||||
s = '''"{config.docbooksgml_html2text}" > "{output.name_txt}" \\
|
||||
-style pretty \\
|
||||
-nobs \\
|
||||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
def make_pdf_with_jw(self):
|
||||
def make_pdf_with_jw(self, **kwargs):
|
||||
'''use jw (openjade) to create a PDF'''
|
||||
s = '''"{config.docbooksgml_jw}" \\
|
||||
-f docbook \\
|
||||
-b pdf \\
|
||||
--output . \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
def make_pdf_with_dblatex(self):
|
||||
def make_pdf_with_dblatex(self, **kwargs):
|
||||
'''use dblatex (fallback) to create a PDF'''
|
||||
s = '''"{config.docbooksgml_dblatex}" \\
|
||||
-F sgml \\
|
||||
-t pdf \\
|
||||
-o "{output.name_pdf}" \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(cleaned_indexsgml)
|
||||
def make_name_pdf(self):
|
||||
def make_name_pdf(self, **kwargs):
|
||||
stem = self.source.stem
|
||||
classname = self.__class__.__name__
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, 'make_pdf_with_jw')
|
||||
if self.make_pdf_with_jw():
|
||||
if self.make_pdf_with_jw(**kwargs):
|
||||
return True
|
||||
logger.error("%s jw failed creating PDF, falling back to dblatex...",
|
||||
stem)
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, 'make_pdf_with_dblatex')
|
||||
return self.make_pdf_with_dblatex()
|
||||
return self.make_pdf_with_dblatex(**kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_html(self):
|
||||
def make_html(self, **kwargs):
|
||||
'''create chunked HTML outputs'''
|
||||
s = '''"{config.docbooksgml_jw}" \\
|
||||
-f docbook \\
|
||||
|
@ -200,19 +200,19 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
-V '%stock-graphics-extension%=.png' \\
|
||||
--output . \\
|
||||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_html)
|
||||
def make_name_html(self):
|
||||
def make_name_html(self, **kwargs):
|
||||
'''rename openjade's index.html to LDP standard name STEM.html'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_indexhtml}" "{output.name_html}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_html)
|
||||
def make_name_indexhtml(self):
|
||||
def make_name_indexhtml(self, **kwargs):
|
||||
'''create final index.html symlink'''
|
||||
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def argparse(cls, p):
|
||||
|
|
|
@ -22,47 +22,47 @@ class Linuxdoc(BaseDoctype, SignatureChecker):
|
|||
'linuxdoc_htmldoc': isexecutable,
|
||||
}
|
||||
|
||||
def make_htmls(self):
|
||||
def make_htmls(self, **kwargs):
|
||||
'''create a single page HTML output (with incorrect name)'''
|
||||
s = '"{config.linuxdoc_sgml2html}" --split=0 "{source.filename}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_htmls)
|
||||
def make_name_htmls(self):
|
||||
def make_name_htmls(self, **kwargs):
|
||||
'''correct the single page HTML output name'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_html}" "{output.name_htmls}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_name_txt(self):
|
||||
def make_name_txt(self, **kwargs):
|
||||
'''create text output (from single-page HTML)'''
|
||||
s = '''"{config.linuxdoc_html2text}" > "{output.name_txt}" \\
|
||||
-style pretty \\
|
||||
-nobs \\
|
||||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_name_pdf(self):
|
||||
def make_name_pdf(self, **kwargs):
|
||||
s = '''"{config.linuxdoc_htmldoc}" \\
|
||||
--size universal \\
|
||||
--firstpage p1 \\
|
||||
--format pdf \\
|
||||
--outfile "{output.name_pdf}" \\
|
||||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_name_html(self):
|
||||
def make_name_html(self, **kwargs):
|
||||
'''create final index.html symlink'''
|
||||
s = '"{config.linuxdoc_sgml2html}" "{source.filename}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@depends(make_name_html)
|
||||
def make_name_indexhtml(self):
|
||||
def make_name_indexhtml(self, **kwargs):
|
||||
'''create final index.html symlink'''
|
||||
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
|
||||
return self.shellscript(s)
|
||||
return self.shellscript(s, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def argparse(cls, p):
|
||||
|
|
Loading…
Reference in New Issue