mirror of https://github.com/tLDP/python-tldp
pep8/pyflakes fixes
This commit is contained in:
parent
517a29b4a8
commit
76fd27d1fa
|
@ -37,7 +37,7 @@ def collectconfiguration(tag, argv):
|
|||
'-t',
|
||||
action='store_true', default=False,
|
||||
help='dump inventory summary report [%(default)s]')
|
||||
g.add_argument('--doctypes', '--formats', '--format',
|
||||
g.add_argument('--doctypes', '--formats', '--format',
|
||||
'--list-doctypes', '--list-formats',
|
||||
'-T',
|
||||
action='store_true', default=False,
|
||||
|
|
|
@ -107,7 +107,7 @@ class BaseDoctype(object):
|
|||
generates scripts into the directory that would be removed. Thus, the
|
||||
behaviour is different depending on --script mode or --build mode.
|
||||
'''
|
||||
logger.debug("%s removing dir %s.",
|
||||
logger.debug("%s removing dir %s.",
|
||||
self.output.stem, self.output.dirname)
|
||||
if self.config.script:
|
||||
s = 'test -d "{output.dirname}" && rm -rf -- "{output.dirname}"'
|
||||
|
@ -123,7 +123,7 @@ class BaseDoctype(object):
|
|||
generates scripts into the directory that would be removed. Thus, the
|
||||
behaviour is different depending on --script mode or --build mode.
|
||||
'''
|
||||
logger.debug("%s creating dir %s.",
|
||||
logger.debug("%s creating dir %s.",
|
||||
self.output.stem, self.output.dirname)
|
||||
if self.config.script:
|
||||
s = 'mkdir -p -- "{output.logdir}"'
|
||||
|
@ -135,7 +135,7 @@ class BaseDoctype(object):
|
|||
|
||||
def chdir_output(self):
|
||||
'''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)
|
||||
if self.config.script:
|
||||
s = 'cd -- "{output.dirname}"'
|
||||
|
@ -144,7 +144,7 @@ class BaseDoctype(object):
|
|||
return True
|
||||
|
||||
def copy_static_resources(self):
|
||||
logger.debug("%s copy resources %s.",
|
||||
logger.debug("%s copy resources %s.",
|
||||
self.output.stem, self.output.dirname)
|
||||
source = list()
|
||||
for d in self.config.resources:
|
||||
|
@ -172,7 +172,7 @@ class BaseDoctype(object):
|
|||
assert method is not None
|
||||
if not method():
|
||||
logger.warning("%s %s failed (%s), skipping",
|
||||
stem, methname, classname)
|
||||
stem, methname, classname)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -209,7 +209,8 @@ class BaseDoctype(object):
|
|||
return True
|
||||
|
||||
@logtimings(logger.debug)
|
||||
def execute_shellscript(self, script, preamble=preamble, postamble=postamble):
|
||||
def execute_shellscript(self, script, preamble=preamble,
|
||||
postamble=postamble):
|
||||
source = self.source
|
||||
output = self.output
|
||||
config = self.config
|
||||
|
@ -244,10 +245,10 @@ class BaseDoctype(object):
|
|||
for name, member in d.items():
|
||||
predecessors = getattr(member, 'depends', None)
|
||||
if predecessors:
|
||||
for pred in predecessors:
|
||||
method = d.get(pred, None)
|
||||
assert method is not None
|
||||
graph.add_edge(method, member)
|
||||
for pred in predecessors:
|
||||
method = d.get(pred, None)
|
||||
assert method is not None
|
||||
graph.add_edge(method, member)
|
||||
order = nx.dag.topological_sort(graph)
|
||||
return order
|
||||
|
||||
|
@ -258,7 +259,7 @@ class BaseDoctype(object):
|
|||
logger.debug("%s build order %r", self.source.stem, order)
|
||||
for method in order:
|
||||
classname = self.__class__.__name__
|
||||
logger.info("%s calling method %s.%s",
|
||||
logger.info("%s calling method %s.%s",
|
||||
stem, classname, method.__name__)
|
||||
if not method():
|
||||
logger.error("%s called method %s.%s failed, skipping...",
|
||||
|
|
|
@ -156,30 +156,31 @@ class Docbook4XML(BaseDoctype, SignatureChecker):
|
|||
def argparse(cls, p):
|
||||
descrip = 'executables and data files for %s' % (cls.formatname,)
|
||||
g = p.add_argument_group(title=cls.__name__, description=descrip)
|
||||
g.add_argument('--docbook4xml-xslchunk', type=arg_isreadablefile,
|
||||
default=xslchunk_finder(),
|
||||
help='full path to LDP HTML chunker XSL [%(default)s]')
|
||||
g.add_argument('--docbook4xml-xslsingle', type=arg_isreadablefile,
|
||||
default=xslsingle_finder(),
|
||||
help='full path to LDP HTML single-page XSL [%(default)s]')
|
||||
g.add_argument('--docbook4xml-xslprint', type=arg_isreadablefile,
|
||||
default=xslprint_finder(),
|
||||
help='full path to LDP FO print XSL [%(default)s]')
|
||||
g.add_argument('--docbook4xml-xmllint', type=arg_isexecutable,
|
||||
default=which('xmllint'),
|
||||
help='full path to xmllint [%(default)s]')
|
||||
g.add_argument('--docbook4xml-xsltproc', type=arg_isexecutable,
|
||||
default=which('xsltproc'),
|
||||
help='full path to xsltproc [%(default)s]')
|
||||
g.add_argument('--docbook4xml-html2text', type=arg_isexecutable,
|
||||
default=which('html2text'),
|
||||
help='full path to html2text [%(default)s]')
|
||||
g.add_argument('--docbook4xml-fop', type=arg_isexecutable,
|
||||
default=which('fop'),
|
||||
help='full path to fop [%(default)s]')
|
||||
g.add_argument('--docbook4xml-dblatex', type=arg_isexecutable,
|
||||
default=which('dblatex'),
|
||||
help='full path to dblatex [%(default)s]')
|
||||
gadd = g.add_argument
|
||||
gadd('--docbook4xml-xslchunk', type=arg_isreadablefile,
|
||||
default=xslchunk_finder(),
|
||||
help='full path to LDP HTML chunker XSL [%(default)s]')
|
||||
gadd('--docbook4xml-xslsingle', type=arg_isreadablefile,
|
||||
default=xslsingle_finder(),
|
||||
help='full path to LDP HTML single-page XSL [%(default)s]')
|
||||
gadd('--docbook4xml-xslprint', type=arg_isreadablefile,
|
||||
default=xslprint_finder(),
|
||||
help='full path to LDP FO print XSL [%(default)s]')
|
||||
gadd('--docbook4xml-xmllint', type=arg_isexecutable,
|
||||
default=which('xmllint'),
|
||||
help='full path to xmllint [%(default)s]')
|
||||
gadd('--docbook4xml-xsltproc', type=arg_isexecutable,
|
||||
default=which('xsltproc'),
|
||||
help='full path to xsltproc [%(default)s]')
|
||||
gadd('--docbook4xml-html2text', type=arg_isexecutable,
|
||||
default=which('html2text'),
|
||||
help='full path to html2text [%(default)s]')
|
||||
gadd('--docbook4xml-fop', type=arg_isexecutable,
|
||||
default=which('fop'),
|
||||
help='full path to fop [%(default)s]')
|
||||
gadd('--docbook4xml-dblatex', type=arg_isexecutable,
|
||||
default=which('dblatex'),
|
||||
help='full path to dblatex [%(default)s]')
|
||||
|
||||
#
|
||||
# -- end of file
|
||||
|
|
|
@ -175,37 +175,38 @@ class Docbook5XML(BaseDoctype, SignatureChecker):
|
|||
def argparse(cls, p):
|
||||
descrip = 'executables for %s' % (cls.formatname,)
|
||||
g = p.add_argument_group(title=cls.__name__, description=descrip)
|
||||
g.add_argument('--docbook5xml-xslchunk', type=arg_isreadablefile,
|
||||
default=xslchunk_finder(),
|
||||
help='full path to LDP HTML chunker XSL [%(default)s]')
|
||||
g.add_argument('--docbook5xml-xslsingle', type=arg_isreadablefile,
|
||||
default=xslsingle_finder(),
|
||||
help='full path to LDP HTML single-page XSL [%(default)s]')
|
||||
g.add_argument('--docbook5xml-xslprint', type=arg_isreadablefile,
|
||||
default=xslprint_finder(),
|
||||
help='full path to LDP FO print XSL [%(default)s]')
|
||||
gadd = g.add_argument
|
||||
gadd('--docbook5xml-xslchunk', type=arg_isreadablefile,
|
||||
default=xslchunk_finder(),
|
||||
help='full path to LDP HTML chunker XSL [%(default)s]')
|
||||
gadd('--docbook5xml-xslsingle', type=arg_isreadablefile,
|
||||
default=xslsingle_finder(),
|
||||
help='full path to LDP HTML single-page XSL [%(default)s]')
|
||||
gadd('--docbook5xml-xslprint', type=arg_isreadablefile,
|
||||
default=xslprint_finder(),
|
||||
help='full path to LDP FO print XSL [%(default)s]')
|
||||
|
||||
g.add_argument('--docbook5xml-rngfile', type=arg_isreadablefile,
|
||||
default=rngfile_finder(),
|
||||
help='full path to docbook.rng [%(default)s]')
|
||||
g.add_argument('--docbook5xml-xmllint', type=arg_isexecutable,
|
||||
default=which('xmllint'),
|
||||
help='full path to xmllint [%(default)s]')
|
||||
g.add_argument('--docbook5xml-xsltproc', type=arg_isexecutable,
|
||||
default=which('xsltproc'),
|
||||
help='full path to xsltproc [%(default)s]')
|
||||
g.add_argument('--docbook5xml-html2text', type=arg_isexecutable,
|
||||
default=which('html2text'),
|
||||
help='full path to html2text [%(default)s]')
|
||||
g.add_argument('--docbook5xml-fop', type=arg_isexecutable,
|
||||
default=which('fop'),
|
||||
help='full path to fop [%(default)s]')
|
||||
g.add_argument('--docbook5xml-dblatex', type=arg_isexecutable,
|
||||
default=which('dblatex'),
|
||||
help='full path to dblatex [%(default)s]')
|
||||
g.add_argument('--docbook5xml-jing', type=arg_isexecutable,
|
||||
default=which('jing'),
|
||||
help='full path to jing [%(default)s]')
|
||||
gadd('--docbook5xml-rngfile', type=arg_isreadablefile,
|
||||
default=rngfile_finder(),
|
||||
help='full path to docbook.rng [%(default)s]')
|
||||
gadd('--docbook5xml-xmllint', type=arg_isexecutable,
|
||||
default=which('xmllint'),
|
||||
help='full path to xmllint [%(default)s]')
|
||||
gadd('--docbook5xml-xsltproc', type=arg_isexecutable,
|
||||
default=which('xsltproc'),
|
||||
help='full path to xsltproc [%(default)s]')
|
||||
gadd('--docbook5xml-html2text', type=arg_isexecutable,
|
||||
default=which('html2text'),
|
||||
help='full path to html2text [%(default)s]')
|
||||
gadd('--docbook5xml-fop', type=arg_isexecutable,
|
||||
default=which('fop'),
|
||||
help='full path to fop [%(default)s]')
|
||||
gadd('--docbook5xml-dblatex', type=arg_isexecutable,
|
||||
default=which('dblatex'),
|
||||
help='full path to dblatex [%(default)s]')
|
||||
gadd('--docbook5xml-jing', type=arg_isexecutable,
|
||||
default=which('jing'),
|
||||
help='full path to jing [%(default)s]')
|
||||
|
||||
|
||||
#
|
||||
|
|
|
@ -17,7 +17,8 @@ from tldp.config import collectconfiguration
|
|||
from tldp.utils import arg_isloglevel, arg_isdirectory
|
||||
from tldp.doctypes.common import preamble, postamble
|
||||
|
||||
logformat = '%(levelname)-9s %(name)s %(filename)s#%(lineno)s %(funcName)s %(message)s'
|
||||
logformat = '%(levelname)-9s %(name)s %(filename)s#%(lineno)s ' \
|
||||
+ '%(funcName)s %(message)s'
|
||||
logging.basicConfig(stream=sys.stderr, format=logformat, level=logging.ERROR)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -40,9 +41,10 @@ def show_doctypes(config, **kwargs):
|
|||
print(file=file)
|
||||
return os.EX_OK
|
||||
|
||||
|
||||
def show_statustypes(config, **kwargs):
|
||||
file = kwargs.get('file', sys.stdout)
|
||||
width = 2 + max([len(x) for x in status_types])
|
||||
width = 2 + max([len(x) for x in status_types])
|
||||
print("Basic status types:", file=file)
|
||||
print(file=file)
|
||||
for status, descrip in stypes.items():
|
||||
|
@ -60,6 +62,7 @@ def show_statustypes(config, **kwargs):
|
|||
print(file=file)
|
||||
return os.EX_OK
|
||||
|
||||
|
||||
def summary(config, inv=None, **kwargs):
|
||||
if inv is None:
|
||||
inv = Inventory(config.pubdir, config.sourcedir)
|
||||
|
@ -230,7 +233,7 @@ def extractExplicitDocumentArgs(config, args):
|
|||
|
||||
def sameFilesystem(d0, d1):
|
||||
return os.stat(d0).st_dev == os.stat(d1).st_dev
|
||||
|
||||
|
||||
|
||||
def run(argv):
|
||||
# -- may want to see option parsing, so set --loglevel as
|
||||
|
|
|
@ -6,7 +6,6 @@ from __future__ import absolute_import, division, print_function
|
|||
import os
|
||||
import sys
|
||||
import errno
|
||||
import shutil
|
||||
import logging
|
||||
|
||||
from tldp.ldpcollection import LDPDocumentCollection
|
||||
|
|
|
@ -203,7 +203,7 @@ class SourceDocument(object):
|
|||
print(' doctype {}'.format(self.doctype), file=file)
|
||||
print(' source file {}'.format(self.filename), file=file)
|
||||
if self.output:
|
||||
print(' output dir {}'.format(self.output.dirname),
|
||||
print(' output dir {}'.format(self.output.dirname),
|
||||
file=file)
|
||||
for f in sorted(self.newer):
|
||||
fname = os.path.join(self.dirname, f)
|
||||
|
|
Loading…
Reference in New Issue