""" Functions, Constants, and utilities for WikidPad.WikiData.Todos
Function genTodos(WikidPad, WikiWord) :
- Opening a page called ToDo -> generates a list of ALL Todos with 'todo' in it
- Opening a page called TodoWikidPad -> generates a list of all Todos with strings 'todo' AND 'WikidPad' in the text
- Opening a page called TodoNEXT -> will generate a list of all Todos with strings 'todo' AND 'NEXT' in the text (including "todo.NEXT:")
- The Todos are then sorted according to further categories if they contain any of a defined set of Tag Words like 'URGENT' , 'ASAP' , 'NEXT', etc.
- Tag Words can be customised in the code (look for TAG LIST in todos.py)
- Todos that have more than one Tag Word in it are displayed in the category that comes first in the TAG LIST, and not duplicated
(although this can be easily changed)
"""
tags = [('_spec.SPACER',''),
('HIGH','Tagged HIGH ! '),
('high','Tagged HIGH ! '),
('HOT','Tagged Hot ! '),
('hot','Tagged Hot ! '),
('URGENT','Tagged URGENT ! '),
('urgent','Tagged URGENT ! '),
('_spec.SPACER',''),
('NEXT','Tagged Next'),
('next','Tagged Next'),
('_spec.SPACER',''),
('ASAP','Tagged ASAP'),
('asap','Tagged ASAP'),
('soon','Tagged Soon'),
('thisweek','Tagged for This Week'),
('_spec.SPACER',''),
('bug','Tagged as Bug'),
('_spec.SPACER',''),
('issue','Tagged as Issue'),
('_spec.SPACER',''),
('_spec.NOTAGS','UNTAGGED Todos'),
('_spec.SPACER',''),
('later','Tagged for Later'),
('someday','Tagged for Someday'),
('eventually','Tagged for eventually'),
('_spec.SPACER',''),
('low','Tagged as LOW'),
('verylow','Tagged as Very LOW'),
('_spec.SPACER',''),
('ref','Tagged as ref'),
('_spec.SPACER',''),
('done','Tagged as Done'),
('_spec.SPACER',''),
('defer','Tagged as defer'),
('_spec.SPACER',''),
('nixed','Tagged as nixed') ]
def genTodos(wikidPad, wikiWord):
""" Dynamically generates list of Todos (or other keywords) on openedWikiWord,
.. where wikiWord is of the form ToDoSEARCHSTRING (SEARCHSTRING can be any text that you are looking for).
Displays all todos containing 'todo' and the value of SEARCHSTRING.
The Generated display is seperated into categories determined by the presence of Tags in the todo text.
These Tags can be defined and ordered in the TAGS LIST above.
"""
srchstr = wikiWord[4:]
bOnlyNotag = False
if srchstr[:5] == 'NOTAG':
bOnlyNotag = True
srchstr = 'todo'
todosFull = wikidPad.wikiData.getTodos()
todos = [todo for todo in todosFull if ('todo' in todo[1].split(':')[0] and srchstr in todo[1].split(':')[0])]
editor = wikidPad.editor
editor.GotoLine(1)
editor.SetSelectionEnd(editor.GetLength())
editor.ReplaceSelection("")
tagAdded = True
for tag in tags:
wroteHeader = False
if tag[0] == '_spec.SPACER' and tagAdded:
editor.AddText('\n' + ('-'*70) + '\n')
tagAdded = False
elif tag[0] == '_spec.NOTAGS':
for todo in todos:
foundTag = False
for t in tags:
if t[0] in todo[1].split(':')[0]:
foundTag = True
break
if not foundTag and todo[0] != 'DEL':
if not wroteHeader:
editor.AddText('\n++ ' + tag[1] + ' :\n')
wroteHeader = True
editor.AddText(' * '+ str(todo[1])+'\n')
todos[todos.index(todo)] = ('DEL','DEL') tagAdded = True
elif not bOnlyNotag:
for todo in todos:
if (tag[0] in todo[1].split(':')[0]):
if not wroteHeader:
editor.AddText('\n++ ' + tag[1] + ' :\n')
wroteHeader = True
editor.AddText(' * '+ str(todo[1])+'\n')
todos[todos.index(todo)] = ('DEL','DEL') tagAdded = True