Manual:Pywikipediabot/Development
This page was moved from MetaWiki.
It probably requires cleanup – please feel free to help out. In addition, some links on the page may be red; respective pages might be found at Meta. Remove this template once cleanup is complete.
Pywikipediabot |
||||||
|---|---|---|---|---|---|---|
|
- If you need more help on setting up your pywikipediabot visit the irc channel #pywikipediabotconnect @ freenode server or pywikipediabot mailing list.
Contents |
How to report a bug [edit]
When you report a bug please try to include:
- PyWikipediaBot version in use. It's recommended to test if the bug is still present in latest SVN revision available.
- Python version (python -V) and operating system you use (e.g. Windows, Linux, MacOS...)
- For above purpose, version.py will be useful.
- A nice summary
- Full description of the problem/report
- How to reproduce bug full information (script, command line, family, and language used)
- The console output provided by the script (included the Python traceback if you are reporting a crash)
To submit a new bug visit the bug tracker provided by SourceForge.
Development [edit]
If you have a function you want to have a bot for that is not yet provided by one of the bots, you can ask one of the programmers to write it for you. Or even better, you can try to work on the bots yourself. Python is a nice language, and not hard to learn. We will welcome you.
Commit access [edit]
To request commit access, first email the mailing list and explain what you'd like to work on. Once you've gotten a little community consensus that you should get access, submit a formal commit access request and mention that you'd like pywikipediabot commit access, and point to the mailing list thread where you got an OK from the pywikipediabot community. Example.
Tips [edit]
Here and in wikipedia.py, there are some very basic tips for getting started writing your own bot:
- be sure you've set up your user-config.py file (see above)
- To gain access to the pywikipedia framework, use:
import wikipedia
- to retrieve a page, use the following, where pageName is, e.g., "Wikipedia:Bots" or "India":
site = wikipedia.getSite() page = wikipedia.Page(site, u"pageName") text = page.get(get_redirect = True)
- to update a page, use:
page.put(u"newText", u"Edit comment")
- look at some of the pywikipedia files for other ideas -- basic.py is relatively easy to read even if you're new to pywikipedia.
- you can find all available Page methods in the wikipedia.py file.
- basic.py gives you a setup that can be used for many different bots, all you have to do is define the string editing on the page text.
- To iterate over a set of pages, see pagegenerators.py for some objects that return a set of pages. An example use of the CategoryPageGenerator that does something for each page in the Category:Living people category:
import catlib import pagegenerators import wikipedia site = wikipedia.getSite() cat = catlib.Category(site,'Category:Living people') gen = pagegenerators.CategorizedPageGenerator(cat) for page in gen: #Do something with the page object, for example: text = page.get()
Contributing changes [edit]
If you changed the bot and want to send a patch to the maintainer,
- Update to the current version (it will merge your changes with the improvements already committed to the SVN Repository),
- Resolve any conflicts caused by the update (grep for "=====" ;-) and
- Type:
-
$ svn diff > svn.diff
Review the diff to ensure it only includes the changes you want to contribute. The lines at the beginning starting with "?" should be removed.
If you are in direct contact with a Pywikipediabot developer, you can send the file svn.diff to him, but preferably attach the patch to a ticket in the Pywikipedia bug tracking system.
Git [edit]
See this mailing list post if you would like to try Git instead of Subversion for source control. This github repo mentioned is quite dated, the best part is this git svn command:
git svn clone http://svn.wikimedia.org/svnroot/pywikipedia/ -T trunk -b branches
Note that this will take quite a while.
Bot & Proxy [edit]
There is probably (not tested!) draft workaround described here.