fix -F options

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1216 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2004-01-29 17:58:17 +00:00
parent 9206fe4519
commit 252e63ca47

View file

@ -177,15 +177,18 @@ group.add_option("-q", "--quiet", action="store_true", dest="quiet",
"""Quiet operation. This is only useful with -F."""))
group.add_option("-o", "--output", type="string", dest="output",
help=i18n._(
"""Specify output type as %s. Default type is text.""")%LoggerKeys)
group.add_option("-F", "--file-output", type="string", dest="fileoutput",
help=i18n._(
"""Specify output as %s. Default output type is text.""")%LoggerKeys)
group.add_option("-F", "--file-output", type="string", action="append",
dest="fileoutput", help=i18n._(
"""type[/filename]
Same as -o, but write to a file linkchecker-out.<type>
or <filename> if specified. If the file already exists, it
is overwritten. You can specify this option more than once.
There is no file output for the blacklist logger. Default is
no file output."""))
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,
else if the file already exists, it will be overwritten.
You can specify this option more than once. Valid file output types
are %s.
Default is no file output. If console output is not specified with -o,
this option suppresses all console output by implying -o none.""")%LoggerKeys)
group.add_option("-D", "--debug", action="count",
help=i18n._(
"""Print debugging information. Provide this option multiple times
@ -273,6 +276,10 @@ group = OptionGroup(optparser, i18n._("Deprecated options"))
group.add_option("-R", "--robots-txt", action="store_true")
optparser.add_option_group(group)
################# auto completion #####################
from linkcheck import optcomplete
optcomplete.autocomplete(optparser)
if "--wischiwaschi" in sys.argv:
from linkcheck import util1
util1.abbuzze()
@ -307,16 +314,19 @@ if options.output:
(options.output, "'-o, --output'"))
if options.fileoutput:
ns = {'fileoutput': 1}
try:
ftype, ns['filename'] = options.fileoutput.split('/', 1)
if not ns['filename']: raise ValueError
except ValueError:
ftype = options.fileoutput
if linkcheck.log.Loggers.has_key(ftype) and ftype != "blacklist":
config['fileoutput'].append(config.newLogger(ftype, ns))
else:
printUsage(i18n._("Illegal argument %r for option %s") % \
(options.fileoutput, "'-F, --file-output'"))
for ftype in options.fileoutput:
try:
ftype, ns['filename'] = ftype.split('/', 1)
if not ns['filename']: raise ValueError
except ValueError:
pass
if linkcheck.log.Loggers.has_key(ftype):
config['fileoutput'].append(config.newLogger(ftype, ns))
else:
printUsage(i18n._("Illegal argument %r for option %s") % \
(ftype, "'-F, --file-output'"))
if not options.output:
config['log'] = config.newLogger('none')
if options.interactive is not None:
config['interactive'] = options.interactive
if options.intern:
@ -379,13 +389,6 @@ if constructauth:
'user': _username,
'password': _password})
# construct the url list
# if we use blacklist mode, try to read ~/.blacklist
from linkcheck.log.BlacklistLogger import BlacklistLogger
if config["log"].__class__ == BlacklistLogger and \
os.path.exists(config['log'].filename):
args = file(config['log'].filename).readlines()
debug(HURT_ME_PLENTY, "configuration:", pprint.pformat(config.items()))
# interactive input