Wikipedia:Bots/Requests for approval/Bot0612 5


 * 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 5
Operator:  Richard 0612

Automatic or Manually Assisted: Auto, supervised

Programming Language(s): C# + DotNetWikiBot rewritten using python + pywikipedia

Function Summary: Add Huddersfield Town F.C. seasons to all articles in Category:Huddersfield Town F.C. seasons that do not have said template, and then rename all articles in the category to titles using endashes instead of hyphens.

Edit period(s) (e.g. Continuous, daily, one time run): One time run

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

Function Details: See this BOTREQ. The bot will add the template to the end of each article and then move all articles in the category to titles using endashes (i.e. 1988–89 as opposed to 1988-89). As bots have the  right enabled, the bot will also recreate the redirect from the hyphenated title to the new one, as per the MOS. The editing and moving will be done in separate loops, as doing them together causes everything to get mixed up (read: big mess).

Discussion

 * Source code is here.  Richard 0612  13:35, 17 January 2009 (UTC)
 * "Supressredirect" is an option when moving pages, I don't believe its used by default. Mr.Z-man 17:16, 17 January 2009 (UTC)
 * I just finished testing it, just don't specify  when making the API call and the redirect will be created as usual. Anomie⚔ 18:52, 17 January 2009 (UTC)
 * I looked into the DotNetWikiBot source code and found that it doesn't use the API for pagemoves, it uses index.php: (code commented out to avoid lengthening page, see below)


 * I suppose my only option would be to recode it to use the API (which I have little idea on how to do, although I could probably work it out). If this is not practical, it would probably be best if this task was taken up by someone who can use python/perl/etc. to access the API and this request marked as withdrawn.  Richard 0612  19:32, 17 January 2009 (UTC)
 * Update: I have managed to recode this task in python using the pywikipedia library, the code can be found in the same place. The bot will now leave the redirect behind and any errors the bot encounters will be logged in its userspace. I rewrote the code after giving myself a 5-hour crash course in python, so any improvements/optimisations are more than welcome! (as an aside, python seems much easier to code bots in than C#!)  Richard 0612  18:53, 18 January 2009 (UTC)
 * One thing I note, the original request specified removing Huddersfield Town F.C.. Also, you don't seem to check whether Huddersfield Town F.C. seasons is already on the page. You also don't check if fb end is actually on the page (so the inserting of Huddersfield Town F.C. seasons happens), although that may not be an issue.
 * BTW, does MW handle it correctly if you try to move to a title containing "&amp;ndash;" instead of "–"? Anomie⚔ 19:11, 18 January 2009 (UTC)
 * That's a good point actually. Huddersfield Town F.C. seasons has to go between the fb start and fb end templates in order for it to work properly. – PeeJay 19:14, 18 January 2009 (UTC)

(outdent) The original request did specify removing Huddersfield Town F.C., but I thought that it would probably be better to have both on the page (both are relevant), and this was agreed at the BOTREQ. If it is felt that it should be removed, then I can do so. As for checking whether fb end is on the page, I assumed (naively) that it would be there due to PeeJay saying that the main club template (which requires the fb templates) should be removed (which implies that it is already there). However, for robustness it would be best if I did check; I will fix the code accordingly. I will have to find out whether MW handles '&amp;ndash;' and '–' as the same thing, I know that the former worked when using C# though.  Richard 0612  19:24, 18 January 2009 (UTC)
 * Works for me. Anomie⚔ 19:27, 18 January 2009 (UTC)
 * This curious error was (I think) caused by a bug in the code I used to ensure that only 26 edits were made. To fix this I removed the code and monitored the bot, terminating the process after 26 pages had been processed. No other problems that I can see.  Richard 0612  21:37, 18 January 2009 (UTC)
 * It seems for that error that the page loading followed the redirect (to get the contents of the target article), but the page save overwrote the redirect instead of following it to the target article. At any rate, keep an eye on it in case that happens again. Anomie⚔ 22:00, 18 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.