From: Oleg Broytman Date: Thu, 12 Jun 2014 13:38:12 +0000 (+0400) Subject: Add helper scripts to debug JSON storage X-Git-Tag: v4.6.0~33 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=3a248e2d5c95bcc5b92db5fe9cd637bc201edec5;p=bookmarks_db.git Add helper scripts to debug JSON storage --- diff --git a/Storage/debug-json/bkmk-pprint-json b/Storage/debug-json/bkmk-pprint-json new file mode 100755 index 0000000..7d4a4eb --- /dev/null +++ b/Storage/debug-json/bkmk-pprint-json @@ -0,0 +1,17 @@ +#! /bin/sh + +DEBUG_DIR="`pwd`" +cd "`dirname \"$0\"`"/../.. +. "`dirname \"$0\"`"/set-path +cd "$DEBUG_DIR" + +rm -f bookmarks_db.json bookmarks_db.pickle bookmarks_db.txt \ + mozilla.json mozilla.txt json.diff +ln -s "$HOME"/Desktop/bookmarks-*.json bookmarks_db.json && +BKMK_STORAGE=json convert_st.py pickle && +mv bookmarks_db.json mozilla.json && +convert_st.py json && + +./pprint-json.py mozilla.json >mozilla.txt && +./pprint-json.py bookmarks_db.json >bookmarks_db.txt && +exec diff bookmarks_db.txt mozilla.txt >json.diff diff --git a/Storage/debug-json/pprint-json.py b/Storage/debug-json/pprint-json.py new file mode 100755 index 0000000..2df6a81 --- /dev/null +++ b/Storage/debug-json/pprint-json.py @@ -0,0 +1,16 @@ +#! /usr/bin/env python + +import sys +import json +from pprint import pprint + +infile = open(sys.argv[1], 'rb') +bkmk_s = infile.read() +infile.close() + +# Work around a bug in Mozilla - remove the trailing comma +bkmk_s = bkmk_s.strip().replace(',]', ']') +bookmarks_dict = json.loads(bkmk_s) +del bkmk_s + +pprint(bookmarks_dict)