filename = "bookmarks_db.json"
def root_folder(self, f):
- self.dict = {}
+ self.dict = dict = {}
+ dict["children"] = children = []
+ self.folder_stack = [children]
+ dict["dateAdded"] = f.add_date
+ dict["id"] = f.id
+ dict["lastModified"] = f.last_modified
+ dict["root"] = "placesRoot"
+ dict["title"] = ""
+ dict["type"] = "text/x-moz-place-container"
def start_folder(self, f, level):
- pass
+ dict = {}
+ dict["children"] = children = []
+ dict["dateAdded"] = f.add_date
+ dict["id"] = f.id
+ index = getattr(f, 'index')
+ if index: dict["index"] = index
+ dict["lastModified"] = f.last_modified
+ parent_idx = getattr(f, 'parent_idx')
+ if parent_idx: dict["parent"] = parent_idx
+ dict["title"] = f.name.decode('utf-8')
+ dict["type"] = "text/x-moz-place-container"
+ self.folder_stack[-1].append(dict)
+ self.folder_stack.append(children)
+
+ def end_folder(self, f, level):
+ del self.folder_stack[-1]
def bookmark(self, b, level):
- pass
+ dict = {}
+ charset = getattr(b, 'charset')
+ if charset: dict["charset"] = charset
+ dict["dateAdded"] = b.add_date
+ dict["id"] = b.id
+ index = getattr(b, 'index')
+ if index: dict["index"] = index
+ dict["lastModified"] = b.last_modified
+ dict["parent"] = b.parent_idx
+ dict["title"] = b.name.decode('utf-8')
+ dict["type"] = "text/x-moz-place"
+ dict["uri"] = b.href
+ self.folder_stack[-1].append(dict)
def ruler(self, r, level):
- pass
+ dict = {}
+ dict["dateAdded"] = r.add_date
+ dict["id"] = r.id
+ dict["index"] = r.index
+ dict["lastModified"] = r.last_modified
+ dict["parent"] = r.parent_idx
+ dict["title"] = r.name.decode('utf-8')
+ dict["type"] = "text/x-moz-place-separator"
+ self.folder_stack[-1].append(dict)
def store(self, root_folder):
root_folder.walk_depth(self)
folder.parent_idx = _dict.get("parent")
folder.name = encode(_dict["title"])
- folder.href = _dict.get("uri")
folder.comment = ''
folder.add_date = _dict["dateAdded"]
folder.last_modified = _dict["lastModified"]
last_modified=record.get("lastModified"),
charset=record.get("charset"))
bookmark.id = record["id"]
+ bookmark.index = record.get("index")
bookmark.parent_idx = record["parent"]
bookmark.name = encode(record["title"])
self.current_folder.append(bookmark)