]> git.phdru.name Git - bookmarks_db.git/commitdiff
Rulers can have no title
authorOleg Broytman <phd@phdru.name>
Wed, 17 Sep 2014 09:24:26 +0000 (13:24 +0400)
committerOleg Broytman <phd@phdru.name>
Wed, 17 Sep 2014 09:24:26 +0000 (13:24 +0400)
Storage/bkmk_stjson.py

index 43f5881183ba14cb12e54ed18b96b9bd267f3a7c..86e0270fd55b034fd6b91d651e8f7d0feb037375 100644 (file)
@@ -84,7 +84,7 @@ class storage_json(Walker):
         if guid: dict["guid"] = guid
         dict["index"] = r.index
         dict["lastModified"] = convert_date_to_json(r.last_modified)
-        dict["title"] = r.name.decode('utf-8')
+        if r.name: dict["title"] = r.name.decode('utf-8')
         dict["type"] = "text/x-moz-place-separator"
         self.folder_stack[-1].append(dict)
 
@@ -168,7 +168,7 @@ class storage_json(Walker):
                 ruler.id = record["id"]
                 ruler.index = record["index"]
                 ruler.last_modified = convert_date_from_json(record.get("lastModified"))
-                ruler.name = encode_title(record["title"])
+                ruler.name = encode_title(record.get("title"))
                 ruler.comment = get_comment(record.get("annos"))
                 self.current_folder.append(ruler)
 
@@ -195,7 +195,9 @@ def convert_date_from_json(date):
     return date
 
 def encode_title(title):
-    return title.encode("UTF-8", "xmlcharrefreplace")
+    if title:
+        return title.encode("UTF-8", "xmlcharrefreplace")
+    return title
 
 def get_str(record, name):
     if name in record: