From 1d46a18bfe213e25401908cc3c31c5ac66008572 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 12 Aug 2010 09:11:06 +0000 Subject: [PATCH] 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 --- Robots/parse_html.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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... -- 2.39.5