Changeset 7829
- Timestamp:
- 2004-07-30T12:57:57+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugin.pm
r7363 r7829 26 26 package plugin; 27 27 28 use strict; # to pick up typos and undeclared variables... 29 no strict 'refs'; # ...but allow filehandles to be variables and vice versa 30 28 31 require util; 29 use gsprintf; 30 32 use gsprintf 'gsprintf'; 33 34 # global variables 31 35 my $stats = {'num_processed' => 0, 32 36 'num_blocked' => 0, … … 36 40 }; 37 41 38 39 sub gsprintf40 {41 return &gsprintf::gsprintf(@_);42 }43 44 42 #globaloptions contains any options that should be passed to all plugins 43 my ($verbosity, $outhandle, $failhandle, $globaloptions); 44 45 45 sub load_plugins { 46 46 my ($plugin_list) = shift @_; … … 49 49 50 50 $verbosity = 2 unless defined $verbosity; 51 $outhandle = STDERRunless defined $outhandle;52 $failhandle = STDERRunless defined $failhandle;51 $outhandle = 'STDERR' unless defined $outhandle; 52 $failhandle = 'STDERR' unless defined $failhandle; 53 53 54 54 map { $_ = "\"$_\""; } @$globaloptions; 55 55 my $globals = join (",", @$globaloptions); 56 56 57 foreach $pluginoptions (@$plugin_list) {57 foreach my $pluginoptions (@$plugin_list) { 58 58 my $pluginname = shift @$pluginoptions; 59 59 next unless defined $pluginname; … … 66 66 if (-e $colplugname) { require $colplugname; } 67 67 elsif (-e $mainplugname) { require $mainplugname; } 68 else { &gsprintf(STDERR, "{plugin.could_not_find_plugin}\n", $pluginname) && die "\n"; 69 # die "ERROR - couldn't find plugin \"$pluginname\"\n"; 70 } 68 else { 69 gsprintf($outhandle, "{plugin.could_not_find_plugin}\n", 70 $pluginname); 71 die "\n"; 72 } 71 73 72 74 # create a plugin object … … 117 119 # an import.pl or buildcol.pl process 118 120 if (-e &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, ".kill")) { 119 &gsprintf($outhandle, "{plugin.kill_file}\n");121 gsprintf($outhandle, "{plugin.kill_file}\n"); 120 122 die "\n"; 121 123 } … … 129 131 # 0 - blocked 130 132 # anything else for successful processing 131 foreach $plugobj (@$pluginfo) {133 foreach my $plugobj (@$pluginfo) { 132 134 $rv = $plugobj->read($pluginfo, $base_dir, $file, 133 135 $metadata, $processor, $maxdocs, $gli, $aux); … … 146 148 # was recognised but couldn't be processed 147 149 if ($verbosity >= 2) { 148 &gsprintf($outhandle, "{plugin.no_plugin_could_process}\n", $file); 149 # print $outhandle "WARNING - no plugin could process $file\n"; 150 gsprintf($outhandle, "{plugin.no_plugin_could_process}\n", $file); 150 151 } 151 152 # tell the GLI that it was not processed … … 153 154 154 155 $file =~ s/.*?([^\\\/]+)$/$1/; 155 &gsprintf($failhandle, "$file: {plugin.no_plugin_could_process_this_file}\n"); 156 # print $failhandle "$file: no plugin could process this file\n"; 156 gsprintf($failhandle, "$file: {plugin.no_plugin_could_process_this_file}\n"); 157 157 $stats->{'num_not_processed'} ++; 158 158 } else { 159 159 # was not recognised 160 160 if ($verbosity >= 2) { 161 &gsprintf($outhandle, "{plugin.no_plugin_could_recognise}\n", $file); 162 # print $outhandle "WARNING - no plugin could process $file\n"; 161 gsprintf($outhandle, "{plugin.no_plugin_could_recognise}\n",$file); 163 162 } 164 163 # tell the GLI that it was not processed … … 166 165 167 166 $file =~ s/.*?([^\\\/]+)$/$1/; 168 &gsprintf($failhandle, "$file: {plugin.no_plugin_could_recognise_this_file}\n"); 169 # print $failhandle "$file: no plugin could process this file\n"; 167 gsprintf($failhandle, "$file: {plugin.no_plugin_could_recognise_this_file}\n"); 170 168 $stats->{'num_not_recognised'} ++; 171 172 169 } 173 170 … … 183 180 $gli = 0 unless defined $gli; 184 181 185 foreach $plugobj (@$pluginfo) {182 foreach my $plugobj (@$pluginfo) { 186 183 $plugobj->compile_stats($stats); 187 184 } … … 193 190 194 191 if ($total == 1) { 195 &gsprintf($statshandle, "* {plugin.one_considered}\n");192 gsprintf($statshandle, "* {plugin.one_considered}\n"); 196 193 } else { 197 &gsprintf($statshandle, "* {plugin.n_considered}\n", $total);194 gsprintf($statshandle, "* {plugin.n_considered}\n", $total); 198 195 } 199 196 if ($stats->{'num_archives'}) { 200 197 if ($stats->{'num_archives'} == 1) { 201 &gsprintf($statshandle, " ({plugin.including_archive})\n");198 gsprintf($statshandle, " ({plugin.including_archive})\n"); 202 199 } 203 200 else { 204 &gsprintf($statshandle, " ({plugin.including_archives})\n", $stats->{'num_archives'}); 201 gsprintf($statshandle, " ({plugin.including_archives})\n", 202 $stats->{'num_archives'}); 205 203 } 206 204 } 207 205 if ($stats->{'num_processed'} == 1) { 208 &gsprintf($statshandle, "* {plugin.one_included}\n");206 gsprintf($statshandle, "* {plugin.one_included}\n"); 209 207 } else { 210 &gsprintf($statshandle, "* {plugin.n_included}\n", $stats->{'num_processed'});208 gsprintf($statshandle, "* {plugin.n_included}\n", $stats->{'num_processed'}); 211 209 } 212 210 if ($stats->{'num_not_recognised'}) { 213 211 if ($stats->{'num_not_recognised'} == 1) { 214 &gsprintf($statshandle, "* {plugin.one_unrecognised}\n");212 gsprintf($statshandle, "* {plugin.one_unrecognised}\n"); 215 213 } else { 216 &gsprintf($statshandle, "* {plugin.n_unrecognised}\n", $stats->{'num_not_recognised'}); 214 gsprintf($statshandle, "* {plugin.n_unrecognised}\n", 215 $stats->{'num_not_recognised'}); 217 216 } 218 217 … … 220 219 if ($stats->{'num_not_processed'}) { 221 220 if ($stats->{'num_not_processed'} == 1) { 222 &gsprintf($statshandle, "* {plugin.one_rejected}\n");221 gsprintf($statshandle, "* {plugin.one_rejected}\n"); 223 222 } else { 224 &gsprintf($statshandle, "* {plugin.n_rejected}\n", $stats->{'num_not_processed'}); 223 gsprintf($statshandle, "* {plugin.n_rejected}\n", 224 $stats->{'num_not_processed'}); 225 225 } 226 226 } 227 227 if ($stats->{'num_not_processed'} || $stats->{'num_not_recognised'}) { 228 &gsprintf($statshandle, " {plugin.see_faillog}\n", $faillog);228 gsprintf($statshandle, " {plugin.see_faillog}\n", $faillog); 229 229 } 230 230 }
Note:
See TracChangeset
for help on using the changeset viewer.