Changeset 13310 for trunk/niupepa
- Timestamp:
- 2006-11-20T17:08:03+13:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/niupepa/perllib/plugins/NPPlug.pm
r3704 r13310 46 46 use BasPlug; 47 47 use util; 48 use strict; 49 use unicode; 48 50 49 51 sub BEGIN { 50 @ISA = ('BasPlug'); 51 } 52 53 use strict; 54 55 sub print_usage { 56 print STDERR "\nIncorrect options passed to NPPlug, check your collect.cfg configuration file\n"; 57 58 print STDERR "\n usage: plugin NPPlug [options]\n\n"; 59 print STDERR " options:\n"; 60 print STDERR " -create_log Creates a log file containing info about which portions\n"; 61 print STDERR " of papers are missing\n"; 62 print STDERR " -logfile Path of logfile (defaults to ./log.txt)\n\n"; 63 } 52 @NPPlug::ISA = ('BasPlug'); 53 } 54 55 56 my $arguments = 57 [ 58 { 'name' => "create_log", 59 'desc' => "To create a log file", 60 'type' => "flag" }, 61 { 'name' => "logfile", 62 'desc' => "The log file path", 63 'type' => "string", 64 'deft' => "./log.txt"} 65 ]; 66 67 my $options = { 'name' => "NPPlug", 68 'desc' => "{NPPlug.desc}", 69 'abstract' => "no", 70 'inherits' => "yes", 71 'args' => $arguments }; 64 72 65 73 sub new { 66 my ($class) = @_;67 my $self = new BasPlug (); 68 69 if (!parsargv::parse(\@_,70 q^create_log^, \$self->{'create_log'}, 71 q^logfile/.*/./log.txt^, \$self->{'logfile'})) { 72 &print_usage();73 die "\n"; 74 }74 my ($class) = shift(@_); 75 76 my ($pluginlist,$inputargs,$hashArgOptLists) = @_; 77 push(@$pluginlist, $class); 78 79 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});} 80 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)}; 81 82 my $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists); 75 83 76 84 $self->{'commentaries'} = {}; … … 81 89 return bless $self, $class; 82 90 } 91 92 93 sub get_default_process_exp { 94 my $self = shift (@_); 95 96 # the last option is an attempt to encode the concept of an html query ... 97 return q^(?i)(\.issue)$^; 98 } 99 83 100 84 101 sub is_recursive { … … 152 169 return 0 if $filename =~ /meta\.txt$/i; 153 170 154 return undef unless ($filename =~ /\.(issue|commentary )$/i && (-e $filename));171 return undef unless ($filename =~ /\.(issue|commentary|gif)$/i && (-e $filename)); 155 172 156 173 $self->{'verbosity'} = $processor->{'verbosity'}; … … 163 180 if ($filename =~ /\.commentary$/i) { 164 181 # commentary 165 return $self->process_commentary ($filename, $issuekey, $dir, $file, $processor); 182 $self->{'num_processed'} 183 += $self->process_commentary ($filename, $issuekey, $dir, $file, $processor); 184 return 1; 185 } 186 187 if ($filename =~ /(.*)on\.gif$/i) { 188 my $root = $1; 189 # create surrogate document to store cover image (on and off) for 190 # newspaper 191 192 $issuekey =~ s/on$//; 193 194 my $doc_obj = new doc ($dir, "indexed_doc"); 195 my $cover = &util::filename_cat ($dir, $issuekey); 196 197 $self->associate_cover_images ($doc_obj, $cover, "" ); 198 $doc_obj->set_OID ($issuekey); 199 $processor->process ($doc_obj); 200 201 return 0; 202 } 203 if ($filename =~ /(.*)of\.gif$/i) { 204 # block it 205 return 0; 206 } 207 if ($filename =~ /\.gif$/i) { 208 # Let some other plugin have a go 209 return undef; 166 210 } 167 211 168 212 my $numprocessed = 0; 169 $self->{'commentaries'}->{$issuekey} = 0 unless defined $self->{'commentaries'}->{$issuekey}; 213 $self->{'commentaries'}->{$issuekey} = 0 214 unless defined $self->{'commentaries'}->{$issuekey}; 170 215 171 216 my ($abstractfile) = $file =~ /^([^\.]*)\.issue/i; … … 188 233 } 189 234 190 return $numprocessed; 235 $self->{'num_processed'} += $numprocessed; 236 237 238 239 return 1; 191 240 } 192 241 … … 202 251 $doc_obj->set_utf8_metadata_element ($topsection, 'abstract', $abstract) if defined $abstract; 203 252 $self->set_main_metadata ($doc_obj, $dir); 253 254 my $com_filename = &util::filename_cat($dir,"$issuekey.commentary"); 255 if (-e $com_filename) { 256 $doc_obj->set_utf8_metadata_element ($topsection, "hascom", "1"); 257 } 204 258 205 259 # process issue's pdf if one exists
Note:
See TracChangeset
for help on using the changeset viewer.