示例#1
0
文件: firefox.py 项目: chmouel/kupfer
	def get_items(self):
		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":
			try:
				return list(self._get_ffx3_items(fpath))
			except Exception, exc:
				# Catch JSON parse errors
				# different exception for cjson and json
				self.output_error(exc)
	# visit all tag folders
	tags_catalogs = {}
	for tag in tagcatalogs:
		items = []
		for bmark in tag["children"]:
			if is_bookmark(bmark) and is_good(bmark):
				bmap_add(bmark, bmap)
				bmap_add_tag(bmark["id"], tag["title"], bmap)
				items.append(bmark)
		if items:
			tags_catalogs[tag['title']] = items

	return bmap.values(), tags_catalogs

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":
		bookmarks, tags = get_bookmarks(fpath)
		print "Parsed # bookmarks:", len(bookmarks)
		print "Parsed # tags:", len(tags)
示例#3
0
	# visit all tag folders
	tags_catalogs = {}
	for tag in tagcatalogs:
		items = []
		for bmark in tag["children"]:
			if is_bookmark(bmark) and is_good(bmark):
				bmap_add(bmark, bmap)
				bmap_add_tag(bmark["id"], tag["title"], bmap)
				items.append(bmark)
		if items:
			tags_catalogs[tag['title']] = items

	return bmap.values(), tags_catalogs

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":
		bookmarks, tags = get_bookmarks(fpath)
		print "Parsed # bookmarks:", len(bookmarks)
		print "Parsed # tags:", len(tags)