mirror of https://github.com/tLDP/python-tldp
removing all chdir() and resource copying logic
the logic for making sure to chdir() into the build directory has been sequestered into doctypes/common.py (and output.py); additionally, it is smarter to put the resource copying logic, there, as well
This commit is contained in:
parent
98b19ac5ce
commit
c390e71b4a
|
@ -24,26 +24,6 @@ class Asciidoc(BaseDoctype):
|
|||
'asciidoc_a2x': isexecutable,
|
||||
}
|
||||
|
||||
def chdir_output(self):
|
||||
os.chdir(self.output.dirname)
|
||||
return True
|
||||
|
||||
@depends(chdir_output)
|
||||
def copy_static_resources(self):
|
||||
source = list()
|
||||
for d in ('images', 'resources'):
|
||||
fullpath = os.path.join(self.source.dirname, d)
|
||||
fullpath = os.path.abspath(fullpath)
|
||||
if os.path.isdir(fullpath):
|
||||
source.append('"' + fullpath + '"')
|
||||
if not source:
|
||||
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)
|
||||
|
||||
@depends(chdir_output)
|
||||
def make_name_pdf(self):
|
||||
s = '''"{config.asciidoc_a2x}" \\
|
||||
--verbose \\
|
||||
|
@ -52,12 +32,10 @@ class Asciidoc(BaseDoctype):
|
|||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(chdir_output)
|
||||
def make_name_txt(self):
|
||||
s = 'cp --verbose --target-directory . -- "{source.filename}"'
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(chdir_output)
|
||||
def make_name_htmls(self):
|
||||
s = '''"{config.asciidoc_a2x}" \\
|
||||
--verbose \\
|
||||
|
@ -66,7 +44,6 @@ class Asciidoc(BaseDoctype):
|
|||
"{source.filename}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(chdir_output)
|
||||
def make_chunked_html(self):
|
||||
s = '''"{config.asciidoc_a2x}" \\
|
||||
--verbose \\
|
||||
|
|
|
@ -51,11 +51,6 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
'docbook4xml_xslprint': isreadablefile,
|
||||
}
|
||||
|
||||
def chdir_output(self):
|
||||
os.chdir(self.output.dirname)
|
||||
return True
|
||||
|
||||
@depends(chdir_output)
|
||||
def make_validated_source(self):
|
||||
s = '''"{config.docbook4xml_xmllint}" > "{output.validsource}" \\
|
||||
--nonet \\
|
||||
|
@ -66,21 +61,6 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
return self.shellscript(s)
|
||||
|
||||
@depends(make_validated_source)
|
||||
def copy_static_resources(self):
|
||||
source = list()
|
||||
for d in ('images', 'resources'):
|
||||
fullpath = os.path.join(self.source.dirname, d)
|
||||
fullpath = os.path.abspath(fullpath)
|
||||
if os.path.isdir(fullpath):
|
||||
source.append('"' + fullpath + '"')
|
||||
if not source:
|
||||
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)
|
||||
|
||||
@depends(copy_static_resources)
|
||||
def make_name_htmls(self):
|
||||
'''create a single page HTML output'''
|
||||
s = '''"{config.docbook4xml_xsltproc}" > "{output.name_htmls}" \\
|
||||
|
@ -100,7 +80,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(copy_static_resources)
|
||||
@depends(make_validated_source)
|
||||
def make_fo(self):
|
||||
'''generate the Formatting Objects intermediate output'''
|
||||
s = '''"{config.docbook4xml_xsltproc}" > "{output.name_fo}" \\
|
||||
|
@ -119,7 +99,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
return self.shellscript(s)
|
||||
|
||||
# -- this is conditionally built--see logic in make_name_pdf() below
|
||||
# @depends(chdir_output)
|
||||
# @depends(make_validated_source)
|
||||
def make_pdf_with_dblatex(self):
|
||||
'''use dblatex (fallback) to create a PDF'''
|
||||
s = '''"{config.docbook4xml_dblatex}" \\
|
||||
|
@ -129,7 +109,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_fo)
|
||||
@depends(make_validated_source, make_fo)
|
||||
def make_name_pdf(self):
|
||||
stem = self.source.stem
|
||||
classname = self.__class__.__name__
|
||||
|
@ -143,8 +123,8 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
stem, classname, 'make_pdf_with_dblatex')
|
||||
return self.make_pdf_with_dblatex()
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_html(self):
|
||||
@depends(make_validated_source)
|
||||
def make_chunked_html(self):
|
||||
'''create chunked HTML output'''
|
||||
s = '''"{config.docbook4xml_xsltproc}" \\
|
||||
--nonet \\
|
||||
|
@ -154,7 +134,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_html)
|
||||
@depends(make_chunked_html)
|
||||
def make_name_html(self):
|
||||
'''rename DocBook XSL's index.html to LDP standard STEM.html'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_indexhtml}" "{output.name_html}"'
|
||||
|
@ -166,7 +146,7 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_html, make_name_pdf, make_name_htmls)
|
||||
@depends(make_name_html, make_name_pdf, make_name_htmls, make_name_txt)
|
||||
def remove_validated_source(self):
|
||||
'''create final index.html symlink'''
|
||||
s = 'rm --verbose -- "{output.validsource}"'
|
||||
|
|
|
@ -63,11 +63,6 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
'docbook5xml_xslsingle': isreadablefile,
|
||||
}
|
||||
|
||||
def chdir_output(self):
|
||||
os.chdir(self.output.dirname)
|
||||
return True
|
||||
|
||||
@depends(chdir_output)
|
||||
def make_xincluded_source(self):
|
||||
s = '''"{config.docbook5xml_xmllint}" > "{output.validsource}" \\
|
||||
--nonet \\
|
||||
|
@ -84,22 +79,7 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_xincluded_source)
|
||||
def copy_static_resources(self):
|
||||
source = list()
|
||||
for d in ('images', 'resources'):
|
||||
fullpath = os.path.join(self.source.dirname, d)
|
||||
fullpath = os.path.abspath(fullpath)
|
||||
if os.path.isdir(fullpath):
|
||||
source.append('"' + fullpath + '"')
|
||||
if not source:
|
||||
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)
|
||||
|
||||
@depends(copy_static_resources)
|
||||
@depends(validate_source)
|
||||
def make_name_htmls(self):
|
||||
'''create a single page HTML output'''
|
||||
s = '''"{config.docbook5xml_xsltproc}" > "{output.name_htmls}" \\
|
||||
|
@ -119,7 +99,7 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
"{output.name_htmls}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(copy_static_resources)
|
||||
@depends(validate_source)
|
||||
def make_fo(self):
|
||||
'''generate the Formatting Objects intermediate output'''
|
||||
s = '''"{config.docbook5xml_xsltproc}" > "{output.name_fo}" \\
|
||||
|
@ -138,7 +118,7 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
return self.shellscript(s)
|
||||
|
||||
# -- this is conditionally built--see logic in make_name_pdf() below
|
||||
# @depends(chdir_output)
|
||||
# @depends(validate_source)
|
||||
def make_pdf_with_dblatex(self):
|
||||
'''use dblatex (fallback) to create a PDF'''
|
||||
s = '''"{config.docbook5xml_dblatex}" \\
|
||||
|
@ -148,7 +128,7 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_fo)
|
||||
@depends(make_fo, validate_source)
|
||||
def make_name_pdf(self):
|
||||
stem = self.source.stem
|
||||
classname = self.__class__.__name__
|
||||
|
@ -162,8 +142,8 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
stem, classname, 'make_pdf_with_dblatex')
|
||||
return self.make_pdf_with_dblatex()
|
||||
|
||||
@depends(make_name_htmls)
|
||||
def make_html(self):
|
||||
@depends(make_name_htmls, validate_source)
|
||||
def make_chunked_html(self):
|
||||
'''create chunked HTML output'''
|
||||
s = '''"{config.docbook5xml_xsltproc}" \\
|
||||
--nonet \\
|
||||
|
@ -173,7 +153,7 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
"{output.validsource}"'''
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_html)
|
||||
@depends(make_chunked_html)
|
||||
def make_name_html(self):
|
||||
'''rename DocBook XSL's index.html to LDP standard STEM.html'''
|
||||
s = 'mv -v --no-clobber -- "{output.name_indexhtml}" "{output.name_html}"'
|
||||
|
@ -185,7 +165,7 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
s = 'ln -svr -- "{output.name_html}" "{output.name_indexhtml}"'
|
||||
return self.shellscript(s)
|
||||
|
||||
@depends(make_name_htmls, make_html, make_fo, make_name_pdf)
|
||||
@depends(make_name_htmls, make_name_html, make_name_pdf, make_name_txt)
|
||||
def remove_xincluded_source(self):
|
||||
'''remove the xincluded source file'''
|
||||
s = 'rm --verbose -- "{output.validsource}"'
|
||||
|
|
|
@ -47,26 +47,6 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
|||
'docbooksgml_docbookdsl': isreadablefile,
|
||||
}
|
||||
|
||||
def chdir_output(self):
|
||||
os.chdir(self.output.dirname)
|
||||
return True
|
||||
|
||||
@depends(chdir_output)
|
||||
def copy_static_resources(self):
|
||||
source = list()
|
||||
for d in ('images', 'resources'):
|
||||
fullpath = os.path.join(self.source.dirname, d)
|
||||
fullpath = os.path.abspath(fullpath)
|
||||
if os.path.isdir(fullpath):
|
||||
source.append('"' + fullpath + '"')
|
||||
if not source:
|
||||
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)
|
||||
|
||||
@depends(copy_static_resources)
|
||||
def make_blank_indexsgml(self):
|
||||
indexsgml = os.path.join(self.source.dirname, 'index.sgml')
|
||||
self.indexsgml = os.path.isfile(indexsgml)
|
||||
|
|
|
@ -23,26 +23,6 @@ class Linuxdoc(BaseDoctype, SignatureChecker):
|
|||
'linuxdoc_htmldoc': isexecutable,
|
||||
}
|
||||
|
||||
def chdir_output(self):
|
||||
os.chdir(self.output.dirname)
|
||||
return True
|
||||
|
||||
@depends(chdir_output)
|
||||
def copy_static_resources(self):
|
||||
source = list()
|
||||
for d in ('images', 'resources'):
|
||||
fullpath = os.path.join(self.source.dirname, d)
|
||||
fullpath = os.path.abspath(fullpath)
|
||||
if os.path.isdir(fullpath):
|
||||
source.append('"' + fullpath + '"')
|
||||
if not source:
|
||||
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)
|
||||
|
||||
@depends(copy_static_resources)
|
||||
def make_htmls(self):
|
||||
'''create a single page HTML output (with incorrect name)'''
|
||||
s = '"{config.linuxdoc_sgml2html}" --split=0 "{source.filename}"'
|
||||
|
|
Loading…
Reference in New Issue