Attachment 'LostSoulsInGroups.py'

Download

   1 # -*- coding: utf-8 -*-
   2 """
   3     MoinMoin - LostSoulsInGroups macro
   4 
   5     List all items in custom groups that do not have user accounts
   6     (either haven't registered yet or have been deleted or there's a typo)
   7 
   8     @copyright: 2007 Alexander "Loki" Agibalov
   9     @license: GNU GPL, see COPYING for details.
  10 
  11     changes:
  12         12.2007 - conversion to new syntax by Bolesław Kulbabiński
  13 """
  14 
  15 from MoinMoin import wikiutil, user
  16 from MoinMoin.Page import Page
  17 from MoinMoin.PageEditor import PageEditor
  18 import re, sys
  19 
  20 def macro_LostSoulsInGroups(macro, args):
  21     request = macro.request
  22     _ = macro.request.getText
  23 
  24     sRet = "<p><b>Items in custom groups (Users in custom groups who don't have user accounts)</b></p>"
  25     sRet = sRet + "<table>"
  26     userlist = []
  27     lostsouls = {}
  28     for uid in user.getUserList(request):
  29         userlist.append(user.User(request, uid).name)
  30 
  31     isgroup = request.cfg.cache.page_group_regex.search
  32     grouppages = request.rootpage.getPageList(user='', filter=isgroup)
  33 
  34     srch = re.compile("^ \* [^ ]*", re.M)
  35     for pg in grouppages:
  36         pged = PageEditor(request, pg)
  37         pagelines = pged.getlines()
  38         for lin in pagelines:
  39             srchS = srch.match(lin)
  40             if srchS:
  41                 st = srchS.group()
  42                 st = st[3:]
  43                 try:
  44                     usr = userlist.index(st)
  45                 except ValueError:
  46                     if lostsouls.has_key(pg):
  47                         temp_lst = lostsouls[pg]
  48                         temp_lst.append(st)
  49                         lostsouls[pg] = temp_lst
  50                     else:
  51                         lostsouls[pg] = [st]
  52 
  53     for k, v in lostsouls.iteritems():
  54         st = '<tr><td>%s</td><td>%s</td></tr>' % (Page(request, k).link_to(request), ", ".join(v))
  55         sRet = sRet + st
  56 
  57     sRet = sRet + "</table>"
  58     return macro.formatter.rawHTML(sRet)
  59 
  60 
  61 def execute(macro, args):
  62     try:
  63         return wikiutil.invoke_extension_function(
  64                    macro.request, macro_LostSoulsInGroups, args, [macro])
  65     except ValueError, err:
  66         return macro.request.formatter.text(
  67                    "<<LostSoulsInGroups: %s>>" % err.args[0])

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] (2007-12-22 23:47:40, 1.4 KB) [[attachment:AllPagesWithACL.py]]
  • [get | view] (2007-12-22 23:26:11, 2.2 KB) [[attachment:LostSoulsInGroups.py]]
  • [get | view] (2007-12-22 23:47:25, 3.9 KB) [[attachment:ManageUsers.py]]
  • [get | view] (2008-11-01 08:08:30, 3.0 KB) [[attachment:WikiLog.py]]
 All files | Selected Files: delete move to page copy to page

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