From a38eb2c9d04e866177c80cb961712ed3d4574f5e Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 12 Aug 2010 09:13:59 +0000 Subject: [PATCH] Parser could be None. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@269 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Robots/bkmk_rsimple.py | 43 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Robots/bkmk_rsimple.py b/Robots/bkmk_rsimple.py index ba30294..67d1fbe 100644 --- a/Robots/bkmk_rsimple.py +++ b/Robots/bkmk_rsimple.py @@ -176,26 +176,29 @@ class robot_simple(Robot): html = False if html: parser = parse_html(fname, charset, self.log) - bookmark.real_title = parser.title - if parser.refresh: - refresh = parser.refresh - try: - url = refresh.split('=', 1)[1] - except IndexError: - url = "self" - try: - timeout = float(refresh.split(';')[0]) - except (IndexError, ValueError): - raise RedirectException("html", "Bad redirect to %s (%s)" % (url, refresh)) - else: - try: - timeout = int(refresh.split(';')[0]) - except ValueError: - pass # float timeout - raise RedirectException("html", "%s (%s sec)" % (url, timeout)) - - # Get favicon.ico - icon = parser.icon + if parser: + bookmark.real_title = parser.title + if parser.refresh: + refresh = parser.refresh + try: + url = refresh.split('=', 1)[1] + except IndexError: + url = "self" + try: + timeout = float(refresh.split(';')[0]) + except (IndexError, ValueError): + raise RedirectException("html", "Bad redirect to %s (%s)" % (url, refresh)) + else: + try: + timeout = int(refresh.split(';')[0]) + except ValueError: + pass # float timeout + raise RedirectException("html", "%s (%s sec)" % (url, timeout)) + + # Get favicon.ico + icon = parser.icon + else: + icon = None if not icon: icon = "/favicon.ico" icon = urljoin("%s://%s%s" % (url_type, url_host, url_path), icon) -- 2.39.5