User:AnomieBOT/source/tasks/WikiProjectWorker.pm: Difference between revisions

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * Fix edit summary link (oops!).
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectTagger, WikiProjectWorker: * Retire these tasks, WikiProject templates have changed a bunch since I last ran these.
 
(12 intermediate revisions by the same user not shown)
Line 1:
{{ombox|type=notice|text= Approved 2009-04-08<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 28]]}}
{{ombox|type=notice|text= Retired 2024-01-29. Haven't had call to run this in a while, and the related templates have changed so I'd probably have to update this code to run it again.}}
<syntaxhighlight lang="perl">
package tasks::WikiProjectWorker;
Line 10 ⟶ 11:
Task: WikiProjectWorker
BRFA: Wikipedia:Bots/Requests for approval/AnomieBOT 28
Status: ApprovedInactive 20092024-0401-0829
Created: 2009-03-27
OnDemand: true
Line 32 ⟶ 33:
 
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject WomenHigher scientistsEducation|request]]";
 
### Increment this number every time a new run is started, so we don't have to
### mess around with deleting previous runs' database entries.
my $seq=2428;
 
### How to find the pages?
my @cats%catmap = (
"Category:Articles using infobox university" => "WikiProject Higher education",
'Category:16th-century women scientists',
'Category:17th-century women scientists',
'Category:18th-century women scientists',
'Category:19th-century women scientists',
'Category:American female geologists',
'Category:American women scientists',
'Category:American women social scientists',
'Category:Australian female geologists',
'Category:Australian women scientists',
'Category:Austrian women scientists',
'Category:Belgian women scientists',
'Category:Brazilian female geologists',
'Category:Brazilian women scientists',
'Category:British female geologists',
'Category:British women scientists',
'Category:Bulgarian female geologists',
'Category:Burmese female geologists',
'Category:Canadian female geologists',
'Category:Canadian women scientists',
'Category:Chinese female geologists',
'Category:Chinese women scientists',
'Category:Danish female geologists',
'Category:Danish women scientists',
'Category:Dutch women scientists',
'Category:Egyptian female geologists',
'Category:English female geologists',
'Category:Ethiopian women scientists',
'Category:Female Fellows of the Royal Society',
'Category:Female geologists',
'Category:Filipino women scientists',
'Category:French female geologists',
'Category:French women scientists',
'Category:German female geologists',
'Category:German women scientists',
'Category:Harvard Computers',
'Category:Imperial Russian women scientists',
'Category:Indian female geologists',
'Category:Indian women scientists',
'Category:Iranian women scientists',
'Category:Iraqi women scientists',
'Category:Irish female geologists',
'Category:Irish women scientists',
'Category:Israeli female geologists',
'Category:Israeli women scientists',
'Category:Italian female geologists',
'Category:Italian women scientists',
'Category:Japanese female geologists',
'Category:Kazakhstani women scientists',
'Category:Lebanese women scientists',
'Category:Lists of women scientists',
'Category:L\'Oréal-UNESCO Awards for Women in Science laureates',
'Category:Malaysian women scientists',
'Category:Mexican women scientists',
'Category:New Zealand women scientists',
'Category:Nigerian female geologists',
'Category:Norwegian women scientists',
'Category:Peruvian women scientists',
'Category:Polish female geologists',
'Category:Polish women scientists',
'Category:Portuguese women scientists',
'Category:Recipients of the Garvan–Olin Medal',
'Category:Romanian female geologists',
'Category:Romanian women scientists',
'Category:Russian female geologists',
'Category:Russian women scientists',
'Category:Scottish female geologists',
'Category:Senegalese women scientists',
'Category:South African female geologists',
'Category:Swedish female geologists',
'Category:Swedish women scientists',
'Category:Tunisian women scientists',
'Category:Women agronomists',
'Category:Women anatomists',
'Category:Women anthropologists',
'Category:Women archaeologists',
'Category:Women astronomers',
'Category:Women atmospheric scientists',
'Category:Women biochemists',
'Category:Women bioengineers',
'Category:Women biologists',
'Category:Women biophysicists',
'Category:Women biotechnologists',
'Category:Women botanists',
'Category:Women bryologists',
'Category:Women chemists',
'Category:Women cognitive scientists',
'Category:Women computer scientists',
'Category:Women cyberneticists',
'Category:Women earth scientists',
'Category:Women ecologists',
'Category:Women economists',
'Category:Women entomologists',
'Category:Women ethnologists',
'Category:Women ethologists',
'Category:Women evolutionary biologists',
'Category:Women food scientists',
'Category:Women forensic scientists',
'Category:Women geneticists',
'Category:Women geographers',
'Category:Women horticulturists and gardeners',
'Category:Women linguists',
'Category:Women mammalogists',
'Category:Women marine biologists',
'Category:Women materials scientists and engineers',
'Category:Women mathematicians',
'Category:Women medical researchers',
'Category:Women meteorologists',
'Category:Women microbiologists',
'Category:Women molecular biologists',
'Category:Women mycologists',
'Category:Women naturalists',
'Category:Women neuroscientists',
'Category:Women oceanographers',
'Category:Women paleontologists',
'Category:Women parasitologists',
'Category:Women pathologists',
'Category:Women pharmacologists',
'Category:Women phycologists',
'Category:Women physicists',
'Category:Women physiologists',
'Category:Women phytopathologists',
'Category:Women planktologists',
'Category:Women political scientists',
'Category:Women primatologists',
'Category:Women psychologists',
'Category:Women rocket scientists',
'Category:Women scientists',
'Category:Women sexologists',
'Category:Women social scientists',
'Category:Women sociologists',
'Category:Women systems scientists',
'Category:Women taxonomists',
'Category:Women virologists',
'Category:Women zoologists',
);
my @cats=keys %catmap;
my @iterators=(
{
Line 197 ⟶ 66:
}
 
my $always_copy_importance = 0;
my $set_empty_importance = 0;
sub copy_importance {
#return ($_[0]->WPBmax($_[2]))[1];
Line 203 ⟶ 74:
 
# Banner configurations.
my $main_banner='WikiProject WomenHigher scientistseducation';
my @preprocess_templates=();
my %banner_cfgs=(
'WikiProject WomenHigher scientistseducation' => {
meta => 1,
canonicalizeimportance => 'WikiProject Women scientists',
canonicalize => 'WikiProject Higher education',
},
);
 
# Extra parameters (e.g. workgroup).
my @bio_wg = (
my @extra_params=();
's&a-work-group',
my $taggingwith = @extra_params ? '|' . join( '|', @extra_params ) : '';
);
 
# Regex fragment to match any aliases of params in @extra_params.
my %extra_param_aliases = ();
 
# Possible main banners, usually just $main_banner.
my @main_banners=(
$main_banner,
);
 
# Set this to merge these existing banners into $main_banner.
my @merge_banners=();
 
# Set this to tag WikiProject Biography workgroups in addition to the project's own banner.
my @bio_wg = (
);
 
Line 234 ⟶ 116:
=for info
Approved 2009-04-08<br />[[Wikipedia:Bots/Requests for approval/AnomieBOT 28]]
 
=for info
Retired 2024-01-29. Haven't had call to run this in a while, and the related templates have changed so I'd probably have to update this code to run it again.
 
=cut
 
sub approved {
return -1;
}
 
Line 313 ⟶ 198:
$api->log("Checking $title...");
 
my $intxt=$tok->{'revisions'}[0]{'slots'}{'main'}{'*'} // '';
my ($outtxt,$nowiki)=$api->strip_nowiki($intxt);
 
my @params=()@extra_params;
 
my $assess = undef;
Line 336 ⟶ 221:
}
 
my $copy_importance = 1$always_copy_importance; # Always copy?
if($class eq '' || lc($class) eq lc($assess)){
$class='';
Line 351 ⟶ 236:
next;
}
push @params, "importance=$imp"; # if ( $set_empty_importance || ($imp//'') ne '' );
}
 
