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