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

Content deleted Content added
AnomieBOT (talk | contribs)
Updating published sources: TFATitleSubpageCreator: * Move to AnomieBOT II * Approved SourceUploader: * Add a new bit of metadata, with a new column in the output. All: * Add the new metadata field.
AnomieBOT (talk | contribs)
Updating published sources: OrphanReferenceFixer: * Update tag parameter recognition. WikiProjectWorker: * Start run for WikiProject Food and drink.
Line 34:
 
### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject BiographyFood and drink 1|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=1213;
 
### How to find the pages?
Line 45:
my @iterators=(
{
generator => 'linksembeddedin',
titles geititle => 'User:Anomie/Sandbox3',[
'Template:WPMIX', 'Template:Cocktails Project', 'Template:WikiProject Mixed Drinks', 'Template:Wpmix', 'Template:WP Mixed Drinks',
gpllimit => '100',
'Template:WPSD', 'Template:Soda', 'Template:WikiProject Soft Drinks',
'Template:WikiProject Ice Cream', 'Template:WP Ice Cream',
'Template:WikiProject Bartending', 'Template:WPBAR',
}],
gpllimitgeilimit => '100',
},
);
Line 54 ⟶ 59:
### page to tag (or undef to skip).
sub filter {
# $_[0]->{'title'}='Talk:'.$_[0]->{'title'} if $_[0]->{'ns'}==0;
# $_[0]->{'title'}=~s/^([^:]*):/$1 talk:/ if($_[0]->{'ns'}!=0 && ($_[0]->{'ns'}&1)==0);
return $_[0]->{'title'};
}
Line 61 ⟶ 66:
### How to copy other projects' assessments
sub copy_class {
return ''($_[0]->WPBmax($_[2]))[0];
#return '';
}
 
sub copy_importance {
return ''($_[0]->WPBmax($_[2]))[1];
#return '';
}
 
# Banner configurations.
my $main_banner='WPBiographyWikiProject Food and drink';
my @preprocess_templates=('WikiProject Food and drink');
my %banner_cfgs=(
'WPBiographyWikiProject Food and drink' => {
meta => 01,
importance => '',
blp => qr/(?:living|blpo)\s*=\s*+(?!(?i)no|n|0|$|¬)/,
activepol => qr/activepol\s*=\s*+(?!(?i)no|n|0|$|¬)/,
},
);
 
my %wg@main_banners=(
$main_banner,
'a&e-work-group' => 'a&e-priority',
'Food and drink',
'filmbio-work-group' => 'filmbio-priority',
'WPFOOD',
'musician-work-group' => 'musician-priority',
'WPCUISINE',
'military-work-group' => 'military-priority',
'F&D',
'peerage-work-group' => 'peerage-priority',
'Wpfood',
'politician-work-group' => 'politician-priority',
'WikiProject Food and Drink',
'royalty-work-group' => 'royalty-priority',
'Food',
's&a-work-group' => 's&a-priority',
'Wikiproject Food and drink',
'sports-work-group' => 'sports-priority',
'WP Food',
'Wikiproject Food and Drink',
'WikiProject Food',
'WikiProject FOOD',
'Wpf',
);
my %wg2=(reverse %wg);
 
 
sub new {
Line 112 ⟶ 119:
 
sub approved {
return -1;
}
 
Line 215 ⟶ 222:
next;
}
#push @params, "importance=$imp" if ($imp//'') eqne '';
}
 
my $need_main_banner = ($api->WPBcheck($outtxt, $main_banner) == 0);
# }grr...
my @pp$need_main_banner=()1;
$api->WPBcheck($outtxt, sub {
my $impbanner=undefshift;
my $ctname=0shift;
$need_main_banner=0 if(grep $name eq $_, @main_banners);
myreturn $any=0undef;
}, $params=\@ppmain_banner);
 
### PROCESSING ###
Line 233 ⟶ 248:
my $wikitext=shift;
 
myreturn $imp=undef if(grep $name eq $_, @main_banners);
 
