-
Notifications
You must be signed in to change notification settings - Fork 2
/
queuefolder.py
31 lines (25 loc) · 1.03 KB
/
queuefolder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import pbm.plugins
import logging
log = logging.getLogger(__name__)
class QueueFolderPlugin(pbm.plugins.PromiumPlugin):
folder_name = 'queue'
def check_node_ids(self, bookmarks_obj):
nodes = [n for n in
bookmarks_obj.bookmarks_dict['roots']['bookmark_bar']['children']
if n.get('name') == self.folder_name]
# if len(nodes) > 1:
# raise Exception(nodes)
for n in nodes:
if n.get('children'):
log.debug(("unprocessed queue", n))
# raise Exception(n)
def postprocess_bookmarks(self, bookmarks_obj):
self.check_node_ids(bookmarks_obj)
# remove any existing 'queue' folders and bookmarks
# XXX: this assumes that other plugins have alread re-filed
bookmarks_obj = bookmarks_obj.remove_bookmark_bar_folders(self.folder_name)
return bookmarks_obj.add_bookmark_bar_folder(
folder_name=self.folder_name)