configuration and storage of output encoding for loggers

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1873 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2004-10-27 09:25:05 +00:00
parent 06992936af
commit c7603d6797
6 changed files with 49 additions and 14 deletions

View file

@ -8,6 +8,22 @@
Type: bugfix
Changed: linkcheck/logger/*.py
* All loggers have now an output encoding. Valid encodings are listed
in http://docs.python.org/lib/node127.html. The default encoding is
"iso-8859-15".
Type: feature
Changed: linkcheck/logger/*.py
* The --output and --file-output parameters can specify the encoding
now. The documentation has been updated with this change.
Type: feature
Changed: linkchecker, linkchecker.1
* The encoding can also be specified in the linkcheckerrc config file.
Type: feature
Changed: config/linkcheckerrc
1.13.5 "Die Musterknaben" (released 22.9.2004)
* Use xgettext with Python support for .pot file creation, adjusted
developer documentation.

4
TODO
View file

@ -3,9 +3,7 @@ Next releases:
- logger methods should get called with unicode strings (using
the unicode-output from the html parser)
- specify output encoding for loggers
- standardize fileoutput init method for loggers
- use output encoding for loggers
- rethink intern/extern stuff

View file

@ -63,6 +63,9 @@
[gml]
#filename=linkchecker-out.gml
#fields=all
# valid encodings are listed in http://docs.python.org/lib/node127.html
# default encoding is iso-8859-15
#encoding=utf_16
# CSV logger
[csv]
@ -94,6 +97,10 @@
[blacklist]
#filename=~/.blacklist
# xml logger
[xml]
#encoding=iso-8859-1
# checking options
[checking]
# number of threads

View file

@ -42,21 +42,22 @@ Fields = {
class Logger (object):
"""basic logger class enabling logging of checked urls"""
def __init__ (self, **kwargs):
def __init__ (self, **args):
"""initialize a logger, looking for field restrictions in kwargs"""
# what log fields should be in output
self.logfields = None # log all fields
if args.has_key('fields'):
if "all" not in args['fields']:
# only log given fields
self.logfields = args['fields']
# number of spaces before log fields for alignment
self.logspaces = {}
# maximum indent of spaces for alignment
self.max_indent = 0
# number of encountered errors
self.errors = 0
# encoding of output strings
if kwargs.has_key('fields'):
if "all" not in kwargs['fields']:
# only log given fields
self.logfields = kwargs['fields']
# encoding of output
self.output_encoding = args.get("encoding", "iso-8859-1")
def init_fileoutput (self, args):
"""initialize self.fd file descriptor from args"""

View file

@ -258,15 +258,20 @@ group.add_option("-q", "--quiet", action="store_true", dest="quiet",
help=_(
"""Quiet operation. This is only useful with -F."""))
group.add_option("-o", "--output", type="string", dest="output",
metavar="TYPE[/ENCODING]",
help=_(
"""Specify output as %(loggertypes)s. Default output type is text.""") % \
"""Specify output as %(loggertypes)s. Default output type is text.
ENCODING specifies the output encoding, the default is "iso-8859-15".
Valid encodings are listed at http://docs.python.org/lib/node127.html.""") % \
{'loggertypes': linkcheck.LoggerKeys})
group.add_option("-F", "--file-output", type="string", action="append",
dest="fileoutput", metavar="TYPE[/FILENAME]",
dest="fileoutput", metavar="TYPE[/ENCODING][/FILENAME]",
help=_(
"""Output to a file linkchecker-out.TYPE, $HOME/.linkchecker_blacklist for
'blacklist' output, or FILENAME if specified.
The FILENAME part of the 'none' output type will be ignored,
ENCODING specifies the output encoding, the default is "iso-8859-15".
Valid encodings are listed at http://docs.python.org/lib/node127.html.
The FILENAME and ENCODING parts of the 'none' output type will be ignored,
else if the file already exists, it will be overwritten.
You can specify this option more than once. Valid file output TYPEs
are %(loggertypes)s. You can specify this option multiple times to output

View file

@ -100,15 +100,23 @@ This option implies \fB-w\fP.
\fB-q\fP, \fB--quiet\fP
Quiet operation. This is only useful with \fB-F\fP.
.TP
\fB-o\fP\fItype\fP, \fB--output=\fP\fItype\fP
\fB-o\fP\fItype\fP, \fB--output=\fP\fItype\fP[\fB/\fP\fIencoding\fP]
Specify output type as \fBtext\fP, \fBcolored\fP, \fBhtml\fP, \fBsql\fP,
\fBcsv\fP, \fBgml\fP, \fBxml\fP, \fBnone\fP or \fBblacklist\fP.
Default type is \fBtext\fP.
\fIencoding\fP specifies the output encoding, the default is
\fBiso-8859-15\fP.
Valid encodings are listed at
\fBhttp://docs.python.org/lib/node127.html\fP.
.TP
\fB-F\fP\fItype\fP[\fB/\fP\fIfilename\fP], \fB--file-output=\fP\fItype\fP[\fB/\fP\fIfilename\fP]
\fB-F\fP\fItype\fP[\fB/\fP\fIencoding\fP][\fB/\fP\fIfilename\fP], \fB--file-output=\fP\fItype\fP[\fB/\fP\fIencoding\fP][\fB/\fP\fIfilename\fP]
Output to a file \fBlinkchecker-out.\fP\fItype\fP,
\fB$HOME/.linkchecker_blacklist\fP for
\fBblacklist\fP output, or \fIfilename\fP if specified.
\fIencoding\fP specifies the output encoding, the default is
\fBiso-8859-15\fP.
Valid encodings are listed at
\fBhttp://docs.python.org/lib/node127.html\fP.
The \fIfilename\fP part of the \fBnone\fP output type will be ignored,
else if the file already exists, it will be overwritten.
You can specify this option more than once. Valid file output types