Attachment 'MyRating-1.0.py'

Download

   1 """
   2     This macro displays a rating
   3     <<MyRating()>>
   4     <<MyRating(2)>>
   5     <<MyRating(2,5)>>
   6     <<MyRating(6,10)>>
   7     <<MyRating(6,10,<!>)
   8     <<MyRating(6,10,X-(,:-))
   9 """
  10 
  11 from MoinMoin import wikiutil
  12 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
  13 
  14 def macro_MyRating(macro,rating=0,scale=5,empty=u'{o}',full=u'{*}'):
  15 
  16     f = macro.formatter
  17     _ = macro.request.getText
  18 
  19     text = ( full + ' ' ) * rating
  20     text += ( empty + ' ' ) * ( scale - rating)
  21     text = wikiutil.renderText(macro.request, WikiParser, text)
  22     #text = text.strip()
  23 
  24     return text

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] (2014-04-02 16:39:54, 0.6 KB) [[attachment:MyRating-1.0.py]]
 All files | Selected Files: delete move to page copy to page

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