Attachment 'MoveEditedSystemPages.py'

Download

   1 #! env python2.3
   2 # -*- coding: UTF-8 -*-
   3 
   4 """
   5 EditedSystemPages - list system pages that has been edited in this wiki.
   6 
   7 @copyright: 2004 Nir Soffer <nirs@freeshell.org>
   8 @license: GNU GPL, see COPYING for details.
   9 """
  10 
  11 import os.path, sys, shutil, urllib
  12 
  13 from MoinMoin import wikiutil
  14 from MoinMoin.wikiutil import unquoteWikiname
  15 from MoinMoin.Page import Page
  16 from MoinMoin.request import RequestCLI
  17 from migutil import opj, listdir, move_file
  18 
  19 wikipath = '.'
  20 sys.path.append(wikipath);
  21 
  22 dir_from = 'data'
  23 dir_to   = 'underlay.backup'
  24 
  25 os.mkdir(dir_to)
  26 
  27 def renderInPage(request):
  28     """
  29     """        
  30     # Get page list for current user (use this as admin), filter
  31     # pages that are both underlay and standard pages.
  32     pages = request.rootpage.getPageList()
  33     print "f"
  34     for name in pages:
  35 	    print ":" + name
  36     pages = [name for name in pages
  37              if pages[name].isStandardPage(includeDeleted=0) and
  38                  pages[name].isUnderlayPage(includeDeleted=0) or 1]
  39       
  40     # Format as numberd list, sorted by page name         
  41     pages.sort()
  42     for name in pages:
  43 	    print name ,
  44     return ''
  45 
  46 def check_page(page):
  47     """
  48     """
  49     if page.isUnderlayPage(includeDeleted=0) and page.isStandardPage(includeDeleted=0):
  50         rev_count = len(page.getRevList())
  51 	if (rev_count > 1):
  52             print page.page_name.encode('utf-8') + ": ",
  53             if page.isUnderlayPage(includeDeleted=0):
  54                 print "U",
  55             if page.isStandardPage(includeDeleted=0):
  56 	        print "S",
  57 	    print "revs: ", rev_count,
  58             print
  59 	    # skip those pages
  60             safe = 0
  61     	else:
  62 	    # page has only one revision and is both a standard and underlay page
  63 	    safe = 1
  64     else:
  65         # don't remove non-underlay or underlay-only pages
  66     	safe = 0
  67     return safe
  68 
  69 #request = RequestCLI('FrontPage')
  70 print "pages with more than one revision, skipped:"
  71 request = RequestCLI('FrontPage')
  72 
  73 for fname in listdir(dir_from + "/pages"):
  74     page = Page(request, unquoteWikiname(fname))
  75     if check_page(page):
  76     	move_file(dir_from + "/pages/" + fname, dir_to + "/" + fname)
  77 
  78 #renderInPage(request)

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] (2004-11-25 03:50:01, 2.1 KB) [[attachment:MoveEditedSystemPages.py]]
 All files | Selected Files: delete move to page copy to page

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