from os.path import join
def plugin_init():
return ['openedWikiWord',openedWikiWord_todo]
def openedWikiWord_todo(wikidPad, wikiWord):
if wikiWord[:4].upper() != "TODO":
return
tags = [('High','Tagged HIGH !'),
('_spec.SPACER',''),
('Next','Next Actions'),
('ThisWeek','Tagged for This Week'),
('_spec.SPACER',''),
('SomeDay','SomeDay / Maybe'),
('_spec.SPACER',''),
('TimeToTime','Tagged for from time to time'),
('_spec.SPACER',''),
('Low','Tagged as LOW'),
('_spec.SPACER',''),
('VeryLow','Tagged as Very LOW')]
tagEnd = [
('_spec.SPACER',''),
('_spec.NOTAGS','Untagged Todos')]
srchstr = wikiWord[4:]
todosFull = wikidPad.wikiData.getTodos()
todos = [todo for todo in todosFull if ('todo' in todo[1]) ]
editor = wikidPad.getActiveEditor()
st = editor.FindText(0, editor.GetLength(), "++ auto-harvested todos:", 0)
st = editor.PositionFromLine(1+editor.LineFromPosition(st))
editor.SetSelection(st, editor.GetLength())
editor.ReplaceSelection("\n")
tagAdded = True checkTags = [tag[0] for tag in tags]
for todo in todos:
allTodo = todo[1].split(":")
words = allTodo[0].split(".")
for word in words[1:]:
if not word in checkTags:
tags.append( (word,"Tagged "+word) )
tags.append( ("_spec.SPACER","") )
checkTags.append(word)
tags = tags + tagEnd
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:
if (tag[0] in todo[1]):
if not wroteHeader:
editor.AddText('\n++ ' + tag[1] + ' :\n')
wroteHeader = True
s = str(todo[1])
editor.AddText(' * '+ str(todo[0]) + ': '+ s[s.find(':')+1:] + '\n')
todos[todos.index(todo)] = ('DEL','DEL') tagAdded = True
else:
for todo in todos:
foundTag = False
for t in tags:
if t[0] in todo[1]:
foundTag = True
break
if not foundTag and todo[0] != 'DEL':
if not wroteHeader:
editor.AddText('\n++ ' + tag[1] + ' :\n')
wroteHeader = True
s = str(todo[1])
editor.AddText(' * '+ str(todo[0]) + ': '+ s[s.find(':')+1:] + '\n')
todos[todos.index(todo)] = ('DEL','DEL') tagAdded = True