User:Xwing328/Pywikipedia


 * A majority of the following was copied from User:Sikon/Pywikipedia.

These instructions should help you get started using the Python Wikipedia Robot Framework. Before proceeding, please visit Droids.

Getting started

 * Install Python version 2.5 (or greater) from http://www.python.org
 * I would suggest installing it at C:\Program Files\Python 2.5
 * Download the latest CVS snapshot.
 * Sikon prepackaged it at http://lucidfox.org/dump/snapshot.tar.bz2
 * Unzip the snapshot (use a program such as 7-Zip) and place the files at C:\Program Files\Python 2.5\Pywikipedia
 * Using Notepad or a similar text-editing program, create a file called user-config.py in the Pywikipedia folder you just created. You are in the correct directory if you see the file config.py
 * In the file, insert the following:

import os, re, sys family = 'starwars' mylang = 'en' usernames['starwars']['en'] = 'bot_username' minthrottle = 1 maxthrottle = 4 put_throttle = 4 noisysleep = 2.0


 * Replace bot_username with your bot's name.
 * The throttle values regulate how long the bot will wait between getting and saving pages. For now, do not worry about these numbers.
 * Be sure NOT to save it as a .txt file.
 * Locate the families directory under Pywikipedia. Create a file called starwars_family.py and insert the following content:

import family class Family(family.Family): def __init__(self): family.Family.__init__(self) self.name = 'starwars' self.langs = { 'en': None, }       # Most namespaces are inherited from family.Family. self.namespaces[4] = { '_default': u'Wookieepedia', }       self.namespaces[5] = { '_default': u'Wookieepedia talk', }       self.namespaces[100] = { '_default': u'Forum', }       self.namespaces[101] = { '_default': u'Forum talk', }       # A few selected big languages for things that we do not want to loop over # all languages. This is only needed by the titletranslate.py module, so       # if you carefully avoid the options, you could get away without these # for another wiki family. self.languages_by_size = ['en'] def hostname(self,code): return 'starwars.wikia.com' def path(self, code): return '/index.php' def version(self, code): return "1.7"


 * Under the Pywikipedia directory, locate wikipedia.py. Open it and find "Wikipedia:Sandbox". Replace it with "%s:Sandbox" (or any other page that exists on Wookieepedia).

Running scripts
Now that your bot is installed and configured, try running some scripts. A summary on command line options can be found in the .py files themselves.


 * 1) Open Command Prompt (or a similar program).
 * 2) *Start, Run, cmd, OK
 * 3) Navigate to the Pywikipedia directory:
 * 4) *Type: cd C:\\Program Files\Python 2.5\Pywikipedia
 * 5) Login to Wookieepedia. This only needs to be done once, NOT every time you run your bot!
 * 6) *Type: login.py (Follow the instructions to enter the bot's password)
 * 7) You can now run any other script you desire. I would suggest starting small, by testing an edit to your user page.

Some example commands used by R2-D2:

python replace.py -cat:Core_planets "=Unknown" "="
 * Implementing auto-hiding in planet infoboxes by removing the "Unknown" text (repeated for "Core planets", "Colonies planets", "Tapani Sector planets" and "Planets"):

python category.py move
 * Moving categories (category names were input at prompt):


 * Fixing template categories with a modified version of catall.py (with the noinclude notation support).


 * Gender categorization

echo a|python replace.py -ref:Template:Character_infobox -regex "gender=([^M]*)Male([^}]*)}}" "gender=\\1Male\\2}} ">/dev/null

(output was disabled to save my bandwidth)