### Request link, for edit summary.
my $req="[[User:AnomieBOT/req/WikiProject CaliforniaTrains 21|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=89;
### How to find the pages?
my @cats=(
'Category:Unassessed California articles',
'Category:Unknown-importance California articles',
'Category:California ranchos',
);
my @iterators=(
{
generator => 'embeddedinlinks',
geititletitles => ['TemplateUser:SFBAProjectNE2/TWP'],
geifilterredirgpllimit => 'nonredirects100',
geilimit => '100',
prop => 'categories|templates',
clcategories => 'Category:Unincorporated communities in California|Category:Ghost towns in California|Category:California ranchos',
cllimit => 'max',
tllimit => 'max',
},
);
### page to tag (or undef to skip).
sub filter {
return undef if $_[0]->{'redirect'};
$_[0]->{'title'}='Talk:'.$_[0]->{'title'} if $_[0]->{'ns'}==0;
$_[0]->{'title'}=~s/^([^:]*):/$1 talk:/ if($_[0]->{'ns'}!=0 && ($_[0]->{'ns'}&1)==0);
### How to copy other projects' assessments
sub copy_class {
return ($_[0]->WPBmax($_[2]))[0]'';
}
# Banner configurations.
my $main_banner='WikiProject CaliforniaTrainsWikiProject';
my @preprocess_templates=('SFBAProject');
my %banner_cfgs=(
'WikiProject CaliforniaTrainsWikiProject' => {
meta => 0,
stubauto => 'auto',
},
);
sub approved {
return -1;
}
}
$api->WPBconfig(%cfg);
my %r=$api->redirects_to('Template:Infobox settlement');
if(exists($r{''})){
$api->warn("Failed to get Infobox Settlement redirects: ".$r{''}{'error'}."\n");
return 60;
}
$self->{'settle'}=\%r;
$self->{'config loaded'}=1;
$api->log("Checking $title...");
my $intxt=exists($tok->{'revisions'}[0]{'*'})?$tok->{'revisions'}[0]{'*'}: // '';
my ($outtxt,$nowiki)=$api->strip_nowiki($intxt);
$page=$api->query(
titles => $pg,
prop => 'categories|templates',
clcategories => 'Category:Unincorporated communities in California|Category:Ghost towns in California|Category:California ranchos',
cllimit => 'max',
tllimit => 'max',
);
if($page->{'code'} eq 'shutoff'){
}
mypush $imp@params, 'stations=yes'' if($pg=~/station|depot/i);
if(grep($_->{'title'} eq 'Category:Unincorporated communities in California', @{$page->{'categories'}})){
$imp='low';
} elsif(grep($_->{'title'} eq 'Category:Ghost towns in California', @{$page->{'categories'}})){
$imp='low';
} elsif(grep($_->{'title'} eq 'Category:California ranchos', @{$page->{'categories'}})){
$imp='mid';
} elsif(grep($_->{'title'} eq 'Template:Infobox settlement', @{$page->{'templates'}})){
$pg=$api->rawpage($page->{'title'});
if($pg->{'code'} eq 'shutoff'){
$api->warn("Task disabled: ".$pg->{'content'}."\n");
return 300;
}
if($pg->{'code'} ne 'success'){
$api->warn("Could not load $page->{title} content: ".$pg->{'error'}."\n");
return 60;
}
$pg=$pg->{'content'};
my $pop=undef;
$api->process_templates($pg, sub {
my $name=shift;
my $params=shift;
my $wikitext=shift;
shift; # $data
my $oname=shift;
return undef unless(exists($self->{'settle'}{"Template:$name"}));
my %pop=();
foreach (@$params){
$pop{$1}=$2 if /^\s*(population(?:|_total|_metro|_urban|_est))\s*=\s*([0-9,]+)\s*$/;
}
$pop=($pop{'population'} // $pop{'population_total'} // $pop{'population_est'} // $pop{'population_metro'} // $pop{'population_urban'} // undef);
$pop=~s/,//g if defined($pop);
}, undef);
if(defined($pop)){
$imp='low';
$imp='mid' if $pop>=25000;
$imp='high' if $pop>=100000;
}
}
push @params, "importance=$imp";
$outtxt=$api->WPBadd($outtxt, $assess, sub {
|