From: Oleg Broytman Date: Thu, 12 Aug 2010 09:13:59 +0000 (+0000) Subject: Parser could be None. X-Git-Tag: v4.5.3~107 X-Git-Url: https://git.phdru.name/?p=bookmarks_db.git;a=commitdiff_plain;h=a38eb2c9d04e866177c80cb961712ed3d4574f5e Parser could be None. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@269 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- 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)