folder.index = fdict.get("index")
folder.parent_idx = fdict.get("parent")
folder.root = fdict.get("root")
- folder.name = encode(fdict["title"])
+ folder.name = encode_title(fdict["title"])
for record in fdict["children"]:
if record["type"] == "text/x-moz-place-container":
elif record["type"] == "text/x-moz-place":
bookmark = Bookmark(
- href=record["uri"],
+ href=record["uri"].encode('utf-8'),
add_date=record.get("dateAdded"),
last_modified=record.get("lastModified"),
- keyword=record.get("keyword"),
+ keyword=get_str(record, "keyword"),
comment=get_comment(record.get("annos")),
- charset=record.get("charset"))
+ charset=get_str(record, "charset"))
bookmark.id = record["id"]
bookmark.index = record.get("index")
bookmark.parent_idx = record["parent"]
- bookmark.name = encode(record["title"])
+ bookmark.name = encode_title(record["title"])
self.current_folder.append(bookmark)
elif record["type"] == "text/x-moz-place-separator":
ruler.index = record["index"]
ruler.last_modified = record["lastModified"]
ruler.parent_idx = record["parent"]
- ruler.name = encode(record["title"])
+ ruler.name = encode_title(record["title"])
ruler.comment = get_comment(record.get("annos"))
self.current_folder.append(ruler)
else:
self.current_folder = None
-def encode(title):
+def encode_title(title):
return title.encode("UTF-8", "xmlcharrefreplace")
+def get_str(record, name):
+ if name in record:
+ return record[name].encode('utf-8')
+ return ''
+
def get_comment(annos):
if not annos:
return ''