folder.root = fdict.get("root")
folder.name = encode_title(fdict["title"])
- for record in fdict["children"]:
- if record["type"] == "text/x-moz-place-container":
- folder = Folder(
- add_date=convert_date_from_json(record.get("dateAdded")),
- comment=get_comment(record.get("annos")),
- last_modified=convert_date_from_json(record.get("lastModified")))
- folder.guid = record.get("guid")
- self.current_folder.append(folder)
- self.folder_stack.append(folder)
- self.current_folder = folder
- self.load_folder(folder, record)
-
- elif record["type"] == "text/x-moz-place":
- bookmark = Bookmark(
- href=record["uri"].encode('utf-8'),
- add_date=convert_date_from_json(record.get("dateAdded")),
- last_modified=convert_date_from_json(record.get("lastModified")),
- keyword=get_str(record, "keyword"),
- comment=get_comment(record.get("annos")),
- icon_href=record.get("iconuri"),
- charset=get_str(record, "charset"))
- bookmark.guid = record.get("guid")
- bookmark.id = record["id"]
- bookmark.index = record.get("index")
- bookmark.name = encode_title(record["title"])
- self.current_folder.append(bookmark)
-
- elif record["type"] == "text/x-moz-place-separator":
- ruler = Ruler()
- ruler.add_date = convert_date_from_json(record.get("dateAdded"))
- ruler.guid = record.get("guid")
- ruler.id = record["id"]
- ruler.index = record["index"]
- ruler.last_modified = convert_date_from_json(record.get("lastModified"))
- ruler.name = encode_title(record.get("title"))
- ruler.comment = get_comment(record.get("annos"))
- self.current_folder.append(ruler)
-
- else:
- raise ValueError('Unknown record type "%s"' % record["type"])
+ if "children" in fdict:
+ for record in fdict["children"]:
+ if record["type"] == "text/x-moz-place-container":
+ folder = Folder(
+ add_date=convert_date_from_json(record.get("dateAdded")),
+ comment=get_comment(record.get("annos")),
+ last_modified=convert_date_from_json(record.get("lastModified")))
+ folder.guid = record.get("guid")
+ self.current_folder.append(folder)
+ self.folder_stack.append(folder)
+ self.current_folder = folder
+ self.load_folder(folder, record)
+
+ elif record["type"] == "text/x-moz-place":
+ bookmark = Bookmark(
+ href=record["uri"].encode('utf-8'),
+ add_date=convert_date_from_json(record.get("dateAdded")),
+ last_modified=convert_date_from_json(record.get("lastModified")),
+ keyword=get_str(record, "keyword"),
+ comment=get_comment(record.get("annos")),
+ icon_href=record.get("iconuri"),
+ charset=get_str(record, "charset"))
+ bookmark.guid = record.get("guid")
+ bookmark.id = record["id"]
+ bookmark.index = record.get("index")
+ bookmark.name = encode_title(record["title"])
+ self.current_folder.append(bookmark)
+
+ elif record["type"] == "text/x-moz-place-separator":
+ ruler = Ruler()
+ ruler.add_date = convert_date_from_json(record.get("dateAdded"))
+ ruler.guid = record.get("guid")
+ ruler.id = record["id"]
+ ruler.index = record["index"]
+ ruler.last_modified = convert_date_from_json(record.get("lastModified"))
+ ruler.name = encode_title(record.get("title"))
+ ruler.comment = get_comment(record.get("annos"))
+ self.current_folder.append(ruler)
+
+ else:
+ raise ValueError('Unknown record type "%s"' % record["type"])
del self.folder_stack[-1]
if self.folder_stack: