Forum:Pywikipedia bot, replace.py help

Hi, I've recently downloaded pywikipedia bot. I'd like to be able to use it to add text to a lot of different articles. I know I can use replace.py to add the same text to every article, but what I really want to do is add slightly different text to each one. (Sort keys, if anyone's interested.) Is there any way to do this without just running replace.py once for each article. I'm hoping I'll be able to use replace.py, or one of the other available scripts, since I'm not experienced enough with python to attempt writing my own. Thanks, Quartic ~ insanity is a virtue  |  Talk  16:55, 25 August 2009 (UTC)

Can You...
Be a little more specific. I use replace.py all the time and will be glad to help. But I need to understand exactly what you are doing. --DaNASCAT 20:33, 27 August 2009 (UTC)


 * On the wiki I edit we have a lot of subpages with an infobox. The information in these infoboxes is used to fill a table on the respective main page. (Via dpl.) What I want to be able to do is add a new field to each infobox, already filled in with the correct value. Specifically, I want to replace  with   on one article,   on the next,   on the next, etc. I know I can do this one by one, but I'd rather be able to, say, provide a file with the articles, text to be replaced and text to replace with.  Quartic ~ insanity is a virtue  |  Talk  22:32, 27 August 2009 (UTC)


 * I don't know if you have Extension:Variables enabled on your wiki, but it sounds like to me the best idea would be to create a page variable and instead of replacing gameSort = AA\n}} with \n . That would require a lot of work as well, though. I don't really see an easy solution. If you want to give a link to where you would like this done, I can create a test page on your wiki and try some things myself. Best, --DaNASCAT 21:29, 28 August 2009 (UTC)
 * This is the template that will be sorted if I can add these sort keys. This is the infobox I want to add the sort keys to. Quartic ~ insanity is a virtue  |  Talk  21:37, 28 August 2009 (UTC)
 * Hmm, I still need some help with this. Quartic ~ insanity is a virtue  |  Talk  00:23, 1 September 2009 (UTC)
 * Don't think it can be done with replace.py alone. You'd have to write your own script or use a shell script that calls replace.py multiple times. This is because your replacement depends on the file to work on.--AB 10:53, 1 September 2009 (UTC)
 * Hmm, I'll need some advice on how to do that then. ;-p Quartic ~ insanity is a virtue  |  Talk  11:04, 1 September 2009 (UTC)

This ought to work on bash (you'd save this in a file and call it with ):
 * 1) !/bin/bash

python replace.py -always -page:»pagetitleA« '}}' 'gameSort = AA\n}}' sleep 7 python replace.py -always -page:»pagetitleB« '}}' 'gameSort = AB\n}}' sleep 7 python replace.py -always -page:»pagetitleC« '}}' 'gameSort = AC\n}}' You better try the replace command on one single page beforehand.--AB 11:28, 1 September 2009 (UTC)