User:TalBot/ceom hard2soft.py


 * 1) ! /usr/bin/env python
 * 2) _*_ coding: utf8 _*_
 * 3) Part of the Complete Encyclopedia of Music standadisation:
 * 4) Convert all hard redirects to soft redirects
 * 5) Copyright (C) 2007, GrafZahl (en.wikisource.org user)
 * 6) run with standard args "-log -putthrottle:xx"
 * 1) Copyright (C) 2007, GrafZahl (en.wikisource.org user)
 * 2) run with standard args "-log -putthrottle:xx"
 * 1) run with standard args "-log -putthrottle:xx"
 * 1) run with standard args "-log -putthrottle:xx"

import pagegenerators, wikipedia

wikipedia.get_throttle.setDelay(5)

for args in wikipedia.handleArgs: wikipedia.output(u'(WWW) ignoring unrecognised argument: %s' % arg)


 * 1) Basic stuff

base_redir = u'"%s"' summ = u'Converted to soft redirect'


 * 1) Page generators

ceom_pages = pagegenerators.PrefixingPageGenerator(u'Complete Encyclopaedia of Music')


 * 1) alter pages

for page in ceom_pages: try: if page.isRedirectPage: redir = base_redir % page.getRedirectTarget wikipedia.output(u'(III) Converting %s to soft redirect with target %s' % ( page.title, redir)			page.put(redir, summ, minorEdit = False)	except wikipedia.Error:		wikipedia.output(u'(EEE) Error fixing page %s' % page.title)