Attachment 'LostSoulsInGroups.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - LostSoulsInGroups macro 
   4     
   5     Find users in custom groups who don't have user accounts 
   6     (either haven't registered yet or have been deleted or there's a typo)
   7     
   8     Copyright (c) 2007 by Alexander "Loki" Agibalov
   9 
  10 """
  11 
  12 from MoinMoin import wikiutil, user
  13 from MoinMoin.Page import Page
  14 from MoinMoin.PageEditor import PageEditor
  15 import re, sys
  16 
  17 def makeStr(lst):
  18     st=""
  19     for l in lst:
  20         if len(st)>1:
  21             st=st+", "
  22         st=st+l
  23     return st
  24 
  25 def execute(macro, args):
  26     request=macro.request
  27     _=macro.request.getText
  28     sRet="<p><b>Users in custom groups who don't have user accounts</b></p>"
  29     sRet=sRet+"<table>"
  30     userlist=[]
  31     lostsouls={}
  32     for uid in user.getUserList(request):
  33         userlist.append(user.User(request, uid).name)
  34         
  35     GrpPages = request.rootpage.getPageList(filter=re.compile("(?!SystemPages|AutoAdmin).*Group$").match)
  36     srch=re.compile("^ \* [^ ]*", re.M)
  37     for pg in GrpPages:
  38         pged = PageEditor(request, pg)
  39         pagelines = pged.getlines()
  40         for lin in pagelines:
  41             srchS=srch.match(lin)
  42             if srchS:
  43                 st=srchS.group()
  44                 st=st[3:]
  45                 try:
  46                     usr=userlist.index(st)
  47                 except:
  48                     if lostsouls.has_key(pg):
  49                         temp_lst=lostsouls[pg]
  50                         temp_lst.append(st)
  51                         lostsouls[pg]=temp_lst
  52                     else:
  53                         lostsouls[pg]=[st]
  54     for k, v in lostsouls.iteritems():
  55         st='<tr><td>%s</td><td>%s</td></tr>' % (Page(request, k).link_to(request), makeStr(v))
  56         sRet=sRet+st
  57     
  58     sRet=sRet+"</table>"
  59     
  60     return macro.formatter.rawHTML(sRet)

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-07-11 12:43:54, 1.1 KB) [[attachment:AllPagesWithACL.py]]
  • [get | view] (2007-07-11 12:45:09, 1.8 KB) [[attachment:LostSoulsInGroups.py]]
  • [get | view] (2007-04-13 10:05:04, 1.1 KB) [[attachment:MacroMarket-AllPagesWithACL.py]]
  • [get | view] (2007-04-24 07:25:22, 3.6 KB) [[attachment:MacroMarket-ManageUsers.py]]
  • [get | view] (2007-05-03 10:22:47, 2.4 KB) [[attachment:MacroMarket-WikiLog.py]]
  • [get | view] (2007-07-11 12:44:58, 3.6 KB) [[attachment:ManageUsers.py]]
  • [get | view] (2007-07-11 12:44:50, 2.4 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.