From f6f43ffba86c4934db7354eecc09eeed48346c45 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 10 May 2012 21:29:18 +0200 Subject: [PATCH] Improve warning about missing twill module. --- linkcheck/director/__init__.py | 8 ++++++-- linkcheck/strformat.py | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/linkcheck/director/__init__.py b/linkcheck/director/__init__.py index 808c4c03..dbf43af0 100644 --- a/linkcheck/director/__init__.py +++ b/linkcheck/director/__init__.py @@ -21,7 +21,8 @@ import os import thread import urlparse from cStringIO import StringIO -from .. import log, LOG_CHECK, LinkCheckerInterrupt, cookies, dummy, fileutil +from .. import log, LOG_CHECK, LinkCheckerInterrupt, cookies, dummy, \ + fileutil, strformat from ..cache import urlqueue, robots_txt, cookie, connection from . import aggregator, console from ..httplib2 import HTTPMessage @@ -34,7 +35,10 @@ def visit_loginurl (aggregate): if not url: return if not fileutil.has_module("twill"): - log.warn(LOG_CHECK, _("Could not import twill for login URL visit")) + msg = strformat.format_feature_warning(module=u'twill', + feature=u'login URL visit', + url=u'http://twill.idyll.org/') + log.warn(LOG_CHECK, msg) return from twill import commands as tc log.debug(LOG_CHECK, u"Visiting login URL %s", url) diff --git a/linkcheck/strformat.py b/linkcheck/strformat.py index 262856d4..0d32d1da 100644 --- a/linkcheck/strformat.py +++ b/linkcheck/strformat.py @@ -304,3 +304,10 @@ def limit (s, length=72): def strline (s): """Display string representation on one line.""" return u"`%s'" % unicode(s).replace(u"\n", u"\\n") + + +def format_feature_warning (**kwargs): + """Format warning that a module could not be imported and that it should + be installed for a certain URL. + """ + return _("Could not import %(module)s for %(feature)s. Install %(module)s from %(url)s to use this feature.") % kwargs