my $need_main_banner = ($api->WPBcheck($outtxt, $main_banner@main_banners) == 0);
if(0){
# grr, already redirected so the above always returns true
$need_main_banner=1;
$api->WPBcheck($outtxt, sub {
my $banner=shift;
my $name=shift;
$need_main_banner=0 if(grep $name eq $_, @main_banners);
return undef;
}, $main_banner@main_banners);
}
 
Line 372 ⟶ 257:
my $no_summary = 0;
 
# Special: Different default parent banner depending on source category.
if(@preprocess_templates){
$main_banner = $catmap{$iter->iterval};
 
if(@merge_banners){
(undef,$outtxt)=$api->WPBcheck($outtxt, sub {
my $banner=shift;
Line 387 ⟶ 275:
$need_main_banner=0;
return "{{$main_banner}}";
}, @preprocess_templatesmerge_banners);
if(ref($outtxt) eq 'HASH'){
$api->warn("Preprocessing $title failed: ".$outtxt->{'error'}."\n");
Line 457 ⟶ 345:
}
 
$outtxt=$api->WPBadd($outtxt,my $assess,@process_banners sub= {();
$api->WPBcheck( $outtxt, sub { mypush @process_banners, $banner=shift_[0]; #}, banner@main_banners );
@process_banners = ( $main_banner my) $name=shiftunless @process_banners; # name
for my $process_banner (@process_banners) my $oname=shift;{
my $paramsouttxt=shift;$api->WPBadd($outtxt, $assess, sub {
my $wikitextbanner=shift; # banner
my $newname=shift; # name
#return '' if my $newoname=shift;
my $params=shift;
my $wikitext=shift;
my $new=shift;
#return '' if $new;
 
return undef unless(grep $banner eq $_, @main_banners);
my %cfg=%{$banner_cfgs{$banner}};
 
my $any=0;
foreach my $p (@params){
next unless $p=~/^(.+?)=(.*)$/;
my ($k,$v)=($1,$2);
my $rekre=qr/\S.*?Q$k\E/;
unless if (grep defined(/^\s*\Q $k\E\s*=\s*extra_param_aliases{$re\s*$/,k} @$params) ) {
next if(grep(/^\s*\Q my $k\E\s*aliasre =\s*(?i:\Q$v\E)\s*$/s, @$params))extra_param_aliases{$k};
unshift @ $params,kre "$k=$v" unless(grep(sqr/^(\s*\Q$k\E\s*=\s*?)(?:\S.*?)?(\s*)$/kre|$1$v$2aliasre)/s, @$params));
$any=1 unless $v eq '';}
if($k eq 'class' && ($cfg{'meta'}//0) &&my ($cfg{'stubauto'}re=qr/\S.*?/'')){;
my unless(grep(/^\s*$aakre\s*=\s*$re\s*$/, @$cfgparams)){'stubauto'};
$aa=~snext if(grep(/^\s*$kre\s*=.\s*(?i:\Q$v\E)\s*$//s, @$params));
pushunshift @$params, "$aak=inherit$v" unless(grep(s/^(\s*\Q$aa\Ekre\s*=\s*?)(?:\S.*?)?(\s*)$/$1inherit1$v$2/s, @$params));
$any=1 unless $v eq '';
if($k eq 'class' && exists($cfg{'meta'}) && ($cfg{'stubauto'}//'')){
my $aa=$cfg{'stubauto'};
$aa=~s/\s*=.*//;
push @$params, "$aa=inherit" unless(grep(s/^(\s*\Q$aa\E\s*=\s*?)(?:\S.*?)?(\s*)$/$1inherit$2/s, @$params));
}
}
}
if($new && $class && (grep /^class=/, @$params) && exists($cfg{'meta'}) && ($cfg{'stubauto'}//'')){
}
if($new && $class && (grep /^class=/, @$params) && ($cfg{'meta'}//0)my && ($aa=$cfg{'stubauto'}//'')){;
my $aa=$cfg{'stubauto'}~s/\s*=.*//;
push @$params, "$aa=~inherit" unless(grep(s/^(\s*\Q$aa\E\s*=\s*?)(?:\S.*?)?(\s*)$/$1inherit$2/s, @$params));
push @$params, "$aa=inherit" unless(grep(s/^(\s*\Q $aa\E\s*any=\s*?)(?:\S.*?)?(\s*)$/$1inherit$2/s, @$params))1;
$any=1;}
} return $wikitext unless $any;
return $wikitext unless $any;
 
if(defined($cfg{'canonicalize'})){
my $n=$cfg{'canonicalize'};
$oname=~s/_/ /g;
$oname=~s/^(\s*)\S(?:.*\S)?(\s*)$/$1$n$2/is;
}
my $out="{{$oname";
$out.="|".join("|", @$params) if @$params;
$out.="}}";
return $out;
}, $process_banner, @params);
if(ref($outtxt) eq 'HASH'){
$api->warn("Processing $title failed: ".$outtxt->{'error'}."\n");
next;
}
mypush @summary, $out="Tagging with {{$onameprocess_banner$taggingwith}}" unless $no_summary;
$out.="|".join("|", @$params) if @$params;
$out.="}}";
return $out;
}, $main_banner, @params);
if(ref($outtxt) eq 'HASH'){
$api->warn("Processing $title failed: ".$outtxt->{'error'}."\n");
next;
}
push @summary, "Tagging with {{$main_banner}}" unless $no_summary;
 
$outtxt=$api->replace_nowiki($outtxt, $nowiki);
Line 555 ⟶ 453:
return 600;
}
 
1;
 
</syntaxhighlight>