Board Thread:Support Requests - Getting Technical/@comment-4738647-20131129225241/@comment-188432-20131130173022

FortressMaximus wrote: And can I reference special page lists i.e. Special:WhatLinksHere/HellowWorld as well as unused files? Heh, you've almost hit upon the markup by using the word reference. The WLH report, as you put it, is the basis of many bot runs, but the command is. That tells the command to work on those pages which reference (that is, are linked to) the page you name.

So if you wanted to, I dunno, change Hellow to Hello on every page that linked to HellowWorld, you would do this:

python replace.py "Hellow" "Hello" -ref:"HellowWorld" -pt:1

Now, that language is super simple and it may not be appropriate for every bot run. For instance, this would change every instance of Hellow to Hello on pages where a link to HellowWorld exists. You may not want to do this, because it may be, for whatever reason, that you want only to change the links and not also every 'unlinked'' instance on these pages. Also, you might not want to change the spelling only on those pages which are linked to HellowWorld. This language wouldn't do anything on a page that mentioned HellowWorld but didn't link to HellowWorld.

or. Given that the in-wiki command that duplicates  is WhatLinksHere, you might think that   would do the same thing. But instead it does kinda the converse. It works on all the pages that are linked at a particular article. Imagine the page HellowWorld consisted of a single sentence, something like this:

HellowWorld was a riff on an old 1970s test phrase used by computer scientists to test whether their ~computer program~@program@s were correctly coded.

Now imagine that you wrote this python command:

python replace.py "Hellow" "Hello" -links:HellowWorld -pt:1

What this does is to look on every page linked from HellowWorld, and then take the action indicated. So it would go to riff, 1970s, computer scientist, computer program and code, see if there were any instances of "Hellow", and change them to "Hello".

So, remember that  and   do kind of the opposite of what you might expect, given the existence of Special:WhatLinksHere.

Oh, by the way,   is a throttle. By setting it to 1, you're saying, "Perform an edit once a second." In most installations of pywikipedia, the default editing interval is 8 or 9 seconds, and that number grows the more processes you run at any given time. If you really start using pywikipedia heavily, it will save you hours and hours of time to bring your editing interval down to 1.

You may also wonder why I've not included a  statement in these examples. Well, I tend to think that all deletions, which we were talking about in our earlier example, deserve a custom edit summary. For the beneft of people looking through the logs later, I think it's vital that you justify your deletion. However, with replacement text runs, like the examples here, the automatically-generated summaray is often more precise than what you can possibly enter. This is especially true in more complicated replacements using regex, where the summary includes the precise regex statement — which, to me, is more useful than a manual summary. That's not to say I'd never do a manual summary — certianly in the case of a change that was called for by community discussion, I'd note the Thread number or forum title in the summary. But for casual spelling error corrections, I'd mostly just let pywikipedia fill in the summary, because it's going to be much more explicit than my own summary could be.