view MoinMoin/scripts/ @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <>
date Thu, 22 Sep 2005 15:09:50 +0000
children be33ecd58d4e
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'

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)