[kupfer] plugins.firefox: try to load bookmarks.html when load json bookmarks fail
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] plugins.firefox: try to load bookmarks.html when load json bookmarks fail
- Date: Sat, 10 Oct 2009 23:07:00 +0000 (UTC)
commit 56c34fc845513a5f5cd40689406c188272803266
Author: Karol BÄ?dkowski <karol bedkowsk+gh gmail com>
Date: Fri Oct 9 17:01:31 2009 +0200
plugins.firefox: try to load bookmarks.html when load json bookmarks fail
In my env opening bookmarks by (c)json fail with error:
"Expecting object: line 1 ...".
With this patch Kupfer try to open bookmarks.html when cjson/json
throw exception.
This patch includes changes by Ulrik Sverdrup.
kupfer/plugin/firefox.py | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/kupfer/plugin/firefox.py b/kupfer/plugin/firefox.py
index c6bf7ca..b334908 100644
--- a/kupfer/plugin/firefox.py
+++ b/kupfer/plugin/firefox.py
@@ -45,15 +45,20 @@ class BookmarksSource (AppLeafContentMixin, Source):
if files:
latest_file = (files.sort() or files)[-1]
fpath = os.path.join(dirloc, latest_file)
- if not fpath:
- fpath = firefox_support.get_firefox_home_file("bookmarks.html")
- if not fpath:
- self.output_error("No firefox bookmarks file found")
- return []
- if os.path.splitext(fpath)[-1] == ".json":
- return self._get_ffx3_items(fpath)
- elif os.path.splitext(fpath)[-1] == ".html":
+
+ if fpath and os.path.splitext(fpath)[-1].lower() == ".json":
+ try:
+ return self._get_ffx3_items(fpath)
+ except Exception, exc:
+ # Catch JSON parse errors
+ # different exception for cjson and json
+ self.output_error(exc)
+
+ fpath = firefox_support.get_firefox_home_file("bookmarks.html")
+ if fpath:
return self._get_ffx2_items(fpath)
+
+ self.output_error("No firefox bookmarks file found")
return []
def get_description(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]