changeset 491:be33ecd58d4e

add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc imported from: moin--main--1.5--patch-495
author Thomas Waldmann <tw@waldmann-edv.de>
date Wed, 22 Mar 2006 09:55:32 +0000
parents ca35d9e6d63e
children 9b77d2a84685
files ChangeLog Makefile MoinMoin/__init__.py MoinMoin/i18n/build_lang_py MoinMoin/i18n/build_meta_py MoinMoin/i18n/linkpo2wiki.py MoinMoin/i18n/po2wiki.py MoinMoin/i18n/prepend.py MoinMoin/i18n/recode.py MoinMoin/i18n/wiki2po.py MoinMoin/scripts/cachecleaner.py MoinMoin/scripts/import/IrcLogImporter.py MoinMoin/scripts/packages/create_pagepacks.py MoinMoin/scripts/pagescleaner.py MoinMoin/scripts/print_stats.py MoinMoin/scripts/reducewiki/reducewiki.py MoinMoin/scripts/xmlrpc-tools/HelloWorld.py MoinMoin/scripts/xmlrpc-tools/UpdateGroupTest.py MoinMoin/scripts/xmlrpc-tools/WhoAmI.py MoinMoin/scripts/xmlrpc-tools/get_es_pages.py MoinMoin/scripts/xmlrpc-tools/getmasterpages2.py MoinMoin/scripts/xmlrpc-tools/getsystempages.py MoinMoin/scripts/xmlrpc-tools/getsystempages2.py MoinMoin/scripts/xmlrpc-tools/putPageTest.py MoinMoin/scripts/xmlrpc-tools/wikibackup.py MoinMoin/scripts/xmlrpc-tools/wikirestore.py MoinMoin/version.py
diffstat 27 files changed, 488 insertions(+), 384 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 22 09:03:08 2006 +0000
+++ b/ChangeLog	Wed Mar 22 09:55:32 2006 +0000
@@ -2,6 +2,44 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-22 10:55:32 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-495
+
+    Summary:
+      add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
+    Revision:
+      moin--main--1.5--patch-495
+
+    add run() methods to scripts, include version info into MoinMoin/__init__.py for epydoc
+    
+
+    removed files:
+     MoinMoin/i18n/.arch-ids/linkpo2wiki.py.id
+     MoinMoin/i18n/linkpo2wiki.py
+
+    modified files:
+     ChangeLog Makefile MoinMoin/__init__.py
+     MoinMoin/i18n/build_lang_py MoinMoin/i18n/build_meta_py
+     MoinMoin/i18n/po2wiki.py MoinMoin/i18n/prepend.py
+     MoinMoin/i18n/recode.py MoinMoin/i18n/wiki2po.py
+     MoinMoin/scripts/cachecleaner.py
+     MoinMoin/scripts/import/IrcLogImporter.py
+     MoinMoin/scripts/packages/create_pagepacks.py
+     MoinMoin/scripts/pagescleaner.py
+     MoinMoin/scripts/print_stats.py
+     MoinMoin/scripts/reducewiki/reducewiki.py
+     MoinMoin/scripts/xmlrpc-tools/HelloWorld.py
+     MoinMoin/scripts/xmlrpc-tools/UpdateGroupTest.py
+     MoinMoin/scripts/xmlrpc-tools/WhoAmI.py
+     MoinMoin/scripts/xmlrpc-tools/get_es_pages.py
+     MoinMoin/scripts/xmlrpc-tools/getmasterpages2.py
+     MoinMoin/scripts/xmlrpc-tools/getsystempages.py
+     MoinMoin/scripts/xmlrpc-tools/getsystempages2.py
+     MoinMoin/scripts/xmlrpc-tools/putPageTest.py
+     MoinMoin/scripts/xmlrpc-tools/wikibackup.py
+     MoinMoin/scripts/xmlrpc-tools/wikirestore.py
+     MoinMoin/version.py
+
+
 2006-03-22 10:03:08 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-494
 
     Summary:
--- a/Makefile	Wed Mar 22 09:03:08 2006 +0000
+++ b/Makefile	Wed Mar 22 09:55:32 2006 +0000
@@ -32,7 +32,8 @@
 	@python -c 'import tabnanny ; tabnanny.check("MoinMoin")'
 
 # Create documentation
-epydoc:
+epydoc: patchlevel
+	@MoinMoin/version.py update
 	@epydoc -o ../html -n MoinMoin -u http://moinmoin.wikiwikiweb.de MoinMoin
 
 # Create new underlay directory from MoinMaster
--- a/MoinMoin/__init__.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/__init__.py	Wed Mar 22 09:55:32 2006 +0000
@@ -1,8 +1,10 @@
 # -*- coding: iso-8859-1 -*-
 """
-    MoinMoin - Package Initialization
+MoinMoin Version 1.5.2 patch-494
 
-    @copyright: 2000-2006 by Jrgen Hermann <jh@web.de>
-    @license: GNU GPL, see COPYING for details.
+@copyright: 2000-2006 by Jrgen Hermann <jh@web.de>
+@license: GNU GPL, see COPYING for details.
 """
 
+
+
--- a/MoinMoin/i18n/build_lang_py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/i18n/build_lang_py	Wed Mar 22 09:55:32 2006 +0000
@@ -142,15 +142,19 @@
 
   outfile.write('}\n')
 
-for i in sys.argv[1:]:
-  lang = i
-  infilename = "%s.po" % lang
-  outfilename = "%s.py" % lang
-  infile = file(infilename, "r")
-  outfile = file(outfilename, "w")
-  try:
-    do(lang, infile, outfile)
-  except:
-    os.unlink(outfilename)
-    raise
+def run():
+    for i in sys.argv[1:]:
+      lang = i
+      infilename = "%s.po" % lang
+      outfilename = "%s.py" % lang
+      infile = file(infilename, "r")
+      outfile = file(outfilename, "w")
+      try:
+        do(lang, infile, outfile)
+      except:
+        os.unlink(outfilename)
+        raise
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/i18n/build_meta_py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/i18n/build_meta_py	Wed Mar 22 09:55:32 2006 +0000
@@ -1,13 +1,13 @@
 #!/usr/bin/env python
+def run():
+    import sys
+    sys.path.insert(0, '../..')
+    from MoinMoin.util import pysupport
 
-import sys
-sys.path.insert(0, '../..')
-from MoinMoin.util import pysupport
+    outfile = file("meta.py", "w")
+    outwiki = file("meta.wiki", "w")
 
-outfile = file("meta.py", "w")
-outwiki = file("meta.wiki", "w")
-
-outfile.write('''# -*- coding: utf-8 -*-
+    outfile.write('''# -*- coding: utf-8 -*-
 """ This file contains meta information about available languages, so MoinMoin
     does not need to load all language files to collect those informations.
     
@@ -17,42 +17,44 @@
 languages = {
 ''')
 
-# Create python dictionary of known languages
-for lang in sys.argv[1:]:
-    print "Processing %s ..." % lang
-    try:
-        meta = pysupport.importName(lang, "meta")
-    except:
-        print "Exception caught while importing %s!" % lang
-        continue
-
-    # Encode direction to binary, this will be decoded later by
-    # i18n.getDirection.
-    # TODO: refactor this to save the direction as simple string
-    if meta['direction'] == 'ltr':
-        dir = 0
-    else:
-        dir = 1
+    # Create python dictionary of known languages
+    for lang in sys.argv[1:]:
+        print "Processing %s ..." % lang
+        try:
+            meta = pysupport.importName(lang, "meta")
+        except:
+            print "Exception caught while importing %s!" % lang
+            continue
 
-    # Translate file name to iso language name. iso names are xx[-xx],
-    # but since each langauge is a python module, we use xx[_xx]
-    lang = lang.replace('_', '-')
+        # Encode direction to binary, this will be decoded later by
+        # i18n.getDirection.
+        # TODO: refactor this to save the direction as simple string
+        if meta['direction'] == 'ltr':
+            dir = 0
+        else:
+            dir = 1
 
-    # decode the language (as it is in file encoding still)
-    language = meta['language'].decode(meta['encoding'])
-    elanguage = meta['elanguage'].decode(meta['encoding'])
-    
-    meta.update(locals())
+        # Translate file name to iso language name. iso names are xx[-xx],
+        # but since each langauge is a python module, we use xx[_xx]
+        lang = lang.replace('_', '-')
 
-    outf = u''''%(lang)s': (u'%(language)s', u'%(elanguage)s', '%(encoding)s', %(dir)d, """%(maintainer)s""",),\n''' % meta
-    outw = u'''|| %(lang)s || %(language)s || TODO || %(maintainer)s ||\n''' % meta
-    
-    outfile.write(outf.encode('utf-8'))
-    outwiki.write(outw.encode('utf-8'))
-    del meta
+        # decode the language (as it is in file encoding still)
+        language = meta['language'].decode(meta['encoding'])
+        elanguage = meta['elanguage'].decode(meta['encoding'])
+        
+        meta.update(locals())
 
-outfile.write("""}
+        outf = u''''%(lang)s': (u'%(language)s', u'%(elanguage)s', '%(encoding)s', %(dir)d, """%(maintainer)s""",),\n''' % meta
+        outw = u'''|| %(lang)s || %(language)s || TODO || %(maintainer)s ||\n''' % meta
+        
+        outfile.write(outf.encode('utf-8'))
+        outwiki.write(outw.encode('utf-8'))
+        del meta
+
+    outfile.write("""}
 # EOF
 """)
 
+if __name__ == "__main__":
+    run()
 
