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

Content deleted Content added
No edit summary
Tag: Reverted
AnomieBOT (talk | contribs)
Updating published sources: SourceUploader: * Improve list handling for doc pages. * Add a TemplateStyles stylesheet to doc pages. * Cleanup some manpage refs.
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{ombox|type=notice|text= Per [[WP:BOT#Approval]], any bot or automated editing process that only affects only the operators' user and talk pages (or subpages thereof), and which are not otherwise disruptive, may be run without prior approval.}}
<syntaxhighlight lang="perl">
package tasks::SourceUploader;
 
=pod
 
=begin metadata
 
Bot: AnomieBOT
Task: SourceUploader
BRFA: N/A
Status: Begun 2008-08-15
Created: 2008-08-16
 
Updates the pages under [[User:AnomieBOT/source]] to reflect the current source
of the bot.
 
=end metadata
 
=cut
 
use utf8;
use strict;
 
use AnomieBOT::Task qw/:time/;
use vars qw/@ISA/;
@ISA=qw/AnomieBOT::Task/;
 
use Storable qw/dclone/;
use URI::Escape;
use tasks::SourceUploader::WikiPod;
Line 6 ⟶ 34:
use Fcntl ':mode';
 
my %extensions=(
'pl' => 'perl',
'pm' => 'perl',
Line 37 ⟶ 65:
my $class=shift;
my $self=$class->SUPER::new();
$self->{'pages'}={};
$self->{'loadexisting'}=1;
$self->{'order'}=-1000;
$self->{'fail'}=0;
return $self;
}
 
sub build_sources {
my $self = shift;
 
my $basedir=$AnomieBOT::API::basedir;
Line 47 ⟶ 79:
$self->{'fail'}=1;
AnomieBOT::API->warn("Cannot find source directory\n");
return $self;
}
 
Line 54 ⟶ 86:
$self->{'fail'}=1;
AnomieBOT::API->warn("Cannot load changelog: $!\n");
return $self;
}
local $_;
Line 86 ⟶ 118:
$self->{'fail'}=1;
AnomieBOT::API->warn("Cannot open directory $dir: $!\n");
return $self;
}
 
Line 106 ⟶ 138:
$self->{'fail'}=1;
AnomieBOT::API->warn("Cannot open file $p: $!\n");
return $self;
}
do {
Line 131 ⟶ 163:
$parser->output_string(\$x);
$parser->parse_string_document($pages{$pp});
$pages{"$pp/doc"}="<templatestyles src=\"User:$mainbot/source-docs.css\"/>\n$x" if($parser->content_seen);
 
# Handle embedded notices and metadata
Line 256 ⟶ 288:
$self->{'pages'}={%pages};
$self->{'tasklists'}=\%tasklists;
return $self;
}
 
Line 262 ⟶ 293:
my ($self, $api)=@_;
 
return undef if $self->{'fail'};
 
$self->build_sources() unless defined( $self->{'pages'} );
return undef if $self->{'fail'};
 
Line 280 ⟶ 314:
my $iter=$api->iterator(
list => 'allpages',
apprefix => $api->user.'/source/',
apnamespace => '2',
aplimit => 'max'
Line 488 ⟶ 522:
return "01 Current" if($botnum>0 && $status=~/^Begun \d{4}-\d{2}-\d{2}$/);
return "02 On demand" if(exists($metadata{'ondemand'}) && $metadata{'ondemand'} eq 'true');
}
}WRMFkcvnmhuvieeeeehet
if($status=~/^Approved \d{4}-\d{2}-\d{2}$/){
return "01 Current" if $botnum>0;