use helper alias for unicode_safe

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3441 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2006-09-15 19:34:03 +00:00
parent 2a75dff16e
commit 27a8869783
2 changed files with 12 additions and 11 deletions

View file

@ -30,6 +30,8 @@ import linkcheck.httplib2
import linkcheck.strformat
import linkcheck.dns.exception
# helper alias
unicode_safe = linkcheck.strformat.unicode_safe
# Catch these exception on syntax checks.
ExcSyntaxList = [
@ -171,12 +173,12 @@ def get_url_from (base_url, recursion_level, aggregate,
@type name: string
"""
if base_url is not None:
base_url = linkcheck.strformat.unicode_safe(base_url)
base_url = unicode_safe(base_url)
if parent_url is not None:
parent_url = linkcheck.strformat.unicode_safe(parent_url)
parent_url = unicode_safe(parent_url)
if base_ref is not None:
base_ref = linkcheck.strformat.unicode_safe(base_ref)
name = linkcheck.strformat.unicode_safe(name)
base_ref = unicode_safe(base_ref)
name = unicode_safe(name)
url = absolute_url(base_url, base_ref, parent_url).lower()
klass = get_urlclass_from(url, assume_local)
return klass(base_url, recursion_level, aggregate,

View file

@ -41,6 +41,8 @@ import linkcheck.log
import linkcheck.httplib2
import linkcheck.HtmlParser.htmlsax
# helper alias
unicode_safe = linkcheck.strformat.unicode_safe
def urljoin (parent, url, scheme):
"""
@ -295,8 +297,7 @@ class UrlBase (object):
tag="url-effective-url")
self.url = effectiveurl
except tuple(linkcheck.checker.ExcSyntaxList), msg:
self.set_result(linkcheck.strformat.unicode_safe(msg),
valid=False)
self.set_result(unicode_safe(msg), valid=False)
return
self.set_cache_keys()
@ -411,8 +412,7 @@ class UrlBase (object):
# make nicer error msg for bad status line
if isinstance(value, linkcheck.httplib2.BadStatusLine):
value = _('Bad HTTP response %r') % str(value)
uvalue = linkcheck.strformat.unicode_safe(value)
self.set_result(uvalue, valid=False)
self.set_result(unicode_safe(value), valid=False)
# check content
warningregex = self.aggregate.config["warningregex"]
@ -423,8 +423,7 @@ class UrlBase (object):
self.check_content(warningregex)
except tuple(linkcheck.checker.ExcList):
value = self.handle_exception()
self.set_result(linkcheck.strformat.unicode_safe(value),
valid=False)
self.set_result(unicode_safe(value), valid=False)
self.checktime = time.time() - check_start
# check recursion
@ -734,7 +733,7 @@ class UrlBase (object):
"""
Return serialized url check data as unicode string.
"""
sep = linkcheck.strformat.unicode_safe(os.linesep)
sep = unicode_safe(os.linesep)
if self.base_url is not None:
assert isinstance(self.base_url, unicode), self
if self.parent_url is not None: