CLI-tool friendly handling of EPIPE and INT

And, correcting from the name of the Python class to the format name processed
by the Python class (class.__name__ vs. class.formatname).
This commit is contained in:
Martin A. Brown 2016-03-11 14:21:56 -08:00
parent 2f71c66b5a
commit 61d55a9f69
1 changed files with 9 additions and 1 deletions

View File

@ -6,6 +6,7 @@ from __future__ import absolute_import, division, print_function
import os
import sys
import errno
import signal
import shutil
import logging
import inspect
@ -21,6 +22,13 @@ from tldp.utils import arg_isloglevel, arg_isdirectory
from tldp.utils import swapdirs, sameFilesystem
from tldp.doctypes.common import preamble, postamble
# -- Don't freak out with IOError when our STDOUT, handled with
# head, sed, awk, grep, etc; and, also deal with a user's ctrl-C
# the same way (i.e. no traceback, just stop)
#
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.SIG_DFL)
logformat = '%(levelname)-9s %(name)s %(filename)s#%(lineno)s ' \
+ '%(funcName)s %(message)s'
logging.basicConfig(stream=sys.stderr, format=logformat, level=logging.ERROR)
@ -122,7 +130,7 @@ def summary(config, *args, **kwargs):
print('', 'By Document Type', '----------------', sep='\n', file=file)
summarybytype = collections.defaultdict(list)
for doc in inv.source.values():
name = doc.doctype.__name__
name = doc.doctype.formatname
summarybytype[name].append(doc.stem)
for doctype, docs in summarybytype.items():
count = len(docs)