Attachment 'todo.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - Parser for TODO lists
   4 
   5     @version: 0.2
   6     @copyright: 2005 by Julián Romero <julian.romero@gmail.com>
   7     @license: GNU GPL
   8 
   9     Usage:
  10 
  11     {{{#!todo
  12     < > pending task
  13     </> task in progress
  14     <x> task done
  15     <~> task can be considered done
  16     <!> task cancelled
  17     }}}
  18 
  19     Optional: add some styling
  20 
  21     [[CSS(TodoStyle)]]
  22 
  23 """
  24 
  25 import re
  26 
  27 Dependencies = []
  28 
  29 class Parser:
  30     """ Format TODO lists
  31     """
  32 
  33     Dependencies = []
  34     img_base = "/chrome/todo"
  35     img_ext  = "png"
  36 
  37     def __init__(self, raw, request, **kw):
  38         """ Store the source text.
  39         """
  40         self.raw = raw
  41         self.request = request
  42         self.form = request.form
  43         self._ = request.getText
  44         self.items = { 'x': 'done', 'X':'done','~':'pass','!':'cancel', '/':'progress', ' ':'pending' }
  45 
  46     def format(self, formatter):
  47         """ Parse and send the list
  48         """
  49 
  50 
  51         status_re = re.compile( r'^\s*<([ xX!\/~])>([ \d\-\/\.\:]*) (.+)$' )
  52         date_re   = re.compile( r'.*(\d{4}[\-\/]\d{2}[\-\/]\d{2})' )
  53         time_re   = re.compile( r'.*(\d{2}[\.\:]\d{2})' )
  54 
  55         lines = self.raw.split('\n')
  56 
  57         self.request.write(formatter.span(True,attr={'class':'todo-item'}))
  58         for line in lines:
  59 
  60             todo_status = None
  61             todo_date = None
  62             todo_time = None
  63             todo_line = None
  64             todo_date_out = ''
  65             todo_time_out = ''
  66 
  67             ms = status_re.match(line)
  68             if ms:
  69                 todo_status = ms.group(1)
  70                 todo_line = ms.group(3)
  71                 md = date_re.match(line)
  72                 if md:
  73                     todo_date = md.group(1)
  74                 mt = time_re.match(line)
  75                 if mt:
  76                     todo_time = mt.group(1)
  77                 if todo_date:
  78                     todo_date_out = '<span class="todo-date">%s</span>' % todo_date
  79                 if todo_time:
  80                     todo_time_out = '<span class="todo-hour">%s</span>' % todo_time
  81 		self.request.write( '<div class="todo"><div class="todo-%s"><img class="todo" src="%s/todo-%s.%s" border="0">%s %s <span class="todo-%s">%s</span></div></div>\n' % (self.items[todo_status],self.img_base,self.items[todo_status],self.img_ext,todo_date_out,todo_time_out,self.items[todo_status],todo_line) )
  82             else:
  83                 self.request.write(formatter.span(True, attr={'class':'todo-comment'}) )
  84                 self.request.write(line)
  85                 self.request.write(formatter.span(False))
  86         self.request.write(formatter.span(False))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2005-12-10 02:54:33, 2.1 KB) [[attachment:CSV.py]]
  • [get | view] (2006-10-10 10:42:36, 1.1 KB) [[attachment:box.py]]
  • [get | view] (2005-11-21 02:56:09, 0.5 KB) [[attachment:css-action.py]]
  • [get | view] (2005-11-21 02:56:33, 0.8 KB) [[attachment:css-macro.py]]
  • [get | view] (2005-11-13 12:21:38, 0.9 KB) [[attachment:patch-1.5b2-Form.py]]
  • [get | view] (2005-11-13 12:13:19, 0.8 KB) [[attachment:patch-1.5b2-wikiform.py]]
  • [get | view] (2006-05-12 12:59:21, 2.6 KB) [[attachment:todo.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.