From: Oleg Broytman Date: Thu, 12 Aug 2010 09:11:06 +0000 (+0000) Subject: Test if m_lib is available. X-Git-Tag: v4.5.3~108 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=1d46a18bfe213e25401908cc3c31c5ac66008572;p=bookmarks_db.git Test if m_lib is available. Return None instead of a parser if there are no parsers. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@268 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- diff --git a/Robots/parse_html.py b/Robots/parse_html.py index 347ed22..23f53e4 100755 --- a/Robots/parse_html.py +++ b/Robots/parse_html.py @@ -27,8 +27,12 @@ except ImportError: else: parsers.append(parse_html_beautifulsoup.parse_html) -from parse_html_htmlparser import parse_html -parsers.append(parse_html) +try: + from parse_html_htmlparser import parse_html +except ImportError: + pass +else: + parsers.append(parse_html) import re @@ -61,6 +65,9 @@ def recode_entities(title, charset): def parse_html(filename, charset=None, log=None): + if not parsers: + return None + if charset: try: codecs.lookup(charset) # In case of unknown charset...