view MoinMoin/scripts/ @ 491:be33ecd58d4e

add run() methods to scripts, include version info into MoinMoin/ for epydoc imported from: moin--main--1.5--patch-495
author Thomas Waldmann <>
date Wed, 22 Mar 2006 09:55:32 +0000
parents 77665d8e2254
line wrap: on
line source
#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
    MoinMoin - display unused or trash page directories in data/pages
    First change the base path to match your needs.
    Then do ./ >
    Then please review and run it, if it is OK.

    @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann)
    @license: GNU GPL, see COPYING for details.

import os

base = "."
pagebasedir = base + "/data/pages"

def qualify(p):
    dir = os.listdir(p)
    if not dir:
        return 'empty'

    # check if we have something of potential value
    revs = []
    if 'revisions' in dir:
        revs = os.listdir(os.path.join(p, 'revisions'))
    atts = []
    if 'attachments' in dir:
        atts = os.listdir(os.path.join(p, 'attachments'))

    if not revs and not atts:
        return 'trash'
    if 'current-locked' in dir:
        return 'current-locked'
    elif 'current' in dir:
            current = open(os.path.join(p, 'current')).read().strip()
            curr = int(current)
            return 'current damaged'
        if current not in revs:
            return 'deleted'
        return 'no current'

    return 'ok'

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)
            print "# %s: '%s'" % (status, pagedir)

if __name__ == "__main__":