[kupfer] pluin.firefox3_support: Add test snippet to end of file
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] pluin.firefox3_support: Add test snippet to end of file
- Date: Thu, 22 Oct 2009 13:00:58 +0000 (UTC)
commit 7fca1c5ffe9f8ffe869d383dffff567645a50d9c
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Oct 22 14:56:46 2009 +0200
pluin.firefox3_support: Add test snippet to end of file
Add an "if __name__ ..." to the module to allow independent testing of
it.
kupfer/plugin/firefox3_support.py | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/plugin/firefox3_support.py b/kupfer/plugin/firefox3_support.py
index 93f5bfc..64789f4 100644
--- a/kupfer/plugin/firefox3_support.py
+++ b/kupfer/plugin/firefox3_support.py
@@ -69,3 +69,18 @@ def get_bookmarks(bookmarks_file):
else:
bookmarks.append(b)
return bookmarks
+
+if __name__ == '__main__':
+ import os
+ import firefox_support
+
+ dirloc = firefox_support.get_firefox_home_file("bookmarkbackups")
+ fpath = None
+ if dirloc:
+ files = os.listdir(dirloc)
+ if files:
+ latest_file = (files.sort() or files)[-1]
+ fpath = os.path.join(dirloc, latest_file)
+
+ if fpath and os.path.splitext(fpath)[-1].lower() == ".json":
+ print "Parsed # bookmarks:", len(list(get_bookmarks(fpath)))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]