Permalink
Browse files

documentation, mv changes to top

  • Loading branch information...
Ted Timmons
Ted Timmons committed Feb 26, 2010
1 parent 0c0c3a4 commit 23f808edab8a65e9958f33d091b511d2523b959f
Showing with 34 additions and 6 deletions.
  1. +34 −6 bin/oneoffs/retemplate.pl
@@ -34,6 +34,20 @@
use constant WIKI_LOGTIME => '{{subst:CURRENTYEAR}}-{{subst:CURRENTMONTH}}- {{subst:CURRENTDAY2}} {{subst:CURRENTTIME}}';
# Good for trial runs- set much higher when it is running.
use constant MAX_TO_CHANGE => 1;
# Number of seconds between edits. Running time (in hours)
# can be approximated by NUM_PAGES * SLEEP_TIME / 3600
use constant SLEEP_TIME => 30;
# Don't include "Template:" namespace. Just the specific template name.
# It'll look for "Template:$CHANGE_FROM" and will change {{$CHANGE_FROM
# to {{$CHANGE_TO. Note it doesn't look for {{WikiProject $CHANGE_FROM.
my $CHANGE_FROM = "Children'sLiteratureWikiProject";
# Again, no namespace. Case is important here.
my $CHANGE_TO = "WikiProject Children's literature";
# If true, run through the process, but don't acutally output to Wikipedia.
my $NOPOST = 0;
@@ -57,7 +71,7 @@
my $backlist = $mw->list ( { action => 'query',
list => 'backlinks',
bltitle => 'Template:Space telescopes',
bltitle => 'Template:' . $CHANGE_FROM,
blnamespace => '0',
bllimit => '500',
blredirect => '500',
@@ -70,13 +84,15 @@
my $emblist = $mw->list ( { action => 'query',
list => 'embeddedin',
eititle => 'Template:Space telescopes',
eititle => 'Template:' . $CHANGE_FROM,
eilimit => '500',
#ucprop => 'ids|title|timestamp',
{ max => 2, }
{ max => 200, }
#hook => &process_article
} ) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
print "Collected transcluded pages: ", (scalar @$backlist + scalar @$emblist), " possibilities\n";
my %seen;
my $count = 0;
foreach my $entry (@$backlist, @$emblist) {
@@ -93,18 +109,30 @@
next;
}
(my $new_c = $c) =~ s/{{Space telescopes/{{Space observatories/g;
(my $new_c = $c) =~ s/{{$CHANGE_FROM/{{$CHANGE_TO/g;
if ($new_c eq $c) {
_debug(":Couldn't change [[$title]], didn't match regex.\n");
} elsif (! $NOPOST) {
# this is a safety trigger to make sure we don't actually edit
# real articles without approval. Remove before flight.
print "updating $title\n"; exit;
print "updating $title\n";
# Remove exit before flight.
# exit;
$tb->replacePage($title, $new_c, "replace [[:Template:Space telescopes]] with [[:Template:Space observatories]] (bot edit)");
$tb->replacePage($title, $new_c, "replace [[:Template:$CHANGE_FROM]] with [[:Template:$CHANGE_TO]] (bot edit)");
_debug(":updated [[$title]]\n");
# testing: make sure we don't change more than N.
if (++$count >= MAX_TO_CHANGE) {
_debug("\nWe've changed the maximum allowed pages. Outta here.\n");
last;
}
# Don't hit the servers too fast, and make sure there is time
# to fix a problem before it becomes a bigger problem.
sleep SLEEP_TIME;
}
#print "done.";

0 comments on commit 23f808e

Please sign in to comment.