--- a/MoinMoin/i18n/linkpo2wiki.py	Wed Mar 22 09:03:08 2006 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#!/usr/bin/env python
-"""
-   links the .po files to the current versions in the wiki.
-   should be done before updating them with new strings
-"""
-
-import sys, os
-sys.path.insert(0, '../..')
-from MoinMoin import wikiutil
-
-langs = 'da de es fi fr hu it ja ko nb nl pl ru sr vi zh zh-tw'.split()
-broken_langs = 'hr pt sv'.split()
-nonwiki_langs = 'he en'
-
-data_dir = '/org/de.wikiwikiweb.moinmaster/data'
-
-for lang in langs + broken_langs:
-    langdir = os.path.join(data_dir, 'pages', wikiutil.quoteWikinameFS('MoinI18n/%s' % lang))
-    pofn = lang.replace('-', '_') + '.po'
-    if lang in broken_langs:
-        langdir += '(2d)FIXME'
-        pofn += '_'
-    currentfn = os.path.join(langdir, 'current')
-    current = open(currentfn, 'r').read().strip()
-    wikifn = os.path.join(langdir, 'revisions', current)
-    if os.path.exists(pofn):
-        os.remove(pofn)
-    os.symlink(wikifn, pofn)
-    print "ln -s %s %s" % (wikifn, pofn)
-
--- a/MoinMoin/i18n/po2wiki.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/i18n/po2wiki.py	Wed Mar 22 09:55:32 2006 +0000
@@ -4,28 +4,29 @@
     prepend some processing instructions to a .po file to be able to put it
     onto moinmaster wiki, letting it get processed by gettext parser
 """
-import sys, os, xmlrpclib
-sys.path.insert(0, '../..')
-
-excluded = ["en",] # languages managed in tla repository, not in wiki
-
-lang = sys.argv[1]
-lang = lang.replace('_', '-') # module names use _ instead of -
-
-data = sys.stdin.read()
+def run():
+    import sys, os, xmlrpclib
+    sys.path.insert(0, '../..')
 
-if lang in excluded:
-    f = open("%s.po" % lang, "w")
-    f.write(data)
-    f.close()
-    sys.exit(0)
-    
-data = data.decode('utf-8')
+    excluded = ["en",] # languages managed in tla repository, not in wiki
 
-cutpos = data.index(u"msgid")
-data = data[cutpos:] # remove comments at top
+    lang = sys.argv[1]
+    lang = lang.replace('_', '-') # module names use _ instead of -
 
-data = u"""\
+    data = sys.stdin.read()
+
+    if lang in excluded:
+        f = open("%s.po" % lang, "w")
+        f.write(data)
+        f.close()
+        sys.exit(0)
+        
+    data = data.decode('utf-8')
+
+    cutpos = data.index(u"msgid")
+    data = data[cutpos:] # remove comments at top
+
+    data = u"""\
 ## Please edit system and help pages ONLY in the moinmaster wiki! For more
 ## information, please see MoinMaster:MoinPagesEditorGroup.
 ##master-page:None
@@ -40,16 +41,19 @@
 %s""" % (lang, lang, data)
 
 
-from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
+    from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
 
-user = "ThomasWaldmann" # must be a known Wiki account
-password = os.environ.get("PASS", "")
-pagename = "MoinI18n/%s" % lang
-pagedata = data.encode('utf-8')
+    user = "ThomasWaldmann" # must be a known Wiki account
+    password = os.environ.get("PASS", "")
+    pagename = "MoinI18n/%s" % lang
+    pagedata = data.encode('utf-8')
 
-authtrans = BasicAuthTransport(user, password)
-wiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2", transport=authtrans)
+    authtrans = BasicAuthTransport(user, password)
+    wiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2", transport=authtrans)
 
-rc = wiki.putPage(pagename, pagedata)
-print "Page: %s rc=%s" % (pagename, rc)
+    rc = wiki.putPage(pagename, pagedata)
+    print "Page: %s rc=%s" % (pagename, rc)
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/i18n/prepend.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/i18n/prepend.py	Wed Mar 22 09:55:32 2006 +0000
@@ -5,17 +5,18 @@
 
     for f in *.po; do ./prepend.py $f; done
 """
-import sys, codecs
-fname = sys.argv[1]
+def run():
+    import sys, codecs
+    fname = sys.argv[1]
 
-lang = fname.replace('.po_', '').replace('.po', '')
-lang = lang.replace('_', '-') # module names use _ instead of -
+    lang = fname.replace('.po_', '').replace('.po', '')
+    lang = lang.replace('_', '-') # module names use _ instead of -
 
-f = codecs.open(fname, 'r', 'utf-8')
-data = f.read()
-f.close()
+    f = codecs.open(fname, 'r', 'utf-8')
+    data = f.read()
+    f.close()
 
-data = u"""\
+    data = u"""\
 ## Please edit system and help pages ONLY in the moinmaster wiki! For more
 ## information, please see MoinMaster:MoinPagesEditorGroup.
 ##master-page:None
@@ -26,7 +27,10 @@
 
 %s""" % (lang, data)
 
-f = codecs.open(fname, 'w', 'utf-8')
-f.write(data)
-f.close()
+    f = codecs.open(fname, 'w', 'utf-8')
+    f.write(data)
+    f.close()
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/i18n/recode.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/i18n/recode.py	Wed Mar 22 09:55:32 2006 +0000
@@ -38,20 +38,23 @@
 def error(msg):
     sys.stderr.write(msg + '\n')
     
-
-try:
-    cmd, src_enc, dst_enc = sys.argv
+def run():
+    try:
+        cmd, src_enc, dst_enc = sys.argv
 
-    for line in sys.stdin:
-        line = unicode(line, src_enc).encode(dst_enc)
-        sys.stdout.write(line)
+        for line in sys.stdin:
+            line = unicode(line, src_enc).encode(dst_enc)
+            sys.stdout.write(line)
 
-except UnicodeError, err:
-    error("Can't recode: %s" % str(err))
-except LookupError, err:
-    error(str(err))
-except ValueError:
-    error("Wrong number of arguments")
-    error(__doc__)
+    except UnicodeError, err:
+        error("Can't recode: %s" % str(err))
+    except LookupError, err:
+        error(str(err))
+    except ValueError:
+        error("Wrong number of arguments")
+        error(__doc__)
 
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/i18n/wiki2po.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/i18n/wiki2po.py	Wed Mar 22 09:55:32 2006 +0000
@@ -2,21 +2,25 @@
 """
     get latest translation page content from the wiki and write it to *.po
 """
