mirror of https://github.com/tLDP/python-tldp
move cleanup() method to BaseDoctype
This commit is contained in:
parent
66f11e5f3b
commit
84477c0f45
|
@ -4,7 +4,6 @@
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import errno
|
|
||||||
import logging
|
import logging
|
||||||
import networkx as nx
|
import networkx as nx
|
||||||
|
|
||||||
|
@ -53,20 +52,6 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
|
|
||||||
buildorder = ['buildall']
|
buildorder = ['buildall']
|
||||||
|
|
||||||
def cleanup(self):
|
|
||||||
stem = self.source.stem
|
|
||||||
removals = getattr(self, 'removals', None)
|
|
||||||
if removals:
|
|
||||||
for fn in removals:
|
|
||||||
logger.debug("%s cleaning up file %s", stem, fn)
|
|
||||||
try:
|
|
||||||
os.unlink(fn)
|
|
||||||
except OSError as e:
|
|
||||||
if e.errno is errno.ENOENT:
|
|
||||||
logger.error("%s missing file at cleanup %s", stem, fn)
|
|
||||||
else:
|
|
||||||
raise e
|
|
||||||
|
|
||||||
def hook_build_success(self):
|
def hook_build_success(self):
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
|
||||||
|
@ -119,7 +104,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
moved = self.shellscript(s)
|
moved = self.shellscript(s)
|
||||||
if moved:
|
if moved:
|
||||||
logger.debug("%s created %s", self.source.stem, indexsgml)
|
logger.debug("%s created %s", self.source.stem, indexsgml)
|
||||||
self.removals = [indexsgml]
|
self.removals.append(indexsgml)
|
||||||
return True
|
return True
|
||||||
return os.path.exists(indexsgml)
|
return os.path.exists(indexsgml)
|
||||||
|
|
||||||
|
@ -166,6 +151,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
return self.shellscript(s)
|
return self.shellscript(s)
|
||||||
|
|
||||||
def make_pdf_with_jw(self):
|
def make_pdf_with_jw(self):
|
||||||
|
'''use jw (openjade) to create a PDF'''
|
||||||
s = '''"{config.docbooksgml_jw}" \\
|
s = '''"{config.docbooksgml_jw}" \\
|
||||||
-f docbook \\
|
-f docbook \\
|
||||||
-b pdf \\
|
-b pdf \\
|
||||||
|
@ -174,6 +160,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
return self.shellscript(s)
|
return self.shellscript(s)
|
||||||
|
|
||||||
def make_pdf_with_dblatex(self):
|
def make_pdf_with_dblatex(self):
|
||||||
|
'''use dblatex (fallback) to create a PDF'''
|
||||||
s = '''"{config.docbooksgml_dblatex}" \\
|
s = '''"{config.docbooksgml_dblatex}" \\
|
||||||
-F sgml \\
|
-F sgml \\
|
||||||
-t pdf \\
|
-t pdf \\
|
||||||
|
@ -188,7 +175,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
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():
|
||||||
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",
|
||||||
|
@ -197,7 +184,7 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
|
|
||||||
@depends(graph, make_name_htmls)
|
@depends(graph, make_name_htmls)
|
||||||
def make_html(self):
|
def make_html(self):
|
||||||
'''create final index.html symlink'''
|
'''create chunked HTML outputs'''
|
||||||
s = '''"{config.docbooksgml_jw}" \\
|
s = '''"{config.docbooksgml_jw}" \\
|
||||||
-f docbook \\
|
-f docbook \\
|
||||||
-b html \\
|
-b html \\
|
||||||
|
@ -244,7 +231,5 @@ class DocbookSGML(BaseDoctype, SignatureChecker):
|
||||||
default=which('collateindex'),
|
default=which('collateindex'),
|
||||||
help='full path to collateindex [%(default)s]')
|
help='full path to collateindex [%(default)s]')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# -- end of file
|
# -- end of file
|
||||||
|
|
Loading…
Reference in New Issue