Ignore:
Timestamp:
2001-10-09T17:21:29+13:00 (23 years ago)
Author:
sjboddie
Message:

The build process now creates a summary of how many files were included,
which were rejected, etc. A link to a page containing this summary is
provided from the final page of the collector (once the collection is built
successfully) and from the default "about this collection" text for
collections built by the collector.

Also did a little bit of tidying in a couple of places

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugin.pm

    r2755 r2785  
    2828require util;
    2929
     30my $stats = {'num_processed' => 0,
     31         'num_blocked' => 0,
     32         'num_not_processed' => 0,
     33         'num_archives' => 0
     34         };
     35
    3036sub load_plugins {
    3137    my ($plugin_list) = shift @_;
    32     ($verbosity, $outhandle, $faillogname) = @_; # globals
     38    ($verbosity, $outhandle, $failhandle) = @_; # globals
    3339    my @plugin_objects = ();
    3440
    3541    $verbosity = 2 unless defined $verbosity;
    3642    $outhandle = STDERR unless defined $outhandle;
     43    $failhandle = STDERR unless defined $failhandle;
    3744
    3845    foreach $pluginoptions (@$plugin_list) {
     
    5865   
    5966    # initialize plugin
    60     $plugobj->init($verbosity, $outhandle, $faillogname);
     67    $plugobj->init($verbosity, $outhandle, $failhandle);
    6168
    6269    # add this object to the list
     
    94101    return $rv if defined $rv;
    95102    }
     103
     104    if ($verbosity >= 2) {
     105    print $outhandle "WARNING - no plugin could process $file\n";
     106    }
    96107   
    97     if ($verbosity >= 2) {
    98     print $outhandle "WARNING - no plugin could process " .
    99         &util::filename_cat($base_dir,$file) . "\n";
     108    $file =~ s/([^\\\/]+)$/$1/;
     109    print $failhandle "$file: no plugin could process this file\n";
     110    $stats->{'num_not_processed'} ++;
     111
     112    return 0;
     113}
     114
     115# write out some general stats that the plugins have compiled - note that
     116# the buildcol.pl process doesn't currently call this process so the stats
     117# are only output after import.pl -
     118sub write_stats {
     119    my ($pluginfo, $statshandle) = @_;
     120
     121    foreach $plugobj (@$pluginfo) {
     122    $plugobj->compile_stats($stats);
    100123    }
    101     return 0;
     124
     125    my $total = $stats->{'num_processed'} + $stats->{'num_blocked'} +
     126    $stats->{'num_not_processed'};
     127
     128    if ($total == 1) {
     129    print $statshandle "* 1 document was considered for processing\n";
     130    } else {
     131    print $statshandle "* $total documents were considered for processing\n";
     132    }
     133    if ($stats->{'num_archives'}) {
     134    print $statshandle "   (including the contents of " . $stats->{'num_archives'} .
     135        " ZIP/TAR archive";
     136    if ($stats->{'num_archives'} == 1) {print $statshandle ")\n";}
     137    else {print $statshandle "s)\n";}
     138    }
     139    if ($stats->{'num_processed'} == 1) {
     140    print $statshandle "* 1 was processed and included in the collection\n";
     141    } else {
     142    print $statshandle "* " . $stats->{'num_processed'} . " were processed and included in the collection\n";
     143    }
     144    if ($stats->{'num_not_processed'} == 1) {
     145    print $statshandle "* 1 was rejected.";
     146    } else {
     147    print $statshandle "* " . $stats->{'num_not_processed'} . " were rejected.";
     148    }
     149    print $statshandle " See the fail log for a list of rejected documents\n";
     150   
    102151}
    103152
Note: See TracChangeset for help on using the changeset viewer.