-import sys, xmlrpclib
-sys.path.insert(0, '../..')
-
-excluded = ["en",] # languages managed in tla repository, not in wiki
-
-langfname = sys.argv[1]
-lang = langfname.replace('_', '-') # module names use _ instead of -
+def run():
+    import sys, xmlrpclib
+    sys.path.insert(0, '../..')
 
-if not lang in excluded:
-    wiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2")
+    excluded = ["en",] # languages managed in tla repository, not in wiki
 
-    pagename = "MoinI18n/%s" % lang
-    pagedata = wiki.getPage(pagename).encode('utf-8').replace("\n","\r\n")
+    langfname = sys.argv[1]
+    lang = langfname.replace('_', '-') # module names use _ instead of -
 
-    f = open("%s.po" % langfname, "w")
-    f.write(pagedata)
-    f.close()
+    if not lang in excluded:
+        wiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2")
 
+        pagename = "MoinI18n/%s" % lang
+        pagedata = wiki.getPage(pagename).encode('utf-8').replace("\n","\r\n")
+
+        f = open("%s.po" % langfname, "w")
+        f.write(pagedata)
+        f.close()
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/cachecleaner.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/cachecleaner.py	Wed Mar 22 09:55:32 2006 +0000
@@ -24,16 +24,17 @@
 base = "." # directory containing the data directory
 fnames = ['text_html', 'pagelinks', ] # cache filenames to delete
 
-import sys, os
+def run():
+    import os
+    pagesdir = os.path.join(base, 'data', 'pages')
+    for f in os.listdir(pagesdir):
+        for fname in fnames:
+            cachefile = os.path.join(pagesdir, f, 'cache', fname)
+            try:
+                os.remove(cachefile)
+            except:
+                pass
+    
+if __name__ == '__main__':
+    run()
 
-pagesdir = os.path.join(base, 'data', 'pages')
-for f in os.listdir(pagesdir):
-    for fname in fnames:
-        cachefile = os.path.join(pagesdir, f, 'cache', fname)
-        try:
-            os.remove(cachefile)
-        except:
-            pass
-    
-# EOF
-
--- a/MoinMoin/scripts/import/IrcLogImporter.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/import/IrcLogImporter.py	Wed Mar 22 09:55:32 2006 +0000
@@ -47,23 +47,28 @@
         resultList.append(decoded_line)
     return '\n'.join(resultList)
 
-request = RequestCLI(url=url) #pagename necessary here?
+def run():
+    request = RequestCLI(url=url) #pagename necessary here?
 
-for root, dirs, files in os.walk(local_dir):
-    files.sort()
-    for filename in files[:-1]: # do not push the last file as it is constantly written to
-        pagename = base_page + filename_function(filename)
-        print "Pushing %r as %r" % (filename, pagename)
-        p = PageEditor(request, pagename,
-                       do_editor_backup=0, uid_override=author)
-        if p.exists():
-            continue
-                    
-        fileObj = open(os.path.join(root, filename), 'rb')
-        try:
-            p.saveText("#format plain\n" + decodeLinewise(fileObj.read()), 0)
-        except PageEditor.SaveError, e:
-            print "Got %r" % (e, )
-        fileObj.close()
+    for root, dirs, files in os.walk(local_dir):
+        files.sort()
+        for filename in files[:-1]: # do not push the last file as it is constantly written to
+            pagename = base_page + filename_function(filename)
+            print "Pushing %r as %r" % (filename, pagename)
+            p = PageEditor(request, pagename,
+                           do_editor_backup=0, uid_override=author)
+            if p.exists():
+                continue
+                        
+            fileObj = open(os.path.join(root, filename), 'rb')
+            try:
+                p.saveText("#format plain\n" + decodeLinewise(fileObj.read()), 0)
+            except PageEditor.SaveError, e:
+                print "Got %r" % (e, )
+            fileObj.close()
 
-print "Finished."
+    print "Finished."
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/packages/create_pagepacks.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/packages/create_pagepacks.py	Wed Mar 22 09:55:32 2006 +0000
@@ -173,26 +173,30 @@
             #print "Scheduled %s." % repr(t)
         sleep(1)
 
-request = RequestCLI(url='localhost/')
-request.form = request.args = request.setup_args()
-
-gd = wikidicts.GroupDict(request)
-gd.reset()
-
-#getMasterPages()
-print "Building page sets ..."
-pageSets = buildPageSets()
+def run():
+    request = RequestCLI(url='localhost/')
+    request.form = request.args = request.setup_args()
 
-print "Creating packages ..."
-generate_filename = lambda name: os.path.join('testwiki', 'underlay', 'pages', 'SystemPagesSetup', 'attachments', '%s.zip' % name)
-
-packageCompoundInstaller(pageSets, generate_filename(ALL))
+    gd = wikidicts.GroupDict(request)
+    gd.reset()
 
-[packagePages(list(pages), generate_filename(name), "ReplaceUnderlay") 
-    for name, pages in pageSets.items() if not name in (u'English', ALL, NODIST)]
+    #getMasterPages()
+    print "Building page sets ..."
+    pageSets = buildPageSets()
 
