changeset 504:67d5daa9e872

moin maint reducewiki imported from: moin--main--1.5--patch-508
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 26 Mar 2006 13:30:19 +0000
parents 1c46c48ca67e
children c6ab1f202891
files ChangeLog Makefile MoinMoin/script/maint/__init__.py MoinMoin/script/maint/reducewiki.py MoinMoin/script/old/reducewiki/__init__.py MoinMoin/script/old/reducewiki/reducewiki.py wiki/underlay.tar.bz2
diffstat 7 files changed, 129 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 26 12:49:07 2006 +0000
+++ b/ChangeLog	Sun Mar 26 13:30:19 2006 +0000
@@ -2,6 +2,40 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-26 14:30:19 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-508
+
+    Summary:
+      moin maint reducewiki
+    Revision:
+      moin--main--1.5--patch-508
+
+    moin maint reducewiki
+    
+
+    new files:
+     MoinMoin/script/maint/.arch-ids/__init__.py.id
+     MoinMoin/script/maint/__init__.py
+
+    removed files:
+     MoinMoin/script/old/reducewiki/.arch-ids/=id
+     MoinMoin/script/old/reducewiki/.arch-ids/__init__.py.id
+     MoinMoin/script/old/reducewiki/__init__.py
+
+    modified files:
+     ChangeLog Makefile MoinMoin/script/maint/reducewiki.py
+     wiki/underlay.tar.bz2
+
+    renamed files:
+     MoinMoin/script/old/reducewiki/.arch-ids/reducewiki.py.id
+       ==> MoinMoin/script/maint/.arch-ids/reducewiki.py.id
+     MoinMoin/script/old/reducewiki/reducewiki.py
+       ==> MoinMoin/script/maint/reducewiki.py
+
+    removed directories:
+     MoinMoin/script/old/reducewiki
+     MoinMoin/script/old/reducewiki/.arch-ids
+
+
 2006-03-26 13:49:07 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-507
 
     Summary:
--- a/Makefile	Sun Mar 26 12:49:07 2006 +0000
+++ b/Makefile	Sun Mar 26 13:30:19 2006 +0000
@@ -39,8 +39,8 @@
 # Create new underlay directory from MoinMaster
 # Should be used only on TW machine
 underlay:
