]> git.phdru.name Git - bookmarks_db.git/blobdiff - bkmk_parser.py
Fix(Robot): Stop splitting and un-splitting URLs
[bookmarks_db.git] / bkmk_parser.py
index 00cfcd4c4ce298efc4d4da643b188b391230f325..997728f3b9ceba4072be9c7c872d02fda8ca763b 100644 (file)
@@ -16,18 +16,18 @@ from m_lib.net.www.html import HTMLParser
 from bkmk_objects import Folder, Bookmark, Ruler
 
 
-DEBUG = os.environ.has_key("BKMK_DEBUG")
+DEBUG = "BKMK_DEBUG" in os.environ
 
 if DEBUG:
     def debug(note):
         print(note)
 
     def dump_names(folder_stack):
-        l = []
+        _l = []
         for object in folder_stack:
             if object.isFolder:
-                l.append(object.name)
-        return "'%s'" % "' '".join(l)
+                _l.append(object.name)
+        return "'%s'" % "' '".join(_l)
 
 else:
     def debug(note):
@@ -47,8 +47,9 @@ class BkmkParser(HTMLParser):
 
     def handle_data(self, data):
         if data:
-            if self.charset and default_encoding:
-                data = unicode(data, self.charset, "replace").encode(default_encoding, "xmlcharrefreplace")
+            #if self.charset and default_encoding:
+            #    data = data.decode(self.charset, "replace").\
+            #        encode(default_encoding, "xmlcharrefreplace")
             self.accumulator += data
 
     # Mozilla - get charset
@@ -72,7 +73,8 @@ class BkmkParser(HTMLParser):
 
     def start_title(self, attrs):
         if default_encoding:
-            self.accumulator += '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%s">\n' % default_encoding
+            self.accumulator += '<META HTTP-EQUIV="Content-Type" '
+            'CONTENT="text/html; charset=%s">\n' % default_encoding
         self.accumulator += "<TITLE>"
 
     def end_title(self):