-[removePages(list(pages)) 
-    for name, pages in pageSets.items() if not name in (u'English', ALL)]
+    print "Creating packages ..."
+    generate_filename = lambda name: os.path.join('testwiki', 'underlay', 'pages', 'SystemPagesSetup', 'attachments', '%s.zip' % name)
 
-print "Finished."
+    packageCompoundInstaller(pageSets, generate_filename(ALL))
 
+    [packagePages(list(pages), generate_filename(name), "ReplaceUnderlay") 
+        for name, pages in pageSets.items() if not name in (u'English', ALL, NODIST)]
+
+    [removePages(list(pages)) 
+        for name, pages in pageSets.items() if not name in (u'English', ALL)]
+
+    print "Finished."
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/pagescleaner.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/pagescleaner.py	Wed Mar 22 09:55:32 2006 +0000
@@ -48,15 +48,17 @@
 
     return 'ok'
 
-for p in os.listdir(pagebasedir):
-    pagedir = os.path.join(pagebasedir, p)
-    status = qualify(pagedir)
-    if status in ['trash', 'empty', ]:
-        print "mv '%s' trash # %s" % (pagedir,status)
-    elif status in ['deleted', ]:
-        print "mv '%s' deleted # %s" % (pagedir,status)
-    else:
-        print "# %s: '%s'" % (status, pagedir)
+def run():
+    for p in os.listdir(pagebasedir):
+        pagedir = os.path.join(pagebasedir, p)
+        status = qualify(pagedir)
+        if status in ['trash', 'empty', ]:
+            print "mv '%s' trash # %s" % (pagedir,status)
+        elif status in ['deleted', ]:
+            print "mv '%s' deleted # %s" % (pagedir,status)
+        else:
+            print "# %s: '%s'" % (status, pagedir)
 
-# EOF
+if __name__ == "__main__":
+    run()
 
--- a/MoinMoin/scripts/print_stats.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/print_stats.py	Wed Mar 22 09:55:32 2006 +0000
@@ -18,17 +18,21 @@
     @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
     @license: GNU GPL, see COPYING for details.
 """
-
-import sys
-from hotshot import stats
+def run():
+    import sys
+    from hotshot import stats
 
-if len(sys.argv) != 2:
-    print __doc__
-    sys.exit()
-    
-# Load and print stats 
-s = stats.load(sys.argv[1])
-s.strip_dirs()
-s.sort_stats('cumulative', 'time', 'calls')
-s.print_stats(40)
-s.print_callers(40)
+    if len(sys.argv) != 2:
+        print __doc__
+        sys.exit()
+        
+    # Load and print stats 
+    s = stats.load(sys.argv[1])
+    s.strip_dirs()
+    s.sort_stats('cumulative', 'time', 'calls')
+    s.print_stats(40)
+    s.print_callers(40)
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/reducewiki/reducewiki.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/reducewiki/reducewiki.py	Wed Mar 22 09:55:32 2006 +0000
@@ -77,12 +77,15 @@
             dest_file = os.path.join(dest_dir, filename)
             shutil.copyfile(source_file, dest_file)
 
-
-request = RequestCLI(url=url)
-request.form = request.args = request.setup_args()
+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)
-    
+    pagelist = list(request.rootpage.getPageList(user=''))
+    for pagename in pagelist:
+        copypage(request, destdir, pagename)
+        
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/HelloWorld.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/HelloWorld.py	Wed Mar 22 09:55:32 2006 +0000
@@ -7,8 +7,11 @@
 GPL software, 2003-08-10 Thomas Waldmann
 """
 
-import xmlrpclib
-srcwiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de:8000/?action=xmlrpc2")
+def run():
+    import xmlrpclib
+    srcwiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de:8000/?action=xmlrpc2")
+    print srcwiki.HelloWorld("Hello Wiki User!\n")
 
-print srcwiki.HelloWorld("Hello Wiki User!\n")
+if __name__ == "__main__":
+    run()
 
--- a/MoinMoin/scripts/xmlrpc-tools/UpdateGroupTest.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/UpdateGroupTest.py	Wed Mar 22 09:55:32 2006 +0000
@@ -5,39 +5,42 @@
 
 GPL software, 2005 Thomas Waldmann
 """
-
-import sys
-sys.path.insert(0, '../../..')
-
-import xmlrpclib
-from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
-
-user = "XmlRpc"
-password = "wrong"
-dsttrans = BasicAuthTransport(user, password)
-mywiki = xmlrpclib.ServerProxy("http://enterprise.wikiwikiweb.de:8888/?action=xmlrpc2", transport=dsttrans)
-
-groupname = "TestGroup"
-groupdesc = "This is just a test."
-groupmembers = ["TestUser1", "TestUser2",]
-print mywiki.UpdateGroup(groupname, groupdesc, groupmembers)
+def run():
+    import sys
+    sys.path.insert(0, '../../..')
 
-groupname = "TestAclGroup"
-groupdesc = "This is just a test."
-groupmembers = ["TestUser3",]
-print mywiki.UpdateGroup(groupname, groupdesc, groupmembers, "All:read,write,delete,revert")
-
-del mywiki
-del dsttrans
+    import xmlrpclib
+    from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
 
-user = "XmlRpc"
-password = "completelywrong"
-dsttrans = BasicAuthTransport(user, password)
-mywiki = xmlrpclib.ServerProxy("http://enterprise.wikiwikiweb.de:8888/?action=xmlrpc2", transport=dsttrans)
+    user = "XmlRpc"
+    password = "wrong"
+    dsttrans = BasicAuthTransport(user, password)
+    mywiki = xmlrpclib.ServerProxy("http://enterprise.wikiwikiweb.de:8888/?action=xmlrpc2", transport=dsttrans)
 
-groupname = "TestGroup"
-groupdesc = "This is just a test."
-groupmembers = ["WrongUser1", "WrongUser2",]
-print mywiki.UpdateGroup(groupname, groupdesc, groupmembers)
+    groupname = "TestGroup"
+    groupdesc = "This is just a test."
+    groupmembers = ["TestUser1", "TestUser2",]
+    print mywiki.UpdateGroup(groupname, groupdesc, groupmembers)
+
+    groupname = "TestAclGroup"
+    groupdesc = "This is just a test."
+    groupmembers = ["TestUser3",]
+    print mywiki.UpdateGroup(groupname, groupdesc, groupmembers, "All:read,write,delete,revert")
+
+    del mywiki
+    del dsttrans
+
+    user = "XmlRpc"
+    password = "completelywrong"
+    dsttrans = BasicAuthTransport(user, password)
+    mywiki = xmlrpclib.ServerProxy("http://enterprise.wikiwikiweb.de:8888/?action=xmlrpc2", transport=dsttrans)
+
+    groupname = "TestGroup"
+    groupdesc = "This is just a test."
+    groupmembers = ["WrongUser1", "WrongUser2",]
+    print mywiki.UpdateGroup(groupname, groupdesc, groupmembers)
 
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/WhoAmI.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/WhoAmI.py	Wed Mar 22 09:55:32 2006 +0000
@@ -8,16 +8,19 @@
 GPL software, 2005 Thomas Waldmann
 """
 
-user = "ThomasWaldmann"
-password = "wrong"
+def run():
+    user = "ThomasWaldmann"
+    password = "wrong"
 
-import sys, xmlrpclib
-sys.path.insert(0, '../../..')
-from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
+    import sys, xmlrpclib
+    sys.path.insert(0, '../../..')
+    from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
 
-srctrans = BasicAuthTransport(user, password)
-srcwiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2", transport=srctrans)
+    srctrans = BasicAuthTransport(user, password)
+    srcwiki = xmlrpclib.ServerProxy("http://moinmaster.wikiwikiweb.de/?action=xmlrpc2", transport=srctrans)
 
-print srcwiki.WhoAmI()
+    print srcwiki.WhoAmI()
 
+if __name__ == "__main__":
+    run()
 
--- a/MoinMoin/scripts/xmlrpc-tools/get_es_pages.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/get_es_pages.py	Wed Mar 22 09:55:32 2006 +0000
@@ -1,28 +1,32 @@
 """ get some pages from another wiki """
 
-import sys, os, xmlrpclib, codecs
-
-sys.path.insert(0, "..")
-from MoinMoin import wikiutil
-
-s = xmlrpclib.ServerProxy("http://wainu.ii.uned.es/wainuki/?action=xmlrpc2")
-index = open("index")
+def run():
+    import sys, os, xmlrpclib, codecs
 
-for l in index:
-    d = l.split('||')
-    pn = d[3].strip()
-    pd = s.getPage(pn)
-    dn = wikiutil.quoteWikinameFS(pn.decode("utf-8"))
-    os.mkdir(dn)
-    cn = os.path.join(dn,'current')
-    f = open(cn,'w')
-    f.write('00000001\n')
-    f.close()
-    dn2 = os.path.join(dn, 'revisions')
-    os.mkdir(dn2)
-    fn = os.path.join(dn2,'00000001')
-    f = codecs.open(fn,"wb","utf-8")
-    pd = pd.replace('\n','\r\n')
-    f.write(pd)
-    f.close()
+    sys.path.insert(0, "..")
+    from MoinMoin import wikiutil
 
+    s = xmlrpclib.ServerProxy("http://wainu.ii.uned.es/wainuki/?action=xmlrpc2")
+    index = open("index")
+
+    for l in index:
+        d = l.split('||')
+        pn = d[3].strip()
+        pd = s.getPage(pn)
+        dn = wikiutil.quoteWikinameFS(pn.decode("utf-8"))
+        os.mkdir(dn)
+        cn = os.path.join(dn,'current')
+        f = open(cn,'w')
+        f.write('00000001\n')
+        f.close()
+        dn2 = os.path.join(dn, 'revisions')
+        os.mkdir(dn2)
+        fn = os.path.join(dn2,'00000001')
+        f = codecs.open(fn,"wb","utf-8")
+        pd = pd.replace('\n','\r\n')
+        f.write(pd)
+        f.close()
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/getmasterpages2.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/getmasterpages2.py	Wed Mar 22 09:55:32 2006 +0000
@@ -31,14 +31,18 @@
     rc = dstwiki.putPage(pagename, pagedata)
     print "Transferred %s. Len = %d, rc = %s" % (pagename.encode('ascii','replace'), len(pagedata), str(rc))
 
