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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectWorker: * Begin run for WikiProject Diptera d/WikiProjectTagging.pm: * When not configured to apply namespace assessments, don't apply redirect assessment either.
AnomieBOT (talk | contribs)
Updating published sources: WikiProjectTagger, WikiProjectWorker: * Retire these tasks, WikiProject templates have changed a bunch since I last ran these.
 
(9 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 DipteraHigher Education|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=2528;
 
### How to find the pages?
my @cats%catmap = (
"Category:Articles using infobox university" => "WikiProject Higher education",
'Category:Acalyptratae',
'Category:Acalyptratae stubs',
'Category:Acartophthalmidae',
'Category:Achalcinae',
'Category:Acroceridae',
'Category:Acrosticta',
'Category:Actia (genus)',
'Category:Actia stubs',
'Category:Adejeania',
'Category:Aedeomyia',
'Category:Aedes',
'Category:Aedini',
'Category:Agromyzidae',
'Category:Amethysa',
'Category:Andrenosoma',
'Category:Anisopodidae',
'Category:Anopheles',
'Category:Anophelinae',
'Category:Anthomyiidae',
'Category:Anthomyzidae',
'Category:Antyxinae',
'Category:Armigeres',
'Category:Aschiza',
'Category:Aschiza genera',
'Category:Aschiza stubs',
'Category:Asilidae',
'Category:Asilidae genera',
'Category:Asilidae stubs',
'Category:Asilinae',
'Category:Asiloidea',
'Category:Asiloidea genera',
'Category:Asiloidea stubs',
'Category:Asilomorpha',
'Category:Asilomorpha genera',
'Category:Asilomorpha stubs',
'Category:Asilomorpha subfamilies',
'Category:Asilomorpha taxa',
'Category:Asilomorph flies of Europe',
'Category:Asteiidae',
'Category:Athericidae',
'Category:Atomosia',
'Category:Australimyzidae',
'Category:Austroleptidae',
'Category:Axymyiomorpha',
'Category:Babindellinae',
'Category:Bactrocera',
'Category:Belgica',
'Category:Bibionidae',
'Category:Bibionomorpha',
'Category:Bibionomorpha genera',
'Category:Bibionomorpha stubs',
'Category:Blephariceridae',
'Category:Blephariceromorpha',
'Category:Blephariceromorpha stubs',
'Category:Blepharoneurinae',
'Category:Bolitophilidae',
'Category:Bombyliidae',
'Category:Bombyliidae genera',
'Category:Bombyliidae stubs',
'Category:Brachycera',
'Category:Brachycera families',
'Category:Brachycera genera',
'Category:Brachyceran flies of Europe',
'Category:Brachycera stubs',
'Category:Brachycera subfamilies',
'Category:Brachycera taxa',
'Category:Brachycera tribes',
'Category:Brachystomatidae',
'Category:Braulidae',
'Category:Calliphoridae',
'Category:Calyptratae',
'Category:Calyptratae stubs',
'Category:Camillidae',
'Category:Campichoetidae',
'Category:Canacidae',
'Category:Carnidae',
'Category:Carnoidea',
'Category:Carnoidea genera',
'Category:Carnoidea stubs',
'Category:Cecidomyiidae',
'Category:Cecidomyiidae genera',
'Category:Cecidomyiinae',
'Category:Celyphidae',
'Category:Cephalia',
'Category:Ceratitella',
'Category:Ceratopogonidae',
'Category:Cerotainia',
'Category:Ceroxys',
'Category:Chaetopsis',
'Category:Chamaemyiidae',
'Category:Chaoboridae',
'Category:Chironomidae',
'Category:Chironomidae stubs',
'Category:Chironomoidea',
'Category:Chironomoidea genera',
'Category:Chironomoidea stubs',
'Category:Chloropidae',
'Category:Chloropidae genera',
'Category:Chloropinae',
'Category:Chrysomyza',
'Category:Chyromyidae',
'Category:Clusiidae',
'Category:Conopidae',
'Category:Conopoidea genera',
'Category:Conopoidea stubs',
'Category:Coquillettidia',
'Category:Cremifaniidae',
'Category:Culex',
'Category:Culicidae',
'Category:Culicinae',
'Category:Culicoidea',
'Category:Culicoidea genera',
'Category:Culicoidea stubs',
'Category:Culicoides',
'Category:Culicomorpha',
'Category:Culicomorpha genera',
'Category:Culicomorpha stubs',
'Category:Cyamops',
'Category:Cylindrotomidae',
'Category:Dacinae',
'Category:Dacinae stubs',
'Category:Dasymetopa',
'Category:Dexiinae',
'Category:Dexiinae stubs',
'Category:Diadocidiidae',
'Category:Diaphorinae',
'Category:Diastatidae',
'Category:Diopsidae',
'Category:Diopsoidea',
'Category:Diopsoidea genera',
'Category:Diopsoidea stubs',
'Category:Diptera by classification',
'Category:Diptera by continent',
'Category:Diptera by ___location',
'Category:Diptera by region',
'Category:Diptera families',
'Category:Diptera genera',
'Category:Diptera of Africa',
'Category:Diptera of Asia',
'Category:Diptera of Australasia',
'Category:Diptera of Europe',
'Category:Diptera of New Zealand',
'Category:Diptera of North America',
'Category:Diptera of Scandinavia',
'Category:Diptera of South America',
'Category:Diptera pests and diseases',
'Category:Diptera stubs',
'Category:Diptera subfamilies',
'Category:Diptera superfamilies',
'Category:Diptera taxa',
'Category:Diptera taxa by rank',
'Category:Diptera taxonomy',
'Category:Diptera tribes',
'Category:Diptera used as pest control agents',
'Category:Ditomyiidae',
'Category:Dixidae',
'Category:Dolichopodidae',
'Category:Dolichopodidae genera',
'Category:Dolichopodidae stubs',
'Category:Dolichopodidae subfamilies',
'Category:Dolichopodinae',
'Category:Dolichopus',
'Category:Dorycera',
'Category:Drosophila',
'Category:Drosophila melanogaster',
'Category:Drosophila melanogaster genes',
'Category:Drosophila melanogaster genetics',
'Category:Drosophilidae',
'Category:Drosophilidae genera',
'Category:Drosophilidae stubs',
'Category:Dryomyzidae',
'Category:Empididae',
'Category:Empidoidea',
'Category:Empidoidea genera',
'Category:Empidoidea stubs',
'Category:Empyelocera',
'Category:Enliniinae',
'Category:Ephydridae',
'Category:Ephydroidea',
'Category:Ephydroidea genera',
'Category:Ephydroidea stubs',
'Category:Eristalinae',
'Category:Euleia',
'Category:Eumerini',
'Category:Euxesta',
'Category:Euxesta stubs',
'Category:Exoristinae',
'Category:Exoristinae stubs',
'Category:Fanniidae',
'Category:Ficalbia',
'Category:Flies and humans',
'Category:Fly biology',
'Category:Fly ecology',
'Category:Goniaea',
'Category:Heizmannia',
'Category:Helcomyzidae',
'Category:Heleomyzidae',
'Category:Heleomyzidae stubs',
'Category:Hexachaeta',
'Category:Hippoboscidae',
'Category:Hippoboscoidea',
'Category:Hippoboscoidea genera',
'Category:Hippoboscoidea stubs',
'Category:Hodgesia',
'Category:Homalocephala',
'Category:Hoverflies',
'Category:Hoverfly genera',
'Category:Hybotidae',
'Category:Hydrophorinae',
'Category:Hydrophorus',
'Category:Keroplatidae',
'Category:Laphria',
'Category:Laphriinae',
'Category:Laphystia',
'Category:Lauxaniidae',
'Category:Lauxanioidea',
'Category:Lauxanioidea genera',
'Category:Lauxanioidea stubs',
'Category:Leptoconops',
'Category:Limoniidae',
'Category:Lists of Diptera',
'Category:Lists of Diptera by ___location',
'Category:Lists of Diptera genera',
'Category:Lonchaeidae',
'Category:Lonchaeoidea',
'Category:Lonchopteridae',
'Category:Mansonia',
'Category:Medeterinae',
'Category:Melieria',
'Category:Micropezidae',
'Category:Microphorinae',
'Category:Mimomyia',
'Category:Monogeneric Diptera families',
'Category:Monotypic Brachycera genera',
'Category:Monotypic Diptera genera',
'Category:Monotypic Diptera taxa',
'Category:Mosquito genera',
'Category:Muscidae',
'Category:Muscidae genera',
'Category:Muscidae stubs',
'Category:Muscoidea',
'Category:Muscoidea genera',
'Category:Muscoidea stubs',
'Category:Muscomorpha',
'Category:Muscomorpha genera',
'Category:Muscomorpha stubs',
'Category:Muscomorph flies of Europe',
'Category:Mycetophilidae',
'Category:Mydidae',
'Category:Myennis',
'Category:Myoleja',
'Category:Nematocera',
'Category:Nematocera families',
'Category:Nematocera genera',
'Category:Nematoceran flies of Europe',
'Category:Nematocera stubs',
'Category:Nematocera subfamilies',
'Category:Nematocera taxa',
'Category:Nematocera tribes',
'Category:Nemestrinoidea',
'Category:Nemestrinoidea genera',
'Category:Nemestrinoidea stubs',
'Category:Nerioidea',
'Category:Nerioidea genera',
'Category:Nerioidea stubs',
'Category:Neurigoninae',
'Category:Nycteribiidae',
'Category:Ochlerotatus',
'Category:Odiniidae',
'Category:Oestridae',
'Category:Oestroidea',
'Category:Oestroidea genera',
'Category:Oestroidea stubs',
'Category:Opomyzidae',
'Category:Opomyzoidea',
'Category:Opomyzoidea genera',
'Category:Opomyzoidea stubs',
'Category:Ortalis (fly)',
'Category:Orthopodomyia',
'Category:Oscinellinae',
'Category:Otites',
'Category:Otitinae',
'Category:Pallopteridae',
'Category:Paragorgopis',
'Category:Parasitic flies',
'Category:Parathalassiinae',
'Category:Paravilla',
'Category:Pediciidae',
'Category:Peloropeodinae',
'Category:Perilampsis',
'Category:Periscelididae',
'Category:Phasiinae',
'Category:Phasiinae stubs',
'Category:Phoridae',
'Category:Physiphora',
'Category:Phytalmiinae',
'Category:Phytalmiinae stubs',
'Category:Phytomyza',
'Category:Piophilidae',
'Category:Pipunculidae',
'Category:Plagioneurinae',
'Category:Platypezidae',
'Category:Platypezoidea',
'Category:Platypezoidea genera',
'Category:Platypezoidea stubs',
'Category:Platystomatidae',
'Category:Pollinator flies',
'Category:Prehistoric Diptera',
'Category:Prehistoric Diptera genera',
'Category:Procecidochares',
'Category:Psilidae',
'Category:Psychodidae',
'Category:Psychodomorpha',
'Category:Psychodomorpha genera',
'Category:Psychodomorpha stubs',
'Category:Pterocalla',
'Category:Pterocerina',
'Category:Ptychopteridae',
'Category:Ptychopteromorpha',
'Category:Pyrgotidae',
'Category:Rhagionidae',
'Category:Rhagionoidea',
'Category:Rhagionoidea stubs',
'Category:Rhagoletis',
'Category:Rhagoletis stubs',
'Category:Rhaphiinae',
'Category:Rhinophoridae',
'Category:Sarcophagidae',
'Category:Scathophagidae',
'Category:Scatopsidae',
'Category:Schizophora',
'Category:Schizophora genera',
'Category:Schizophora stubs',
'Category:Sciapodinae',
'Category:Sciaridae',
'Category:Sciaroidea',
'Category:Sciaroidea genera',
'Category:Sciaroidea stubs',
'Category:Sciomyzidae',
'Category:Sciomyzoidea',
'Category:Sciomyzoidea genera',
'Category:Sciomyzoidea stubs',
'Category:Scutelliseta',
'Category:Seioptera',
'Category:Sepsidae',
'Category:Sericomyiini',
'Category:Simuliidae',
'Category:Simulium',
'Category:Sphaeroceridae',
'Category:Sphaeroceroidea',
'Category:Sphaeroceroidea genera',
'Category:Sphaeroceroidea stubs',
'Category:Spheginobacchini',
'Category:Stratiomyidae',
'Category:Stratiomyidae stubs',
'Category:Stratiomyoidea',
'Category:Stratiomyomorpha',
'Category:Stratiomyomorpha genera',
'Category:Stratiomyomorpha stubs',
'Category:Strauzia',
'Category:Sympycninae',
'Category:Syrphidae stubs',
'Category:Syrphinae',
'Category:Syrphini',
'Category:Syrphoidea',
'Category:Syrphoidea genera',
'Category:Syrphoidea stubs',
'Category:Tabanidae',
'Category:Tabanoidea',
'Category:Tabanoidea genera',
'Category:Tabanoidea stubs',
'Category:Tabanomorpha',
'Category:Tabanomorpha genera',
'Category:Tabanomorpha stubs',
'Category:Tachina',
'Category:Tachina stubs',
'Category:Tachinidae',
'Category:Tachinidae genera',
'Category:Tachinidae stubs',
'Category:Tachininae',
'Category:Tachininae stubs',
'Category:Tachiniscinae',
'Category:Tanypodinae',
'Category:Tephritidae',
'Category:Tephritidae genera',
'Category:Tephritidae stubs',
'Category:Tephritinae',
'Category:Tephritinae stubs',
'Category:Tephritoidea',
'Category:Tephritoidea genera',
'Category:Tephritoidea stubs',
'Category:Tetanops',
'Category:Thaumaleidae',
'Category:Therevidae',
'Category:Timia (fly)',
'Category:Tipulidae',
'Category:Tipulidae stubs',
'Category:Tipuloidea',
'Category:Tipuloidea genera',
'Category:Tipuloidea stubs',
'Category:Tipulomorpha',
'Category:Tipulomorpha genera',
'Category:Tipulomorpha stubs',
'Category:Toxorhynchites',
'Category:Tripteroides',
'Category:Trypeta',
'Category:Trypeta stubs',
'Category:Trypetinae',
'Category:Trypetinae stubs',
'Category:Ulidia',
'Category:Ulidiidae',
'Category:Ulidiidae stubs',
'Category:Ulidiinae',
'Category:Uranotaenia',
'Category:Urophora',
'Category:Urophora stubs',
'Category:Vermileonomorpha',
'Category:Xanthochlorinae',
'Category:Xylomyidae',
'Category:Xylophagidae',
'Category:Xylophagomorpha',
'Category:Xylophagomorpha stubs',
);
my @cats=keys %catmap;
my @iterators=(
{
Line 488 ⟶ 69:
my $set_empty_importance = 0;
sub copy_importance {
#return ($_[0]->WPBmax($_[2]))[1];
#return '';
}
 
# Banner configurations.
my $main_banner='WikiProject DipteraHigher education';
my @preprocess_templates=();
my %banner_cfgs=(
'WikiProject DipteraHigher education' => {
meta => 01,
canonicalizeimportance => 'WikiProject Diptera',
canonicalize => 'WikiProject Higher education',
},
);
 
# Extra parameters (e.g. workgroup).
my @bio_wg = (
my @extra_params=();
);
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 523 ⟶ 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 605 ⟶ 201:
my ($outtxt,$nowiki)=$api->strip_nowiki($intxt);
 
my @params=()@extra_params;
 
my $assess = undef;
Line 643 ⟶ 239:
}
 
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 661 ⟶ 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 676 ⟶ 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 746 ⟶ 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' && exists($cfg{'meta'}) &&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) && exists($cfg{'meta'})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 844 ⟶ 453:
return 600;
}
 
1;
 
</syntaxhighlight>