]> git.phdru.name Git - bookmarks_db.git/commitdiff
Log more parsers errors.
authorOleg Broytman <phd@phdru.name>
Mon, 3 Mar 2008 21:13:38 +0000 (21:13 +0000)
committerOleg Broytman <phd@phdru.name>
Mon, 3 Mar 2008 21:13:38 +0000 (21:13 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@191 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Robots/parse_html.py
Robots/parse_html_beautifulsoup.py
Robots/parse_html_htmlparser.py

index 3e49491c7fc36ff5f1e8749fc86195f2a49983e8..80d4a9243bbbec31b96d98a4881182afefd05361 100755 (executable)
@@ -67,7 +67,7 @@ def parse_html(filename, charset=None, log=None):
       parser = None
       for c in charsets:
          try:
-            parser = p(filename, c)
+            parser = p(filename, c, log)
             break
          except UnicodeEncodeError:
             pass
index 11db56371b0df277dd957484f782e54624721e40..25719ca9d643ad86e2c2844c572b938d1bf6f792 100644 (file)
@@ -49,11 +49,12 @@ class BadDeclParser(BeautifulSoup):
          return j
 
 
-def parse_html(filename, charset=None):
+def parse_html(filename, charset=None, log=None):
    infile = open(filename, 'r')
    try:
       root = BadDeclParser(infile, fromEncoding=charset)
    except TypeError:
+      if log: log("TypeError")
       return None
    finally:
       infile.close()
@@ -61,6 +62,7 @@ def parse_html(filename, charset=None):
    try:
       head = root.html.head
    except AttributeError:
+      if log: log("No HTML in root or no HEAD in HTML")
       return None
 
    if head is None:
index e1a35f1007babbf5a31c93751da082dc3e94156d..30911dda7012b0ad9aa273692cc766d3eb5cd775 100644 (file)
@@ -1,7 +1,7 @@
 """
    HTML Parser
 
-   Written by BroytMann. Copyright (C) 1997-2007 PhiloSoft Design
+   Written by BroytMann. Copyright (C) 1997-2008 PhiloSoft Design
 """
 
 from HTMLParser import HTMLParseError
@@ -73,7 +73,7 @@ class HTMLParser(_HTMLParser):
          self.icon = href
 
 
-def parse_html(filename, charset=None):
+def parse_html(filename, charset=None, log=None):
    infile = open(filename, 'r')
    parser = HTMLParser(charset)