-allsystempagesgroup = 'AllSystemPagesGroup'
-transferpage(srcurlformat, dstwiki, allsystempagesgroup)
-allgrouppages = dstwiki.listLinks(allsystempagesgroup)
+def run():
+    allsystempagesgroup = 'AllSystemPagesGroup'
+    transferpage(srcurlformat, dstwiki, allsystempagesgroup)
+    allgrouppages = dstwiki.listLinks(allsystempagesgroup)
 
-for langgrouppage in allgrouppages:
-    pagename = langgrouppage['name']
-    transferpage(srcurlformat, dstwiki, pagename)
-    pages = dstwiki.listLinks(pagename)
-    for page in pages:
-        transferpage(srcurlformat, dstwiki, page['name'])
+    for langgrouppage in allgrouppages:
+        pagename = langgrouppage['name']
+        transferpage(srcurlformat, dstwiki, pagename)
+        pages = dstwiki.listLinks(pagename)
+        for page in pages:
+            transferpage(srcurlformat, dstwiki, page['name'])
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/getsystempages.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/getsystempages.py	Wed Mar 22 09:55:32 2006 +0000
@@ -19,13 +19,17 @@
     dstwiki.putPage(pagename, Binary(pagedata))
     print "Transferred %s." % pagename
 
-allsystempagesgroup = 'AllSystemPagesGroup'
-transferpage(srcwiki, dstwiki, allsystempagesgroup)
-allgrouppages = srcwiki.listLinks(allsystempagesgroup)
-for langgrouppage in allgrouppages:
-    pagename = langgrouppage['name']
-    transferpage(srcwiki, dstwiki, pagename)
-    pages = srcwiki.listLinks(pagename)
-    for page in pages:
-        transferpage(srcwiki, dstwiki, page['name'])
+def run():
+    allsystempagesgroup = 'AllSystemPagesGroup'
+    transferpage(srcwiki, dstwiki, allsystempagesgroup)
+    allgrouppages = srcwiki.listLinks(allsystempagesgroup)
+    for langgrouppage in allgrouppages:
+        pagename = langgrouppage['name']
+        transferpage(srcwiki, dstwiki, pagename)
+        pages = srcwiki.listLinks(pagename)
+        for page in pages:
+            transferpage(srcwiki, dstwiki, page['name'])
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/getsystempages2.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/getsystempages2.py	Wed Mar 22 09:55:32 2006 +0000
@@ -22,13 +22,17 @@
     dstwiki.putPage(pagename, pagedata)
     print "Transferred %s." % pagename.encode('ascii', 'replace')
 
-allsystempagesgroup = 'AllSystemPagesGroup'
-transferpage(srcwiki, dstwiki, allsystempagesgroup)
-allgrouppages = srcwiki.listLinks(allsystempagesgroup)
-for langgrouppage in allgrouppages:
-    pagename = langgrouppage['name']
-    transferpage(srcwiki, dstwiki, pagename)
-    pages = srcwiki.listLinks(pagename)
-    for page in pages:
-        transferpage(srcwiki, dstwiki, page['name'])
+def run():
+    allsystempagesgroup = 'AllSystemPagesGroup'
+    transferpage(srcwiki, dstwiki, allsystempagesgroup)
+    allgrouppages = srcwiki.listLinks(allsystempagesgroup)
+    for langgrouppage in allgrouppages:
+        pagename = langgrouppage['name']
+        transferpage(srcwiki, dstwiki, pagename)
+        pages = srcwiki.listLinks(pagename)
+        for page in pages:
+            transferpage(srcwiki, dstwiki, page['name'])
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/putPageTest.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/putPageTest.py	Wed Mar 22 09:55:32 2006 +0000
@@ -13,24 +13,26 @@
 
 GPL software, 2005 Thomas Waldmann
 """
-
-import xmlrpclib
-mywiki = xmlrpclib.ServerProxy("http://localhost/mywiki/?action=xmlrpc2")
-
-# first a simple test in pure ascii
-pagename = "ApureAsciiPage"
-pagedata = "My first test."
-mywiki.putPage(pagename, pagedata)
+def run():
+    import xmlrpclib
+    mywiki = xmlrpclib.ServerProxy("http://localhost/mywiki/?action=xmlrpc2")
 
-# now let's use some utf-8 encoded pagename and text
-# this stuff will only look correct if you use utf-8 enabled equipment.
-pagename = "SomeUtf8Pagename-äöüÄÖÜߢ" # we use some german chars here
-pagedata = "Some UTF-8 content: äöü ÄÖÜ ß ¢"
-mywiki.putPage(pagename, pagedata)
+    # first a simple test in pure ascii
+    pagename = "ApureAsciiPage"
+    pagedata = "My first test."
+    mywiki.putPage(pagename, pagedata)
 
-# if you have data in iso-8859-1 (latin1) encoding, then use code similar to:
-# pagename = latin1pagename.decode('iso-8859-1').encode('utf-8')
-# pagedata = latin1pagedata.decode('iso-8859-1').encode('utf-8')
-# mywiki.putPage(pagename, pagedata)
+    # now let's use some utf-8 encoded pagename and text
+    # this stuff will only look correct if you use utf-8 enabled equipment.
+    pagename = "SomeUtf8Pagename-äöüÄÖÜߢ" # we use some german chars here
+    pagedata = "Some UTF-8 content: äöü ÄÖÜ ß ¢"
+    mywiki.putPage(pagename, pagedata)
 
+    # if you have data in iso-8859-1 (latin1) encoding, then use code similar to:
+    # pagename = latin1pagename.decode('iso-8859-1').encode('utf-8')
+    # pagedata = latin1pagedata.decode('iso-8859-1').encode('utf-8')
+    # mywiki.putPage(pagename, pagedata)
 
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/wikibackup.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/wikibackup.py	Wed Mar 22 09:55:32 2006 +0000
@@ -18,32 +18,35 @@
 
 GPL software, 2003-08-10 Thomas Waldmann
 """
