''' main.py -- actual action entry point. ---- Copyright (C) 2007-2008 Zoran Isailovski Licensed under the Apache License, Version 2.0 (see http://www.apache.org/licenses/LICENSE-2.0) or, at your option, under the terms described in the file LICENSE.txt found in the root of the distribution of this package (as far as it denotes a different license then the above). ''' __TODO__ = '''\ ''' DEBUG = True #-- configuration ------------------------------------------------------------ TITLE = 'Attachments deletion' #----------------------------------------------------------------------------- import os, re, fnmatch, glob import tmpl from MoinMoin import wikiutil #----------------------------------------------------------------------------- def execute(process, pagename, request): _ = request.getText request.theme.send_title(_(TITLE + ' for "%s"' % pagename)) try: try: process(request) except: import sys, traceback output = traceback.format_exception( *sys.exc_info() ) if not DEBUG: output = output[-1:] output = ''.join( output ) request.write( ERROR_FORMAT % (TITLE, pagename, output) ) finally: request.theme.send_footer(pagename) ERROR_FORMAT = '''\
\ %s\
%s' % items) if items: for (fname, states) in items: ## if states != [u'on']: continue # this does not happen if not fnpat.match(fname): messages.append('File name mismatch:\n %s' % fname) continue path = os.path.join(folder, fname) if not os.path.isfile(path): messages.append('File not found:\n %s' % fname) continue os.remove(path) messages.append('File deleted:\n %s' % fname) data.messages = messages data.folder = folder data.filenames = [ fname for fname in os.listdir(folder) if fnpat.match(fname) ] ##data.succ = lambda n, d=1 : n + d