mirror of https://github.com/tLDP/python-tldp
separate operations by method and dependencies
use the generalized build sequence running supported by doctypes/common.py
This commit is contained in:
parent
df75f051db
commit
a415484b5a
|
@ -32,6 +32,13 @@ class Linuxdoc(BaseDoctype, SignatureChecker):
|
||||||
'linuxdoc_htmldoc': isexecutable,
|
'linuxdoc_htmldoc': isexecutable,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildorder = ['create_htmls',
|
||||||
|
'create_pdf',
|
||||||
|
'create_txt',
|
||||||
|
'create_html',
|
||||||
|
'create_indexhtml',
|
||||||
|
]
|
||||||
|
|
||||||
def build_precheck(self):
|
def build_precheck(self):
|
||||||
for tool, validator in self.required.items():
|
for tool, validator in self.required.items():
|
||||||
thing = getattr(self.config, tool, None)
|
thing = getattr(self.config, tool, None)
|
||||||
|
@ -81,36 +88,51 @@ class Linuxdoc(BaseDoctype, SignatureChecker):
|
||||||
logger.debug("%s creating HTML %s, etc.", stem, outf)
|
logger.debug("%s creating HTML %s, etc.", stem, outf)
|
||||||
cmd = [exe, inf]
|
cmd = [exe, inf]
|
||||||
result = execute(cmd, logdir=logdir)
|
result = execute(cmd, logdir=logdir)
|
||||||
if result == 0: # -- only symlink, if HTML generated successfully
|
if result != 0:
|
||||||
logger.info("%s created HTML %s, etc.", stem, outf)
|
return False
|
||||||
target = os.path.basename(outf)
|
logger.info("%s created HTML %s, etc.", stem, outf)
|
||||||
logger.debug("%s creating index.html symlink to %s.", stem, target)
|
|
||||||
try:
|
|
||||||
os.symlink(target, 'index.html')
|
|
||||||
except OSError:
|
|
||||||
logger.debug("%s failed in creating index.html symlink.", stem)
|
|
||||||
return os.path.isfile(outf)
|
return os.path.isfile(outf)
|
||||||
|
|
||||||
|
def create_indexhtml(self):
|
||||||
|
stem = self.source.stem
|
||||||
|
outf = self.output.name_html
|
||||||
|
target = os.path.basename(outf)
|
||||||
|
linkname = self.output.name_indexhtml
|
||||||
|
symlink = os.path.basename(linkname)
|
||||||
|
logger.debug("%s creating index.html symlink to %s.", stem, target)
|
||||||
|
try:
|
||||||
|
os.symlink(target, symlink)
|
||||||
|
logger.info("%s created link %s to %s.", stem, linkname, target)
|
||||||
|
except OSError:
|
||||||
|
logger.debug("%s failed in creating index.html symlink.", stem)
|
||||||
|
return os.path.islink(linkname)
|
||||||
|
|
||||||
def create_htmls(self):
|
def create_htmls(self):
|
||||||
exe = self.config.linuxdoc_sgml2html
|
exe = self.config.linuxdoc_sgml2html
|
||||||
inf = self.source.filename
|
inf = self.source.filename
|
||||||
assert os.path.exists(inf)
|
assert os.path.exists(inf)
|
||||||
outf = self.output.name_htmls
|
outf = self.output.name_html
|
||||||
stem = self.source.stem
|
stem = self.source.stem
|
||||||
logdir = self.output.logdir
|
logdir = self.output.logdir
|
||||||
logger.debug("%s creating HTMLS %s.", stem, outf)
|
logger.debug("%s creating HTMLS %s.", stem, outf)
|
||||||
cmd = [exe, '--split=0', inf]
|
cmd = [exe, '--split=0', inf]
|
||||||
result = execute(cmd, logdir=logdir)
|
result = execute(cmd, logdir=logdir)
|
||||||
if result == 0: # -- only rename, if HTML generated successfully
|
if result != 0:
|
||||||
|
return False
|
||||||
|
return os.path.isfile(outf)
|
||||||
|
|
||||||
|
def post_create_htmls(self):
|
||||||
|
stem = self.source.stem
|
||||||
|
outf = self.output.name_htmls
|
||||||
|
source = os.path.basename(self.output.name_html)
|
||||||
|
target = os.path.basename(outf)
|
||||||
|
logger.debug("%s renaming HTMLS to %s.", stem, target)
|
||||||
|
try:
|
||||||
|
os.rename(source, target)
|
||||||
logger.info("%s created HTMLS %s.", stem, outf)
|
logger.info("%s created HTMLS %s.", stem, outf)
|
||||||
source = os.path.basename(self.output.name_html)
|
except OSError:
|
||||||
target = os.path.basename(self.output.name_htmls)
|
logger.debug("%s failed renaming HTML single file to %s.",
|
||||||
logger.debug("%s renaming HTMLS to %s.", stem, target)
|
stem, target)
|
||||||
try:
|
|
||||||
os.rename(source, target)
|
|
||||||
except OSError:
|
|
||||||
logger.debug("%s failed renaming HTML single file to %s.",
|
|
||||||
stem, target)
|
|
||||||
return os.path.isfile(outf)
|
return os.path.isfile(outf)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue