Wikipedia:Bots/Requests for approval/Bot0612 6


 * The following discussion is an archived debate. Please do not modify it. Subsequent comments should be made in a new section. The result of the discussion was Symbol keep vote.svg Approved.

User:Bot0612 6
Operator:  Richard 0612

Automatic or Manually Assisted: Automatic supervised

Programming Language(s): python using pywikipedia

Function Summary: See here and also this BOTREQ.

Edit period(s): One-time run

Already has a bot flag (Y/N): Y

Function Details: The bot will get all pages that transclude Year in baseball (essentially all ‘fooyear in Baseball’ articles), and rename Year in baseball to Year in baseball top. The new template has no navigational sidebar; this will be replaced by a navbox (which will eventually reside at Year in baseball) which the bot will add to the bottom of each article. Although this process means that the articles will look a bit strange while the bot updates the templates, this will only be for ~10 minutes or so.

Discussion

 * As always, feel free to take a look at the code.  Richard 0612  17:03, 23 January 2009 (UTC)
 * Three critiques:
 * It would probably be worthwhile to make sure of the template being replaced:  (I couldn't get it to work with regex.Replace locally).
 * When inserting the, you may as well leave out the.
 * It would be good to check whether the replacement has been done on the page already, just in case you run into errors and have to restart the bot. Otherwise it'll end up with  at the bottom of the article.
 * You could also look into putting the  above the category and interwiki links. Pywikipedia probably has a function to handle that sort of thing already. Anomie⚔ 01:30, 24 January 2009 (UTC)
 * Spot on, as always, Anomie (one day I'll be able to write code with no holes in...). I've made the changes you recommended. pywikipedia doesn't have a way to insert text before categories/interwikis, so I wrote my own. It's hardly elegant, but it works. I put it in a separate file so that I can use it in other bot tasks; you can see it here.  Richard 0612  14:25, 24 January 2009 (UTC)
 * I never manage to write code without holes either, I just have an eye for "how can this break" and I test everything I can think of. Your endofprose function has a major bug, though: any cross-namespace links (including File/Image links!) will falsely hit your regex, so the addition will be put just before the first image in the page. Something like this should be more robust, although I know little of python so it could probably be cleaned up a bit. And technically, "endofprose" is the wrong name, as the real end of prose would be above the "See also", "References", "External links", and navboxes. Anomie⚔ 19:11, 24 January 2009 (UTC)

(Per request by Betacommand)

If you wish to implement adding the template to the bottom, you should use a code like that, or something similar. Best, Peter Symonds ( talk ) 19:33, 24 January 2009 (UTC)
 * I thought pywikipedia had some way to do it. Anomie⚔ 20:54, 24 January 2009 (UTC)
 * (Note to self: test code more thoroughly in future) I can be incredibly stupid sometimes (they must never let me code anything for controlling nuclear power plants or suchlike...). I'll test out the method above for adding the template to the bottom of the article. I would have fixed that had I not tested it on an image-less test page. Thanks to both of you for fixing the massive bug! And I named the function 'endofprose' because 'beforecategoriesorinterwikis' is far too long to type!  Richard 0612  20:58, 24 January 2009 (UTC)
 * OK, I've changed the code for the template insertion and tested it. It seems to work fine this time! It reorders the interwiki and category blocks, but this is arguably a good thing (cleaning up the general formatting). 21:51, 24 January 2009 (UTC)
 * Anomie⚔ 22:38, 24 January 2009 (UTC)
 * Thanks, I'll run the trial tomorrow when I can do the trial and the full run relatively quickly to avoid the articles looking weird for too long!  Richard 0612  23:06, 24 January 2009 (UTC)
 * Everything seems fine, no problems encountered with the bot.  Richard 0612  12:22, 25 January 2009 (UTC)

Looks good. Anomie⚔ 14:39, 25 January 2009 (UTC)


 * The above discussion is preserved as an archive of the debate. Please do not modify it. Subsequent comments should be made in a new section.