From MythTV Official Wiki
Jump to: navigation, search

Important.png Note: The correct title of this article is It appears incorrectly here due to technical restrictions.

This is a pywikipedia script, developed to support maintenance of this site.

I want to thank a mysterious user (Special:Contributions/ for finding some bad auto-wiki'd text. This is a modified version of to replace one wiki string with an alternate string that is NOT wiki.

Originally, the MoinMoin wiki site used camel case linking notation. A script used to kick-off the migration to mediawiki replaced many of those links automatically, by splitting camel case words and wrapping them with square brackets. Certain words, which were not links, got dragged along. The result is that many of the Special:Wantedpages entries aren't really "wanted" at all. Reverting them back to their original notation with the linking notation removed helps lower the pages actually wanted.

Source code


import re, sys
from pywikipedia import wikipedia

oldname = sys.argv[1]
newname = sys.argv[2]

site = wikipedia.getSite()
page = wikipedia.Page(site=site, title=oldname)
links = page.getReferences()

print "There are a total of %s related articles that need to be updated" % len(links)

for eachPage in links:
        wikitext = eachPage.get()
        newtext = re.compile("\[\[" + oldname + "\]\]").sub(newname, wikitext)
                eachPage.put(newtext=newtext, \
                        comment="[[pywikipedia]] assisted cleanup ([[]]) -> removing auto-wiki'd '" + \
                        oldname + "' with '" +  newname + "'", minorEdit=True)
        except Exception:
                print "Unable to edit " +eachPage.aslink()

How to run it

To run the script, it needs two arguments. (Use quotation marks to escape the shell).

% python "Foo Bar" "FooBar"

It will find every article pointed at Foo Bar, substitue FooBar without wiki tags, and then write it as a minor edit. This also helps reduce the number of Special:Wantedpages.