Purple exclamation mark.svg Planning the future of Botwiki! - Help us bring Botwiki up to date, contribute to our strategy discussion, add bot scripts, and contribute manuals, guides, and tutorials! Almost anything related to bots, particularly those used to edit mediawiki, is welcome.

Red exclamation mark.svg UNABLE TO EDIT? - We've experienced attacks by spambots lately and now require you to confirm your e-mail before you can edit (go to your preferences, enter an e-mail address, and request a confirmation e-mail, then go to your e-mail and click on the confirmation link). We also require new accounts to make a few edits and wait a few minutes before before you can create a page; however, if this is a problem contact us in #botwiki and we can manually confirm your account. Sorry for the inconvenience.

Python:Compwhizii.py

From Botwiki
Jump to: navigation, search
#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
Reame: TODO
"""
#
# (C) Compwhizii, 2008
# (C) Filnik, 2008 (fixes)
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id: $'
#
 
import wikipedia, pagegenerators, catlib
import re
 
def main():
    site = wikipedia.getSite()
    cat = catlib.Category(site,'Category:Paleontology stubs')
    gen = pagegenerators.SubCategoriesPageGenerator(cat, True)
    for page in gen:
        if not page.isTalkPage():
            tpage = page.toggleTalkPage()
        else:
            tpage = page
 
        wikipedia.output(u"Loading %s..." % tpage.title())
        try:
            text = tpage.get()
        except (wikipedia.NoPage, wikipedia.IsRedirectPage), e:
            wikipedia.output('Error:')
            print e
            wikipedia.output('Skipping...')
            continue
        newtext = text
        newtext = re.sub(r"(?m)\{\{WikiProject Geology\|.*?\}\}", "", text)
        if newtext == "":
            newtext = "{{db-author}}"
        if newtext != text:
            #print "Text: " + newtext
            tpage.put(newtext, u"Fixing tagging mistake made by [[User:John Bot|John Bot]]")  
 
if __name__ == "__main__":
    try:
        main()
    finally:
        wikipedia.stopme()
Personal tools
Share