mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-05 07:20:58 +00:00
Make module detection more robust and use it when possible.
This commit is contained in:
parent
c0957a20df
commit
719441cca5
4 changed files with 10 additions and 10 deletions
|
|
@ -1,5 +1,9 @@
|
|||
6.8 "" (released xx.xx.2011)
|
||||
|
||||
Fixes:
|
||||
- checking: make module detection more robust
|
||||
|
||||
|
||||
Changes:
|
||||
- gui: Print detected module information in about dialog.
|
||||
- gui: Close application on Ctrl-C.
|
||||
|
|
|
|||
|
|
@ -754,12 +754,11 @@ class UrlBase (object):
|
|||
def check_html (self):
|
||||
"""Check HTML syntax of this page (which is supposed to be HTML)
|
||||
with the local HTML tidy module."""
|
||||
try:
|
||||
import tidy
|
||||
except ImportError:
|
||||
if not fileutil.has_module("tidy"):
|
||||
log.warn(LOG_CHECK, _("warning: tidy module is not available; " \
|
||||
"download from http://utidylib.berlios.de/"))
|
||||
return
|
||||
import tidy
|
||||
options = dict(output_html=0, show_warnings=1, quiet=True,
|
||||
input_encoding='utf8', output_encoding='utf8', tidy_mark=0)
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -339,9 +339,7 @@ class Configuration (dict):
|
|||
|
||||
def sanitize_checkhtml (self):
|
||||
"""Ensure HTML tidy is installed for checking HTML."""
|
||||
try:
|
||||
import tidy
|
||||
except ImportError:
|
||||
if not fileutil.has_module("tidy"):
|
||||
log.warn(LOG_CHECK,
|
||||
_("warning: tidy module is not available; " \
|
||||
"download from http://utidylib.berlios.de/"))
|
||||
|
|
@ -349,9 +347,7 @@ class Configuration (dict):
|
|||
|
||||
def sanitize_checkcss (self):
|
||||
"""Ensure cssutils is installed for checking CSS."""
|
||||
try:
|
||||
import cssutils
|
||||
except ImportError:
|
||||
if not fileutil.has_module("cssutils"):
|
||||
log.warn(LOG_CHECK,
|
||||
_("warning: cssutils module is not available; " \
|
||||
"download from http://cthedot.de/cssutils/"))
|
||||
|
|
|
|||
|
|
@ -65,7 +65,8 @@ def has_module (name):
|
|||
try:
|
||||
exec "import %s" % name
|
||||
return True
|
||||
except ImportError:
|
||||
except (OSError, ImportError):
|
||||
# some modules (for example HTMLtidy) raise OSError
|
||||
return False
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue