lib/dynamic.py
changeset 58 004a32370ba5
parent 51 7015d65beb3d
child 74 6784c4350b41
equal deleted inserted replaced
57:31271426f879 58:004a32370ba5
     1 #!/usr/bin/python
     1 #!/usr/bin/python
     2 
     2 
     3 from keywords import get_keywords, sort_keywords, set_selection
     3 from keywords import get_keywords, sort_keywords, set_selection
     4 from templates import Template
     4 from templates import Template
     5 
     5 
     6 def process_index(bk, kw, pref):
     6 def process_index(bk, kw, pref, status, status_msg):
     7     tmpl = Template("dynamic.tmpl", pref)
     7     tmpl = Template("dynamic.tmpl", pref, status, status_msg)
     8     bk.sort(lambda x,y: cmp(x['name'],y['name']))
     8     bk.sort(lambda x,y: cmp(x['name'],y['name']))
     9     tmpl.set("Bookmarks", bk)
     9     tmpl.set("Bookmarks", bk)
    10     kw = sort_keywords(kw, pref)
    10     kw = sort_keywords(kw, pref)
    11     tmpl.set("Keywords", kw)
    11     tmpl.set("Keywords", kw)
    12     tmpl.set("total", len(bk))
    12     tmpl.set("total", len(bk))
    13     print tmpl.process()
    13     print tmpl.process()
    14 
    14 
    15 def do_dynamic(db, prefs, form = []):
    15 def do_dynamic(db, prefs, form, status, status_msg):
    16     if form:
    16     if form:
    17         selection = get_keywords(form, 'sel')
    17         selection = get_keywords(form, 'sel')
    18         exclusion = get_keywords(form, 'exc')
    18         exclusion = get_keywords(form, 'exc')
    19     else:
    19     else:
    20     	selection = exclusion = []
    20     	selection = exclusion = []
    29 		selection, exclusion)
    29 		selection, exclusion)
    30     total = len(bookmarks)
    30     total = len(bookmarks)
    31     if len(bookmarks) > 0:
    31     if len(bookmarks) > 0:
    32     	bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks))
    32     	bookmarks = db.get_bookmarks(map(lambda x: x[0], bookmarks))
    33     bookmarks = map(lambda bk: bk.dict(), bookmarks)
    33     bookmarks = map(lambda bk: bk.dict(), bookmarks)
    34     process_index(bookmarks, keywords[1:], prefs)
    34     process_index(bookmarks, keywords[1:], prefs, status, status_msg)