-
-import xmlrpclib
-from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
-
-#user = "username"
-#password = "xxxxxxxx"
-#srctrans = BasicAuthTransport(user,password)
-#srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=srctrans)
-srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
+def run():
+    import xmlrpclib
+    from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
 
-try:
-    import cPickle as pickle
-except ImportError:
-    import pickle
-
-# Set pickle protocol, see http://docs.python.org/lib/node64.html
-PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
+    #user = "username"
+    #password = "xxxxxxxx"
+    #srctrans = BasicAuthTransport(user,password)
+    #srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=srctrans)
+    srcwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
 
-backup={}
-allpages = srcwiki.getAllPages()
-for pagename in allpages:
-    pagedata = srcwiki.getPage(pagename)
-    print "Got %s." % pagename
-    backup[pagename]=pagedata
+    try:
+        import cPickle as pickle
+    except ImportError:
+        import pickle
 
-backupfile = open("wikibackup.pickle","w")
-pickle.dump(backup, backupfile, PICKLE_PROTOCOL)
-backupfile.close()
+    # Set pickle protocol, see http://docs.python.org/lib/node64.html
+    PICKLE_PROTOCOL = pickle.HIGHEST_PROTOCOL
 
+    backup={}
+    allpages = srcwiki.getAllPages()
+    for pagename in allpages:
+        pagedata = srcwiki.getPage(pagename)
+        print "Got %s." % pagename
+        backup[pagename]=pagedata
+
+    backupfile = open("wikibackup.pickle","w")
+    pickle.dump(backup, backupfile, PICKLE_PROTOCOL)
+    backupfile.close()
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/scripts/xmlrpc-tools/wikirestore.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/scripts/xmlrpc-tools/wikirestore.py	Wed Mar 22 09:55:32 2006 +0000
@@ -19,28 +19,31 @@
 
 GPL software, 2003-10-24 Thomas Waldmann
 """
-
-import xmlrpclib
-from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
-
-user = "ThomasWaldmann"
-password = "xxxxxxxxxxxx"
-dsttrans = BasicAuthTransport(user,password)
-dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=dsttrans)
-#dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
+def run():
+    import xmlrpclib
+    from MoinMoin.support.BasicAuthTransport import BasicAuthTransport
 
-try:
-    import cPickle as pickle
-except ImportError:
-    import pickle
+    user = "ThomasWaldmann"
+    password = "xxxxxxxxxxxx"
+    dsttrans = BasicAuthTransport(user,password)
+    dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/__xmlrpc/?action=xmlrpc2", transport=dsttrans)
+    #dstwiki = xmlrpclib.ServerProxy("http://devel.linuxwiki.org/moin--cvs/?action=xmlrpc2")
 
-backupfile = open("wikibackup.pickle","r")
-backup = pickle.load(backupfile)
-backupfile.close()
+    try:
+        import cPickle as pickle
+    except ImportError:
+        import pickle
 
-allpages = backup.keys()
-for pagename in allpages:
-    pagedata = backup[pagename]
-    dstwiki.putPage(pagename, pagedata) # TODO: add error check
-    print "Put %s." % pagename
+    backupfile = open("wikibackup.pickle","r")
+    backup = pickle.load(backupfile)
+    backupfile.close()
 
+    allpages = backup.keys()
+    for pagename in allpages:
+        pagedata = backup[pagename]
+        dstwiki.putPage(pagename, pagedata) # TODO: add error check
+        print "Put %s." % pagename
+
+if __name__ == "__main__":
+    run()
+
--- a/MoinMoin/version.py	Wed Mar 22 09:03:08 2006 +0000
+++ b/MoinMoin/version.py	Wed Mar 22 09:55:32 2006 +0000
@@ -6,6 +6,7 @@
     @copyright: 2000-2006 by Jrgen Hermann <jh@web.de>
     @license: GNU GPL, see COPYING for details.
 """
+import sys
 
 try:
     from patchlevel import patchlevel
@@ -16,6 +17,25 @@
 release  = '1.5.2'
 revision = patchlevel
 
+def update():
+    """ update the version information in package init """
+    fname = 'MoinMoin/__init__.py'
+    f = file(fname)
+    lines = f.readlines()
+    f.close()
+    f = file(fname, "w")
+    version_pattern = "%s Version " % project
+    version_string = version_pattern + "%s %s" % (release, revision)
+    for line in lines:
+        if version_pattern in line:
+            f.write("%s\n" % version_string)
+        else:
+            f.write(line)
+    f.close()
+
 if __name__ == '__main__':
-    print project, release, revision
+    if len(sys.argv) > 1 and sys.argv[1] == "update":
+        update()
+    else:
+        print project, release, revision