Changeset 7363 for trunk/gsdl/perllib/plugin.pm
- Timestamp:
- 2004-05-21T11:18:44+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugin.pm
r7351 r7363 32 32 'num_blocked' => 0, 33 33 'num_not_processed' => 0, 34 'num_not_recognised' => 0, 34 35 'num_archives' => 0 35 36 }; … … 108 109 109 110 my $rv = 0; 110 111 my $glifile = $file; 112 $glifile =~ s/^[\/\\]+//; # file sometimes starts with a / so get rid of it 111 113 # Announce to GLI that we are handling a file 112 print STDERR "<File n='$ file'>\n" if $gli;114 print STDERR "<File n='$glifile'>\n" if $gli; 113 115 114 116 # the .kill file is a handy (if not very elegant) way of aborting … … 116 118 if (-e &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, ".kill")) { 117 119 &gsprintf($outhandle, "{plugin.kill_file}\n"); 118 # print $outhandle "Process killed by .kill file\n";119 120 die "\n"; 120 121 } 121 122 123 my $had_error = 0; 122 124 # pass this file by each of the plugins in turn until one 123 125 # is found which will process it 126 # read must return: 127 # undef - could not recognise 128 # -1 - tried but error 129 # 0 - blocked 130 # anything else for successful processing 124 131 foreach $plugobj (@$pluginfo) { 125 132 $rv = $plugobj->read($pluginfo, $base_dir, $file, 126 133 $metadata, $processor, $maxdocs, $gli, $aux); 127 return $rv if defined $rv; 128 } 129 130 if ($verbosity >= 2) { 131 &gsprintf($outhandle, "{plugin.no_plugin_could_process}\n", $file); 132 # print $outhandle "WARNING - no plugin could process $file\n"; 133 } 134 # tell the GLI that it was not processed 135 print STDERR "<Processing n='$file' p=''>\n" if $gli; 136 137 $file =~ s/.*?([^\\\/]+)$/$1/; 138 &gsprintf($failhandle, "$file: {plugin.no_plugin_could_process_this_file}\n"); 139 # print $failhandle "$file: no plugin could process this file\n"; 140 $stats->{'num_not_processed'} ++; 134 if (defined $rv) { 135 if ($rv == -1) { 136 # an error has occurred 137 $had_error = 1; 138 print STDERR "<ProcessingError n='$glifile'>\n" if $gli; 139 } else { 140 return $rv; 141 } 142 } # else undefined - was not recognised by the plugin 143 } 144 145 if ($had_error) { 146 # was recognised but couldn't be processed 147 if ($verbosity >= 2) { 148 &gsprintf($outhandle, "{plugin.no_plugin_could_process}\n", $file); 149 # print $outhandle "WARNING - no plugin could process $file\n"; 150 } 151 # tell the GLI that it was not processed 152 print STDERR "<NonProcessedFile n='$glifile'>\n" if $gli; 153 154 $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"; 157 $stats->{'num_not_processed'} ++; 158 } else { 159 # was not recognised 160 if ($verbosity >= 2) { 161 &gsprintf($outhandle, "{plugin.no_plugin_could_recognise}\n", $file); 162 # print $outhandle "WARNING - no plugin could process $file\n"; 163 } 164 # tell the GLI that it was not processed 165 print STDERR "<NonRecognisedFile n='$glifile'>\n" if $gli; 166 167 $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"; 170 $stats->{'num_not_recognised'} ++; 171 172 } 141 173 142 174 return 0; … … 156 188 157 189 my $total = $stats->{'num_processed'} + $stats->{'num_blocked'} + 158 $stats->{'num_not_processed'} ;159 160 print STDERR "<ImportComplete considered='$total' processed='$stats->{'num_processed'}' blocked='$stats->{'num_blocked'}' ignored='$stats->{'num_not_ processed'}'>\n" if $gli;190 $stats->{'num_not_processed'} + $stats->{'num_not_recognised'}; 191 192 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; 161 193 162 194 if ($total == 1) { 163 195 &gsprintf($statshandle, "* {plugin.one_considered}\n"); 164 # print $statshandle "* 1 document was considered for processing\n";165 196 } else { 166 197 &gsprintf($statshandle, "* {plugin.n_considered}\n", $total); 167 # print $statshandle "* $total documents were considered for processing\n";168 198 } 169 199 if ($stats->{'num_archives'}) { 170 # print $statshandle " (including the contents of " . $stats->{'num_archives'} .171 # " ZIP/TAR archive";172 200 if ($stats->{'num_archives'} == 1) { 173 201 &gsprintf($statshandle, " ({plugin.including_archive})\n"); 174 # print $statshandle ")\n";}175 202 } 176 203 else { 177 204 &gsprintf($statshandle, " ({plugin.including_archives})\n", $stats->{'num_archives'}); 178 # print $statshandle "s)\n";}179 205 } 180 206 } 181 207 if ($stats->{'num_processed'} == 1) { 182 208 &gsprintf($statshandle, "* {plugin.one_included}\n"); 183 # print $statshandle "* 1 was processed and included in the collection\n";184 209 } else { 185 210 &gsprintf($statshandle, "* {plugin.n_included}\n", $stats->{'num_processed'}); 186 # print $statshandle "* " . $stats->{'num_processed'} . " were processed and included in the collection\n"; 211 } 212 if ($stats->{'num_not_recognised'}) { 213 if ($stats->{'num_not_recognised'} == 1) { 214 &gsprintf($statshandle, "* {plugin.one_unrecognised}\n"); 215 } else { 216 &gsprintf($statshandle, "* {plugin.n_unrecognised}\n", $stats->{'num_not_recognised'}); 217 } 218 187 219 } 188 220 if ($stats->{'num_not_processed'}) { 189 221 if ($stats->{'num_not_processed'} == 1) { 190 222 &gsprintf($statshandle, "* {plugin.one_rejected}\n"); 191 # print $statshandle "* 1 was rejected.";192 223 } else { 193 224 &gsprintf($statshandle, "* {plugin.n_rejected}\n", $stats->{'num_not_processed'}); 194 # print $statshandle "* " . $stats->{'num_not_processed'} . " were rejected."; 195 } 225 } 226 } 227 if ($stats->{'num_not_processed'} || $stats->{'num_not_recognised'}) { 196 228 &gsprintf($statshandle, " {plugin.see_faillog}\n", $faillog); 197 # print $statshandle " See $faillog for a list of rejected documents\n";198 229 } 199 230 }
Note:
See TracChangeset
for help on using the changeset viewer.