-	cd $(share) ; rm -rf underlay
-	cd $(share) ; PYTHONPATH=.. ../MoinMoin/scripts/reducewiki/reducewiki.py
+	rm -rf $(share)/underlay
+	MoinMoin/script/moin.py --config-dir=/srv/de.wikiwikiweb.moinmaster/bin15 --wiki-url=moinmaster.wikiwikiweb.de/ maint reducewiki --target-dir=$(share)/underlay
 	rm -rf $(share)/underlay/pages/InterWikiMap/
 	echo -ne "#acl All:read\r\nSee MoinMoin:EditingOnMoinMaster.\r\n" > \
 	    $(share)/underlay/pages/MoinPagesEditorGroup/revisions/00000001
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/script/maint/__init__.py	Sun Mar 26 13:30:19 2006 +0000
@@ -0,0 +1,14 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Maintenance Script Package
+
+    @copyright: 2006 by Thomas Waldmann
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin.util import pysupport
+
+# create a list of extension scripts from the subpackage directory
+maint_scripts = pysupport.getPackageModules(__file__)
+modules = maint_scripts
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/script/maint/reducewiki.py	Sun Mar 26 13:30:19 2006 +0000
@@ -0,0 +1,79 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - reducewiki script
+    
+    Use this script to reduce a data/ directory to the latest page revision of
+    each non-deleted page (plus all attachments).
+    
+    This is used to make the distributed underlay directory, but can also be
+    used for other purposes.
+
+    Usage: moin ... maint reducewiki --target-dir=myunderlay
+    
+    So we change like this:      
+        * data/pages/PageName/revisions/{1,2,3,4}
+          -> data/pages/revisions/1  (with content of 4)
+        * data/pages/PageName/current (pointing to e.g. 4)
+          -> same (pointing to 1)
+        * data/pages/PageName/edit-log and data/edit-log
+          -> do not copy
+        * data/pages/PageName/attachments/*
+          -> just copy
+
+    @copyright: 2005-2006 by MoinMoin:ThomasWaldmann
+    @license: GPL, see COPYING for details
+"""
+
+import os, sys, shutil, codecs
+
+from MoinMoin import config, wikiutil
+from MoinMoin.Page import Page
+from MoinMoin.action import AttachFile
+
+from MoinMoin.script._util import MoinScript
+
+class PluginScript(MoinScript):
+    def __init__(self, argv, def_values):
+        MoinScript.__init__(self, argv, def_values)
+        self.parser.add_option(
+            "-t", "--target-dir", dest="target_dir",
+            help="Write reduced wiki data to DIRECTORY."
+        )
+
+    def copypage(self, request, rootdir, pagename):
+        """ quick and dirty! """
+        pagedir = os.path.join(rootdir, 'pages', wikiutil.quoteWikinameFS(pagename))
+        os.makedirs(pagedir)
+        
+        # writte a "current" file with content "00000001"
+        revstr = '%08d' % 1
+        cf = os.path.join(pagedir, 'current')
+        file(cf, 'w').write(revstr+'\n')
+        
+        # create a single revision 00000001
+        revdir = os.path.join(pagedir, 'revisions')
+        os.makedirs(revdir)
+        tf = os.path.join(revdir, revstr)
+        p = Page(request, pagename)
+        text = p.get_raw_body().replace("\n","\r\n")
+        codecs.open(tf, 'wb', config.charset).write(text)
+
+        source_dir = AttachFile.getAttachDir(request, pagename)
+        if os.path.exists(source_dir):
+            dest_dir = os.path.join(pagedir, "attachments")
+            os.makedirs(dest_dir)
+            for filename in os.listdir(source_dir):
+                source_file = os.path.join(source_dir, filename)
+                dest_file = os.path.join(dest_dir, filename)
+                shutil.copyfile(source_file, dest_file)
+
+    def mainloop(self):
+        self.init_request()
+        request = self.request
+        request.form = request.args = request.setup_args()
+        destdir = self.options.target_dir
+        pagelist = list(request.rootpage.getPageList(user=''))
+        for pagename in pagelist:
+            self.copypage(request, destdir, pagename)
+        
+
--- a/MoinMoin/script/old/reducewiki/__init__.py	Sun Mar 26 12:49:07 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-"""
-    MoinMoin - reduce a wiki to the latest revision of each page
-
-    @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
-    @license: GNU GPL, see COPYING for details.
-"""
--- a/MoinMoin/script/old/reducewiki/reducewiki.py	Sun Mar 26 12:49:07 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-#!/usr/bin/env python
-"""
-    Use this script to reduce a data/ directory to the latest page revision of
-    each non-deleted page (plus all attachments).
-    
-    This is used to make the distributed underlay directory, but can also be
-    used for other purposes.
-    
-    So we change like this:      
-        * data/pages/PageName/revisions/{1,2,3,4}
-          -> data/pages/revisions/1
-        * data/pages/PageName/current (pointing to e.g. 4)
-          -> same (pointing to 1)
-        * data/pages/PageName/edit-log and data/edit-log
-          -> do not copy
-        * data/pages/PageName/attachments/*
-          -> just copy
-
-    Steps for a successful conversion:
-
-        1. Stop your wiki and make a backup of old data and code
-
-        2. Make a copy of the wiki's "data" directory to your working dir
-
-        3. Run this script from your working dir
-
-        4. If there was no error, you will find:
-            data.pre-reduce - the script renames your data directory copy to that name
-            data - reduced data dir
-
-        5. Verify conversion results (number of pages, ...)
-
-        6. Test it - if something has gone wrong, you still have your backup.
-
-
-    @copyright: 2005 Thomas Waldmann
-    @license: GPL, see COPYING for details
-"""
-
-url = 'moinmaster.wikiwikiweb.de/'
-destdir = 'underlay'
-
-import sys
-sys.path.insert(0, '/org/de.wikiwikiweb.moinmaster/bin15') # farmconfig/wikiconfig location
-sys.path.insert(0, '../../..')
-
-import os, os.path, shutil, codecs
-from MoinMoin import config
-from MoinMoin import wikiutil
-from MoinMoin.request import RequestCLI
-from MoinMoin.Page import Page
-from MoinMoin.PageEditor import PageEditor
-from MoinMoin.action import AttachFile
-
-def copypage(request, rootdir, pagename):
-    """quick and dirty!"""
-    pagedir = os.path.join(rootdir, 'pages', wikiutil.quoteWikinameFS(pagename))
-    os.makedirs(pagedir)
-    
-    revstr = '%08d' % 1
-    cf = os.path.join(pagedir, 'current')
-    open(cf, 'w').write(revstr+'\n')
-    
-    revdir = os.path.join(pagedir, 'revisions')
-    os.makedirs(revdir)
-    tf = os.path.join(revdir, revstr)
-    p = Page(request, pagename)
-    text = p.get_raw_body().replace("\n","\r\n")
-    codecs.open(tf, 'wb', config.charset).write(text)
-
-    source_dir = AttachFile.getAttachDir(request, pagename)
-    if os.path.exists(source_dir):
-        dest_dir = os.path.join(pagedir, "attachments")
-        os.makedirs(dest_dir)
-        for filename in os.listdir(source_dir):
-            source_file = os.path.join(source_dir, filename)
-            dest_file = os.path.join(dest_dir, filename)
-            shutil.copyfile(source_file, dest_file)
-
-def run():
-    request = RequestCLI(url=url)
-    request.form = request.args = request.setup_args()
-
-    pagelist = list(request.rootpage.getPageList(user=''))
-    for pagename in pagelist:
-        copypage(request, destdir, pagename)
-        
-
-if __name__ == "__main__":
-    run()
-
Binary file wiki/underlay.tar.bz2 has changed