my $ct++soda=undef;
$soda='soda=yes' if(grep $name eq $_, ('WPSD','Soda','WikiProject Soft Drinks'));
my # skip$mix=undef;
$mix='mix=yes' if(grep $name eq $_, ('WPMIX', 'Cocktails Project', 'WikiProject Mixed Drinks', 'Wpmix', 'WP Mixed Drinks'));
$mix='bar=yes' if(grep $name eq $_, ('WikiProject Bartending', 'WPBAR'));
}my else {$icecream=undef;
$icecream='ice cream=yes' if(grep $name eq $_, ('WikiProject Ice Cream', 'WP Ice Cream'));
push @ppmerge, $1name;
}my $pp='';
foreach (@$params){
$impsoda="$1=yes" if /^\s*importance\s*=\s*(\S.*?coffee|tea|c&t)\s*$=/;
$priomix="$1=yes" if $p=~/^\s*priority\s*=\s*(\S.*?bar)\s*$=/;
next if $ppp.=~"|$_" if /^\s*(?:priorityclass|importance|needs-photo)\s*=/;
}
push @mergeparams, $bannersoda if defined($soda);
push @params, 'sfba=yes',$mix if defined($impmix)?"sfba-importance=$imp":() if $banner eq 'SFBAProject';
return push @params, $wikitexticecream unlessif defined($prioicecream);
 
return '' unless $need_main_banner;
$need_main_banner=0;
return "{{$main_banner$pp}}";
}, @preprocess_templates);
if(ref($outtxt) eq 'HASH'){
Line 251 ⟶ 279:
$merge[-1]='and '.$merge[-1] if @merge>1;
push @summary, "merging ".join((@merge>2)?', ':' ', @merge)." into $main_banner" if @merge;
#} else {
# $api->warn("$title contains ".$iter->iterval.", but not in section 0\n");
# next;
}
}
Line 276 ⟶ 304:
$outtxt=$api->WPBadd($outtxt, $assess, sub {
shift; # banner
my $name=shift; # name
my $oname=shift;
my $params=shift;
Line 283 ⟶ 311:
return '' if $new;
 
myreturn $prio=undef unless(grep $name eq $_, @main_banners);
my $imp=undef;
foreach my $p (@$params){
$prio=$1 if $p=~/^\s*priority\s*=\s*(\S.*?)\s*$/;
$prio=$1 if $p=~/^\s*(?:a&e|filmbio|musician|military|peerage|politician|royalty|s&a)-priority\s*=\s*(\S.*?)\s*$/;
$imp=$1 if $p=~/^\s*importance\s*=\s*(\S.*?)\s*$/;
}
$prio//=$imp;
return $wikitext unless defined($prio);
my @pp=();
my $ct=0;
my $any=0;
foreach my $p (@$params){
next if $p=~/^\s*(?:priority|importance)\s*=/;
if($p=~/^(\s*([^=]*?)\s*=\s*+(?!(?i)no|n|0|$|¬).*?)(\s*)$/ && exists($wg{$2})){
push @pp, $1;
push @pp, $wg{$2}.'='.$prio.$3;
$ct++;
$any=1 if $1=~/sports-work-group/;
} elsif($p=~/^(\s*([^=]*?)\s*=\s*+(?!(?i)no|n|0|$|¬).*?)(\s*)$/ && exists($wg2{$2})){
# skip
} else {
push @pp, $p;
}
}
return $wikitext unless($any && $ct>=2);
$params=\@pp;
 
$any=0;
foreach my $p (@params){
next unless $p=~/^(.+?)=(.*)$/;
Line 318 ⟶ 319:
unless(grep(/^\s*\Q$k\E\s*=\s*$re/, @$params)){
next if(grep(/^\s*\Q$k\E\s*=\s*\Q$v\E\s*$/s, @$params));
pushunshift @$params, "$k=$v" unless(grep(s/^(\s*\Q$k\E\s*=\s*?)(?:\S.*?)?(\s*)$/$1$v$2/s, @$params));
$any=1 if($v ne '' || $k ne 'importance');
}
}
#return $wikitext unless $any;
 
my $out="{{$oname";
$out.="|".join("|", @$params) if @$params;
$out.="}}";
return $wikitext if $out eq $wikitext;
push @summary, "updating {{$main_banner}} workgroup priority" unless @summary;
return $out;
}, $main_banner, @params);