]> git.phdru.name Git - bookmarks_db.git/blobdiff - Storage/bkmk_stjson.py
Load/store folder's root.
[bookmarks_db.git] / Storage / bkmk_stjson.py
index 77b3a039348f01262313a4bbf12ebe0c5bd4d0f5..00daa60361710e5c330cb51b62bc952c279bc757 100644 (file)
@@ -39,6 +39,8 @@ class storage_json(Walker):
         dict["lastModified"] = f.last_modified
         parent_idx = getattr(f, 'parent_idx')
         if parent_idx: dict["parent"] = parent_idx
+        root = getattr(f, 'root')
+        if root: dict["root"] = root
         dict["title"] = f.name.decode('utf-8')
         dict["type"] = "text/x-moz-place-container"
         self.folder_stack[-1].append(dict)
@@ -57,6 +59,8 @@ class storage_json(Walker):
         dict["id"] = b.id
         index = getattr(b, 'index')
         if index: dict["index"] = index
+        keyword = getattr(b, 'keyword')
+        if keyword: dict["keyword"] = keyword
         dict["lastModified"] = b.last_modified
         dict["parent"] = b.parent_idx
         dict["title"] = b.name.decode('utf-8')
@@ -97,6 +101,9 @@ class storage_json(Walker):
 
         root_folder = Folder()
         root_folder.header = ''
+        root_folder.add_date = bookmarks_dict["dateAdded"]
+        root_folder.comment = ''
+        root_folder.last_modified = bookmarks_dict["lastModified"]
         self.folder_stack = [root_folder]
         self.current_folder = root_folder
 
@@ -106,28 +113,22 @@ class storage_json(Walker):
 
         return root_folder
 
-    def load_folder(self, folder, _dict):
-        if _dict["type"] != "text/x-moz-place-container":
+    def load_folder(self, folder, fdict):
+        if fdict["type"] != "text/x-moz-place-container":
             raise ValueError("Root object is not a Mozilla container")
 
-        folder.id = _dict["id"]
-        folder.index = _dict.get("index")
-        folder.parent_idx = _dict.get("parent")
+        folder.id = fdict["id"]
+        folder.index = fdict.get("index")
+        folder.parent_idx = fdict.get("parent")
+        folder.root = fdict.get("root")
+        folder.name = encode(fdict["title"])
 
-        folder.name = encode(_dict["title"])
-        folder.comment = ''
-        folder.add_date = _dict["dateAdded"]
-        folder.last_modified = _dict["lastModified"]
-
-        for record in _dict["children"]:
+        for record in fdict["children"]:
             if record["type"] == "text/x-moz-place-container":
                 folder = Folder(
                     add_date=record["dateAdded"],
                     comment=get_comment(record.get("annos")),
                     last_modified=record["lastModified"])
-                folder.id = record["id"]
-                folder.parent_idx = record["parent"]
-                folder.name = encode(record["title"])
                 self.current_folder.append(folder)
                 self.folder_stack.append(folder)
                 self.current_folder = folder
@@ -138,6 +139,7 @@ class storage_json(Walker):
                     href=record["uri"],
                     add_date=record.get("dateAdded"),
                     last_modified=record.get("lastModified"),
+                    keyword=record.get("keyword"),
                     comment=get_comment(record.get("annos")),
                     charset=record.get("charset"))
                 bookmark.id = record["id"]