X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Storage%2Fbkmk_stjson.py;h=9f7fed78202d319658aa199047069f979a8c18e0;hb=9e2bf3eaee5a8ee84c61ee5eac9c55090d45f63f;hp=1d34cbddb68df94703690d696a14d47b4c3c94ae;hpb=e784339181e160ebaf4ee5e21e00c50712823421;p=bookmarks_db.git diff --git a/Storage/bkmk_stjson.py b/Storage/bkmk_stjson.py index 1d34cbd..9f7fed7 100644 --- a/Storage/bkmk_stjson.py +++ b/Storage/bkmk_stjson.py @@ -41,7 +41,7 @@ class storage_json(Walker): dict["lastModified"] = convert_date_to_json(f.last_modified) root = getattr(f, 'root') if root: dict["root"] = root - dict["title"] = f.name.decode('utf-8') + dict["title"] = f.name dict["type"] = "text/x-moz-place-container" if root: self.dict["children"].append(dict) @@ -69,7 +69,7 @@ class storage_json(Walker): keyword = getattr(b, 'keyword') if keyword: dict["keyword"] = keyword dict["lastModified"] = convert_date_to_json(b.last_modified) - dict["title"] = b.name.decode('utf-8') + dict["title"] = b.name dict["type"] = "text/x-moz-place" dict["uri"] = b.href self.folder_stack[-1].append(dict) @@ -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) - if r.name: dict["title"] = r.name.decode('utf-8') + if r.name: dict["title"] = r.name dict["type"] = "text/x-moz-place-separator" self.folder_stack[-1].append(dict) @@ -135,7 +135,7 @@ class storage_json(Walker): folder.guid = fdict.get("guid") folder.index = fdict.get("index") folder.root = fdict.get("root") - folder.name = encode_title(fdict["title"]) + folder.name = fdict["title"] if "children" in fdict: for record in fdict["children"]: @@ -154,7 +154,7 @@ class storage_json(Walker): elif record["type"] == "text/x-moz-place": bookmark = Bookmark( - href=record["uri"].encode('utf-8'), + href=record["uri"], add_date=convert_date_from_json( record.get("dateAdded")), last_modified=convert_date_from_json( @@ -166,7 +166,7 @@ class storage_json(Walker): bookmark.guid = record.get("guid") bookmark.id = record["id"] bookmark.index = record.get("index") - bookmark.name = encode_title(record["title"]) + bookmark.name = record["title"] self.current_folder.append(bookmark) elif record["type"] == "text/x-moz-place-separator": @@ -178,7 +178,7 @@ class storage_json(Walker): ruler.index = record["index"] ruler.last_modified = convert_date_from_json( record.get("lastModified")) - ruler.name = encode_title(record.get("title")) + ruler.name = record.get("title") ruler.comment = get_comment(record.get("annos")) self.current_folder.append(ruler) @@ -207,15 +207,9 @@ def convert_date_from_json(date): return date -def encode_title(title): - if title: - return title.encode("UTF-8", "xmlcharrefreplace") - return title - - def get_str(record, name): if name in record: - return record[name].encode('utf-8') + return record[name] return '' @@ -225,7 +219,7 @@ def get_comment(annos): for a in annos: if a["name"] == "bookmarkProperties/description": - return a["value"].encode('utf-8') + return a["value"] return '' @@ -235,4 +229,5 @@ def make_annos(value, name="bookmarkProperties/description"): "expires": 4, "flags": 0, "name": name, - "value": value.decode('utf-8')}] + "value": value, + }]