[537] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # plugin.pm -- functions to handle using plugins
|
---|
| 4 | # A component of the Greenstone digital library software
|
---|
| 5 | # from the New Zealand Digital Library Project at the
|
---|
| 6 | # University of Waikato, New Zealand.
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 9 | #
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful,
|
---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | # GNU General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with this program; if not, write to the Free Software
|
---|
| 22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | #
|
---|
| 24 | ###########################################################################
|
---|
[4] | 25 |
|
---|
| 26 | package plugin;
|
---|
| 27 |
|
---|
[21307] | 28 |
|
---|
[7829] | 29 | use strict; # to pick up typos and undeclared variables...
|
---|
| 30 | no strict 'refs'; # ...but allow filehandles to be variables and vice versa
|
---|
[10579] | 31 | no strict 'subs';
|
---|
[7829] | 32 |
|
---|
[134] | 33 | require util;
|
---|
[7829] | 34 | use gsprintf 'gsprintf';
|
---|
[4] | 35 |
|
---|
[15873] | 36 | # mapping from old plugin names to new ones for backwards compatibility
|
---|
[17032] | 37 | # can remove at sometime in future when we no longer want to support old xxPlug names in the config file
|
---|
[15873] | 38 | my $plugin_name_map = {
|
---|
[17746] | 39 | 'GAPlug' => 'GreenstoneXMLPlugin',
|
---|
[15873] | 40 | 'ArcPlug' => 'ArchivesInfPlugin',
|
---|
| 41 | 'RecPlug' => 'DirectoryPlugin',
|
---|
| 42 | 'TEXTPlug' => 'TextPlugin',
|
---|
[17731] | 43 | 'XMLPlug' => 'ReadXMLFile',
|
---|
[15873] | 44 | 'EMAILPlug' => 'EmailPlugin',
|
---|
| 45 | 'SRCPlug' => 'SourceCodePlugin',
|
---|
| 46 | 'NULPlug' => 'NulPlugin',
|
---|
[17731] | 47 | 'W3ImgPlug' => 'HTMLImagePlugin',
|
---|
[17030] | 48 | 'PagedImgPlug' => 'PagedImagePlugin',
|
---|
[17724] | 49 | 'METSPlug' => 'GreenstoneMETSPlugin',
|
---|
| 50 | 'PPTPlug' => 'PowerPointPlugin',
|
---|
[17731] | 51 | 'PSPlug' => 'PostScriptPlugin',
|
---|
[17724] | 52 | 'DBPlug' => 'DatabasePlugin'
|
---|
[15873] | 53 | };
|
---|
| 54 |
|
---|
[7829] | 55 | # global variables
|
---|
[2785] | 56 | my $stats = {'num_processed' => 0,
|
---|
| 57 | 'num_blocked' => 0,
|
---|
| 58 | 'num_not_processed' => 0,
|
---|
[7363] | 59 | 'num_not_recognised' => 0,
|
---|
[2785] | 60 | 'num_archives' => 0
|
---|
| 61 | };
|
---|
| 62 |
|
---|
[7829] | 63 | #globaloptions contains any options that should be passed to all plugins
|
---|
| 64 | my ($verbosity, $outhandle, $failhandle, $globaloptions);
|
---|
[5682] | 65 |
|
---|
[15873] | 66 | sub get_valid_pluginname {
|
---|
| 67 | my ($pluginname) = @_;
|
---|
| 68 | my $valid_name = $pluginname;
|
---|
| 69 | if (defined $plugin_name_map->{$pluginname}) {
|
---|
| 70 | $valid_name = $plugin_name_map->{$pluginname};
|
---|
| 71 | } elsif ($pluginname =~ /Plug$/) {
|
---|
| 72 | $valid_name =~ s/Plug/Plugin/;
|
---|
| 73 |
|
---|
| 74 | }
|
---|
| 75 | return $valid_name;
|
---|
| 76 | }
|
---|
[21290] | 77 |
|
---|
[14933] | 78 | sub load_plugin_require
|
---|
| 79 | {
|
---|
| 80 | my ($pluginname) = @_;
|
---|
| 81 |
|
---|
| 82 | my @check_list = ();
|
---|
| 83 |
|
---|
| 84 | # pp_plugname shorthand for 'perllib' 'plugin' '$pluginname.pm'
|
---|
| 85 | my $pp_plugname
|
---|
| 86 | = &util::filename_cat('perllib', 'plugins', "${pluginname}.pm");
|
---|
| 87 | my $collectdir = $ENV{'GSDLCOLLECTDIR'};
|
---|
| 88 |
|
---|
[10579] | 89 | # find the plugin
|
---|
[14239] | 90 | if (defined($ENV{'GSDLCOLLECTION'}))
|
---|
| 91 | {
|
---|
[14933] | 92 | my $customplugname
|
---|
| 93 | = &util::filename_cat($collectdir, "custom",$ENV{'GSDLCOLLECTION'},
|
---|
| 94 | $pp_plugname);
|
---|
| 95 | push(@check_list,$customplugname);
|
---|
[14239] | 96 | }
|
---|
[14933] | 97 |
|
---|
| 98 | my $colplugname = &util::filename_cat($collectdir, $pp_plugname);
|
---|
| 99 | push(@check_list,$colplugname);
|
---|
| 100 |
|
---|
| 101 | if (defined $ENV{'GSDLEXTS'}) {
|
---|
| 102 |
|
---|
| 103 | my $ext_prefix = &util::filename_cat($ENV{'GSDLHOME'}, "ext");
|
---|
| 104 |
|
---|
| 105 | my @extensions = split(/:/,$ENV{'GSDLEXTS'});
|
---|
| 106 | foreach my $e (@extensions) {
|
---|
| 107 | my $extplugname = &util::filename_cat($ext_prefix, $e, $pp_plugname);
|
---|
| 108 | push(@check_list,$extplugname);
|
---|
| 109 |
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
[21290] | 112 | if (defined $ENV{'GSDL3EXTS'}) {
|
---|
[14933] | 113 |
|
---|
[21290] | 114 | my $ext_prefix = &util::filename_cat($ENV{'GSDL3SRCHOME'}, "ext");
|
---|
[14933] | 115 |
|
---|
[21290] | 116 | my @extensions = split(/:/,$ENV{'GSDL3EXTS'});
|
---|
| 117 | foreach my $e (@extensions) {
|
---|
| 118 | my $extplugname = &util::filename_cat($ext_prefix, $e, $pp_plugname);
|
---|
| 119 | push(@check_list,$extplugname);
|
---|
| 120 |
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
[14933] | 125 | my $mainplugname = &util::filename_cat($ENV{'GSDLHOME'}, $pp_plugname);
|
---|
| 126 | push(@check_list,$mainplugname);
|
---|
| 127 |
|
---|
| 128 | my $success=0;
|
---|
| 129 | foreach my $plugname (@check_list) {
|
---|
| 130 | if (-e $plugname) {
|
---|
| 131 | require $plugname;
|
---|
| 132 | $success=1;
|
---|
| 133 | last;
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | if (!$success) {
|
---|
[10579] | 138 | &gsprintf(STDERR, "{plugin.could_not_find_plugin}\n",
|
---|
[14933] | 139 | $pluginname);
|
---|
[10579] | 140 | die "\n";
|
---|
| 141 | }
|
---|
[14933] | 142 | }
|
---|
[10579] | 143 |
|
---|
[14933] | 144 | sub load_plugin_for_info {
|
---|
| 145 | my ($pluginname) = shift @_;
|
---|
[15873] | 146 | $pluginname = &get_valid_pluginname($pluginname);
|
---|
[14933] | 147 | load_plugin_require($pluginname);
|
---|
| 148 |
|
---|
[10579] | 149 | # create a plugin object
|
---|
| 150 | my ($plugobj);
|
---|
| 151 | my $options = "-gsdlinfo";
|
---|
| 152 |
|
---|
| 153 | eval ("\$plugobj = new \$pluginname([],[$options])");
|
---|
| 154 | die "$@" if $@;
|
---|
| 155 |
|
---|
| 156 | return $plugobj;
|
---|
| 157 | }
|
---|
| 158 |
|
---|
[4] | 159 | sub load_plugins {
|
---|
[1431] | 160 | my ($plugin_list) = shift @_;
|
---|
[20578] | 161 | my $incremental_mode;
|
---|
| 162 | ($verbosity, $outhandle, $failhandle, $globaloptions, $incremental_mode) = @_; # globals
|
---|
[4] | 163 | my @plugin_objects = ();
|
---|
[1243] | 164 | $verbosity = 2 unless defined $verbosity;
|
---|
[7829] | 165 | $outhandle = 'STDERR' unless defined $outhandle;
|
---|
| 166 | $failhandle = 'STDERR' unless defined $failhandle;
|
---|
[1243] | 167 |
|
---|
[13933] | 168 | my $colplugindir = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"perllib/plugins");
|
---|
| 169 | unshift (@INC, $colplugindir);
|
---|
| 170 |
|
---|
[6584] | 171 | map { $_ = "\"$_\""; } @$globaloptions;
|
---|
| 172 | my $globals = join (",", @$globaloptions);
|
---|
| 173 |
|
---|
[7829] | 174 | foreach my $pluginoptions (@$plugin_list) {
|
---|
[809] | 175 | my $pluginname = shift @$pluginoptions;
|
---|
| 176 | next unless defined $pluginname;
|
---|
[15873] | 177 | $pluginname = &get_valid_pluginname($pluginname);
|
---|
[14933] | 178 | load_plugin_require($pluginname);
|
---|
[4] | 179 |
|
---|
| 180 | # create a plugin object
|
---|
| 181 | my ($plugobj);
|
---|
[809] | 182 | map { $_ = "\"$_\""; } @$pluginoptions;
|
---|
| 183 | my $options = join (",", @$pluginoptions);
|
---|
[6584] | 184 | if ($globals) {
|
---|
| 185 | if (@$pluginoptions) {
|
---|
| 186 | $options .= ",";
|
---|
| 187 | }
|
---|
| 188 | $options .= "$globals";
|
---|
| 189 | }
|
---|
[20613] | 190 | # need to escape backslash before putting in to the eval
|
---|
[22087] | 191 | # but watch out for any \" (which shouldn't be further escaped)
|
---|
[22221] | 192 | $options =~ s/\\([^"])/\\\\$1/g; #"
|
---|
[1244] | 193 | $options =~ s/\$/\\\$/g;
|
---|
[22087] | 194 |
|
---|
[10218] | 195 | eval ("\$plugobj = new \$pluginname([],[$options])");
|
---|
[4] | 196 | die "$@" if $@;
|
---|
[809] | 197 |
|
---|
[1243] | 198 | # initialize plugin
|
---|
[2785] | 199 | $plugobj->init($verbosity, $outhandle, $failhandle);
|
---|
[10478] | 200 |
|
---|
[20578] | 201 | $plugobj->set_incremental($incremental_mode);
|
---|
[1243] | 202 |
|
---|
[4] | 203 | # add this object to the list
|
---|
| 204 | push (@plugin_objects, $plugobj);
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | return \@plugin_objects;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
[835] | 210 |
|
---|
| 211 | sub begin {
|
---|
[11333] | 212 | my ($pluginfo, $base_dir, $processor, $maxdocs, $gli) = @_;
|
---|
[835] | 213 |
|
---|
[11333] | 214 | map { $_->{'gli'} = $gli; } @$pluginfo;
|
---|
[835] | 215 | map { $_->begin($pluginfo, $base_dir, $processor, $maxdocs); } @$pluginfo;
|
---|
| 216 | }
|
---|
| 217 |
|
---|
[21307] | 218 | sub remove_all {
|
---|
[21290] | 219 | my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
|
---|
| 220 |
|
---|
[21307] | 221 | map { $_->remove_all($pluginfo, $base_dir, $processor, $maxdocs); } @$pluginfo;
|
---|
[21290] | 222 | }
|
---|
| 223 |
|
---|
[21307] | 224 | sub remove_some {
|
---|
[21618] | 225 | my ($pluginfo, $infodbtype, $archivedir, $deleted_files) = @_;
|
---|
[21307] | 226 | return if (scalar(@$deleted_files)==0);
|
---|
[23170] | 227 | $infodbtype = "gdbm" if $infodbtype eq "gdbm-txtgz";
|
---|
[21618] | 228 | my $arcinfo_src_filename = &dbutil::get_infodb_file_path($infodbtype, "archiveinf-src", $archivedir);
|
---|
[21290] | 229 |
|
---|
[21307] | 230 | foreach my $file (@$deleted_files) {
|
---|
[21564] | 231 | # use 'archiveinf-src' info database to look up all the OIDs
|
---|
[21307] | 232 | # that this file is used in (note in most cases, it's just one OID)
|
---|
| 233 |
|
---|
[21618] | 234 | my $src_rec_string = &dbutil::read_infodb_entry($infodbtype, $arcinfo_src_filename, $file);
|
---|
[21554] | 235 | my $src_rec = &dbutil::convert_infodb_string_to_hash($src_rec_string);
|
---|
[21307] | 236 | my $oids = $src_rec->{'oid'};
|
---|
[21314] | 237 | my $rv;
|
---|
| 238 | foreach my $plugobj (@$pluginfo) {
|
---|
| 239 |
|
---|
| 240 | $rv = $plugobj->remove_one($file, $oids, $archivedir);
|
---|
| 241 | if (defined $rv && $rv != -1) {
|
---|
| 242 | return $rv;
|
---|
| 243 | } # else undefined (was not recognised by the plugin) or there was an error, try the next one
|
---|
| 244 | }
|
---|
| 245 | return 0;
|
---|
[21307] | 246 | }
|
---|
| 247 |
|
---|
| 248 | }
|
---|
[16381] | 249 | sub file_block_read {
|
---|
| 250 | my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $gli) = @_;
|
---|
[10155] | 251 |
|
---|
[16381] | 252 |
|
---|
| 253 | $gli = 0 unless defined $gli;
|
---|
| 254 |
|
---|
| 255 | my $rv = 0;
|
---|
| 256 | my $glifile = $file;
|
---|
| 257 |
|
---|
| 258 | $glifile =~ s/^[\/\\]+//; # file sometimes starts with a / so get rid of it
|
---|
| 259 |
|
---|
| 260 | # Announce to GLI that we are handling a file
|
---|
| 261 | print STDERR "<File n='$glifile'>\n" if $gli;
|
---|
| 262 |
|
---|
| 263 | # the .kill file is a handy (if not very elegant) way of aborting
|
---|
| 264 | # an import.pl or buildcol.pl process
|
---|
| 265 | if (-e &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, ".kill")) {
|
---|
| 266 | gsprintf($outhandle, "{plugin.kill_file}\n");
|
---|
| 267 | die "\n";
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | foreach my $plugobj (@$pluginfo) {
|
---|
| 271 |
|
---|
| 272 | $rv = $plugobj->file_block_read($pluginfo, $base_dir, $file, $block_hash, $metadata, $gli);
|
---|
| 273 | #last if (defined $rv && $rv==1); # stop this file once we have found something to 'process' it
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 |
|
---|
[8515] | 279 | sub metadata_read {
|
---|
[19497] | 280 | my ($pluginfo, $base_dir, $file, $block_hash,
|
---|
| 281 | $extrametakeys, $extrametadata, $extrametafile,
|
---|
[23212] | 282 | $processor, $gli, $aux) = @_;
|
---|
[8515] | 283 |
|
---|
| 284 | $gli = 0 unless defined $gli;
|
---|
| 285 |
|
---|
| 286 | my $rv = 0;
|
---|
| 287 | my $glifile = $file;
|
---|
| 288 |
|
---|
| 289 | $glifile =~ s/^[\/\\]+//; # file sometimes starts with a / so get rid of it
|
---|
| 290 |
|
---|
| 291 | # Announce to GLI that we are handling a file
|
---|
| 292 | print STDERR "<File n='$glifile'>\n" if $gli;
|
---|
| 293 |
|
---|
| 294 | # the .kill file is a handy (if not very elegant) way of aborting
|
---|
| 295 | # an import.pl or buildcol.pl process
|
---|
| 296 | if (-e &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, ".kill")) {
|
---|
| 297 | gsprintf($outhandle, "{plugin.kill_file}\n");
|
---|
| 298 | die "\n";
|
---|
| 299 | }
|
---|
| 300 |
|
---|
| 301 | my $had_error = 0;
|
---|
| 302 | # pass this file by each of the plugins in turn until one
|
---|
| 303 | # is found which will process it
|
---|
| 304 | # read must return:
|
---|
| 305 | # undef - could not recognise
|
---|
| 306 | # -1 - tried but error
|
---|
| 307 | # 0 - blocked
|
---|
| 308 | # anything else for successful processing
|
---|
| 309 |
|
---|
| 310 | foreach my $plugobj (@$pluginfo) {
|
---|
| 311 |
|
---|
[16381] | 312 | $rv = $plugobj->metadata_read($pluginfo, $base_dir, $file, $block_hash,
|
---|
[19497] | 313 | $extrametakeys, $extrametadata, $extrametafile,
|
---|
[23212] | 314 | $processor, $gli, $aux);
|
---|
[8515] | 315 |
|
---|
| 316 | if (defined $rv) {
|
---|
| 317 | if ($rv == -1) {
|
---|
| 318 | # an error has occurred
|
---|
| 319 | $had_error = 1;
|
---|
| 320 | print STDERR "<ProcessingError n='$glifile'>\n" if $gli;
|
---|
| 321 | } else {
|
---|
| 322 | return $rv;
|
---|
| 323 | }
|
---|
| 324 | } # else undefined - was not recognised by the plugin
|
---|
| 325 | }
|
---|
| 326 |
|
---|
| 327 | return 0;
|
---|
| 328 | }
|
---|
| 329 |
|
---|
[4] | 330 | sub read {
|
---|
[16381] | 331 | my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $processor, $maxdocs, $total_count, $gli, $aux) = @_;
|
---|
[4] | 332 |
|
---|
[809] | 333 | $maxdocs = -1 unless defined $maxdocs && $maxdocs =~ /\d/;
|
---|
[9853] | 334 | $total_count = 0 unless defined $total_count && $total_count =~ /\d/;
|
---|
[6332] | 335 | $gli = 0 unless defined $gli;
|
---|
| 336 |
|
---|
[315] | 337 | my $rv = 0;
|
---|
[7363] | 338 | my $glifile = $file;
|
---|
[7904] | 339 |
|
---|
[7363] | 340 | $glifile =~ s/^[\/\\]+//; # file sometimes starts with a / so get rid of it
|
---|
[8515] | 341 |
|
---|
[6332] | 342 | # Announce to GLI that we are handling a file
|
---|
[7363] | 343 | print STDERR "<File n='$glifile'>\n" if $gli;
|
---|
[8515] | 344 |
|
---|
[1454] | 345 | # the .kill file is a handy (if not very elegant) way of aborting
|
---|
| 346 | # an import.pl or buildcol.pl process
|
---|
| 347 | if (-e &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, ".kill")) {
|
---|
[7829] | 348 | gsprintf($outhandle, "{plugin.kill_file}\n");
|
---|
[1454] | 349 | die "\n";
|
---|
| 350 | }
|
---|
[18441] | 351 |
|
---|
[7363] | 352 | my $had_error = 0;
|
---|
[4] | 353 | # pass this file by each of the plugins in turn until one
|
---|
| 354 | # is found which will process it
|
---|
[7363] | 355 | # read must return:
|
---|
| 356 | # undef - could not recognise
|
---|
| 357 | # -1 - tried but error
|
---|
| 358 | # 0 - blocked
|
---|
| 359 | # anything else for successful processing
|
---|
[8515] | 360 |
|
---|
[7829] | 361 | foreach my $plugobj (@$pluginfo) {
|
---|
[8515] | 362 |
|
---|
| 363 | $rv = $plugobj->read($pluginfo, $base_dir, $file,
|
---|
[16381] | 364 | $block_hash, $metadata, $processor, $maxdocs,
|
---|
| 365 | $total_count, $gli, $aux);
|
---|
[8515] | 366 |
|
---|
| 367 | if (defined $rv) {
|
---|
[7363] | 368 | if ($rv == -1) {
|
---|
[7904] | 369 | # an error has occurred
|
---|
[7363] | 370 | $had_error = 1;
|
---|
| 371 | } else {
|
---|
[7904] | 372 | return $rv;
|
---|
[7363] | 373 | }
|
---|
| 374 | } # else undefined - was not recognised by the plugin
|
---|
[4] | 375 | }
|
---|
[7904] | 376 |
|
---|
[7363] | 377 | if ($had_error) {
|
---|
| 378 | # was recognised but couldn't be processed
|
---|
| 379 | if ($verbosity >= 2) {
|
---|
[7829] | 380 | gsprintf($outhandle, "{plugin.no_plugin_could_process}\n", $file);
|
---|
[7363] | 381 | }
|
---|
| 382 | # tell the GLI that it was not processed
|
---|
| 383 | print STDERR "<NonProcessedFile n='$glifile'>\n" if $gli;
|
---|
[7904] | 384 |
|
---|
[7829] | 385 | gsprintf($failhandle, "$file: {plugin.no_plugin_could_process_this_file}\n");
|
---|
[7363] | 386 | $stats->{'num_not_processed'} ++;
|
---|
| 387 | } else {
|
---|
| 388 | # was not recognised
|
---|
| 389 | if ($verbosity >= 2) {
|
---|
[7829] | 390 | gsprintf($outhandle, "{plugin.no_plugin_could_recognise}\n",$file);
|
---|
[7363] | 391 | }
|
---|
| 392 | # tell the GLI that it was not processed
|
---|
| 393 | print STDERR "<NonRecognisedFile n='$glifile'>\n" if $gli;
|
---|
| 394 |
|
---|
[7829] | 395 | gsprintf($failhandle, "$file: {plugin.no_plugin_could_recognise_this_file}\n");
|
---|
[7363] | 396 | $stats->{'num_not_recognised'} ++;
|
---|
[170] | 397 | }
|
---|
[315] | 398 | return 0;
|
---|
[4] | 399 | }
|
---|
| 400 |
|
---|
[2785] | 401 | # write out some general stats that the plugins have compiled - note that
|
---|
| 402 | # the buildcol.pl process doesn't currently call this process so the stats
|
---|
| 403 | # are only output after import.pl -
|
---|
| 404 | sub write_stats {
|
---|
[6332] | 405 | my ($pluginfo, $statshandle, $faillog, $gli) = @_;
|
---|
[2785] | 406 |
|
---|
[6332] | 407 | $gli = 0 unless defined $gli;
|
---|
| 408 |
|
---|
[7829] | 409 | foreach my $plugobj (@$pluginfo) {
|
---|
[2785] | 410 | $plugobj->compile_stats($stats);
|
---|
| 411 | }
|
---|
| 412 |
|
---|
| 413 | my $total = $stats->{'num_processed'} + $stats->{'num_blocked'} +
|
---|
[7363] | 414 | $stats->{'num_not_processed'} + $stats->{'num_not_recognised'};
|
---|
[2785] | 415 |
|
---|
[7363] | 416 | print STDERR "<ImportComplete considered='$total' processed='$stats->{'num_processed'}' blocked='$stats->{'num_blocked'}' ignored='$stats->{'num_not_recognised'}' failed='$stats->{'num_not_processed'}'>\n" if $gli;
|
---|
[6332] | 417 |
|
---|
[2785] | 418 | if ($total == 1) {
|
---|
[7829] | 419 | gsprintf($statshandle, "* {plugin.one_considered}\n");
|
---|
[2785] | 420 | } else {
|
---|
[7829] | 421 | gsprintf($statshandle, "* {plugin.n_considered}\n", $total);
|
---|
[2785] | 422 | }
|
---|
| 423 | if ($stats->{'num_archives'}) {
|
---|
[5682] | 424 | if ($stats->{'num_archives'} == 1) {
|
---|
[7829] | 425 | gsprintf($statshandle, " ({plugin.including_archive})\n");
|
---|
[5682] | 426 | }
|
---|
| 427 | else {
|
---|
[7829] | 428 | gsprintf($statshandle, " ({plugin.including_archives})\n",
|
---|
| 429 | $stats->{'num_archives'});
|
---|
[5682] | 430 | }
|
---|
[2785] | 431 | }
|
---|
| 432 | if ($stats->{'num_processed'} == 1) {
|
---|
[7829] | 433 | gsprintf($statshandle, "* {plugin.one_included}\n");
|
---|
[2785] | 434 | } else {
|
---|
[7829] | 435 | gsprintf($statshandle, "* {plugin.n_included}\n", $stats->{'num_processed'});
|
---|
[2785] | 436 | }
|
---|
[7363] | 437 | if ($stats->{'num_not_recognised'}) {
|
---|
| 438 | if ($stats->{'num_not_recognised'} == 1) {
|
---|
[7829] | 439 | gsprintf($statshandle, "* {plugin.one_unrecognised}\n");
|
---|
[7363] | 440 | } else {
|
---|
[7829] | 441 | gsprintf($statshandle, "* {plugin.n_unrecognised}\n",
|
---|
| 442 | $stats->{'num_not_recognised'});
|
---|
[7363] | 443 | }
|
---|
| 444 |
|
---|
| 445 | }
|
---|
[2797] | 446 | if ($stats->{'num_not_processed'}) {
|
---|
| 447 | if ($stats->{'num_not_processed'} == 1) {
|
---|
[7829] | 448 | gsprintf($statshandle, "* {plugin.one_rejected}\n");
|
---|
[2797] | 449 | } else {
|
---|
[7829] | 450 | gsprintf($statshandle, "* {plugin.n_rejected}\n",
|
---|
| 451 | $stats->{'num_not_processed'});
|
---|
[5682] | 452 | }
|
---|
[7363] | 453 | }
|
---|
| 454 | if ($stats->{'num_not_processed'} || $stats->{'num_not_recognised'}) {
|
---|
[7829] | 455 | gsprintf($statshandle, " {plugin.see_faillog}\n", $faillog);
|
---|
[2797] | 456 | }
|
---|
[2785] | 457 | }
|
---|
| 458 |
|
---|
[835] | 459 | sub end {
|
---|
[1587] | 460 | my ($pluginfo, $processor) = @_;
|
---|
| 461 | map { $_->end($processor); } @$pluginfo;
|
---|
[835] | 462 | }
|
---|
[4] | 463 |
|
---|
[10155] | 464 | sub deinit {
|
---|
| 465 | my ($pluginfo, $processor) = @_;
|
---|
| 466 |
|
---|
| 467 |
|
---|
| 468 | map { $_->deinit($processor); } @$pluginfo;
|
---|
| 469 | }
|
---|
| 470 |
|
---|
[4] | 471 | 1;
|
---|