Changeset 11090
- Timestamp:
- 2006-01-24T10:29:34+13:00 (18 years ago)
- Location:
- trunk/gsdl/perllib/plugins
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/ConvertToPlug.pm
r11008 r11090 331 331 my $self = shift (@_); 332 332 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 333 #if ($self->is_recursive()) {334 # die "BasPlug::read function must be implemented in sub-class for recursive plugins\n";335 # }336 333 337 334 my $outhandle = $self->{'outhandle'}; -
trunk/gsdl/perllib/plugins/ConvertToRogPlug.pm
r10254 r11090 313 313 my $self = shift (@_); 314 314 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 315 # if ($self->is_recursive()) {316 # die "BasPlug::read function must be implemented in sub-class for recursive plugins\n";317 # }318 315 319 316 my $outhandle = $self->{'outhandle'}; 320 317 321 my $filename = $file; 322 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; 323 324 if ($self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/) { 325 $self->{'num_blocked'} ++; 326 return 0; 327 } 328 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 329 return undef; 330 } 318 # check process_exp, block_exp, associate_ext etc 319 my ($block_status,$filename) = $self->read_block(@_); 320 return $block_status if ((!defined $block_status) || ($block_status==0)); 321 331 322 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up 332 323 -
trunk/gsdl/perllib/plugins/DBPlug.pm
r10956 r11090 88 88 89 89 # see if we can handle the passed file... 90 my $filename = $file; 91 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; 92 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 93 # this plugin can't process this file type... 94 return undef; 95 } 90 my ($block_status,$filename) = $self->read_block(@_); 91 return $block_status if ((!defined $block_status) || ($block_status==0)); 96 92 97 93 my $outhandle = $self->{'outhandle'}; -
trunk/gsdl/perllib/plugins/FOXPlug.pm
r10254 r11090 69 69 } 70 70 71 sub is_recursive { 72 my $self = shift (@_); 73 74 return 0; # this is not a recursive plugin 75 } 76 71 sub get_default_process_exp { 72 my $self = shift (@_); 73 74 return q^(?i)\.dbf$^; 75 } 76 77 #dbt files are processed at the same time as dbf files 78 sub get_default_block_exp { 79 my $self = shift (@_); 80 81 return q^(?i)\.dbt$^; 82 } 77 83 78 84 # return number of files processed, undef if can't process … … 82 88 my $self = shift (@_); 83 89 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 84 my $fullname = &util::filename_cat ($base_dir, $file);85 86 # dbt files are processed at the same time as dbf files87 return 0 if ($fullname =~ /\.dbt$/i);88 89 # see if this is a foxbase database90 return undef unless (-f $fullname && $fullname =~ /\.dbf$/i);90 91 #check for associate_ext, blocking etc, are we processing this file? 92 my ($block_status,$fullname) = $self->read_block(@_); 93 return $block_status if ((!defined $block_status) || ($block_status==0)); 94 95 print STDERR "<Processing n='$file' p='FOXPlug'>\n" if ($gli); 96 print STDERR "FOXPlug: processing $file\n" if $self->{'verbosity'} > 1; 91 97 92 98 my ($parent_dir) = $fullname =~ /^(.*)\/[^\/]+\.dbf$/i; … … 100 106 return -1; # error in processing 101 107 } 102 103 print STDERR "<Processing n='$file' p='FOXPlug'>\n" if ($gli);104 105 print STDERR "FOXPlug: processing $file\n";106 108 107 109 # read in the database header -
trunk/gsdl/perllib/plugins/GMLPlug.pm
r10254 r11090 82 82 my $outhandle = $self->{'outhandle'}; 83 83 84 my $filename = $file; 85 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; 86 87 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 88 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 89 return undef; 90 } 84 #check process and block exps, smart block, etc 85 my ($block_status,$filename) = $self->read_block(@_); 86 return $block_status if ((!defined $block_status) || ($block_status==0)); 87 91 88 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up 92 89 -
trunk/gsdl/perllib/plugins/ImagePlug.pm
r10254 r11090 337 337 338 338 339 # The ImagePlug read() function. This function does all the right things 340 # to make general options work for a given plugin. It calls the process() 341 # function which does all the work specific to a plugin (like the old 342 # read functions used to do). Most plugins should define their own 343 # process() function and let this read() function keep control. 344 # 339 # The ImagePlug read() function. 345 340 # ImagePlug overrides read() because there is no need to read the actual 346 341 # text of the file in, because the contents of the file is not text... … … 356 351 my $outhandle = $self->{'outhandle'}; 357 352 358 my $filename = &util::filename_cat($base_dir, $file); 359 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 360 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 361 return undef; 362 } 353 #check process and block exps, smart block, etc 354 my ($block_status,$filename) = $self->read_block(@_); 355 return $block_status if ((!defined $block_status) || ($block_status==0)); 363 356 364 357 print STDERR "<Processing n='$file' p='ImagePlug'>\n" if ($gli); -
trunk/gsdl/perllib/plugins/MP3Plug.pm
r10347 r11090 307 307 my $outhandle = $self->{'outhandle'}; 308 308 309 # Make sure we're processing the correct file 310 my $filename = &util::filename_cat($base_dir, $file); 311 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 312 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 313 return undef; 314 } 309 #check for associate_ext, blocking etc 310 my ($block_status,$filename) = $self->read_block(@_); 311 return $block_status if ((!defined $block_status) || ($block_status==0)); 312 315 313 print STDERR "<Processing n='$file' p='MP3Plug'>\n" if ($gli); 316 314 print $outhandle "MP3Plug processing \"$filename\"\n" -
trunk/gsdl/perllib/plugins/NULPlug.pm
r10978 r11090 95 95 my $outhandle = $self->{'outhandle'}; 96 96 97 # Make sure we're processing the correct file 98 my $filename = &util::filename_cat($base_dir, $file); 99 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 100 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 101 return undef; 102 } 97 #check for associate_ext, blocking etc 98 my ($block_status,$filename) = $self->read_block(@_); 99 return $block_status if ((!defined $block_status) || ($block_status==0)); 100 103 101 print STDERR "<Processing n='$file' p='NULPlug'>\n" if ($gli); 104 102 print $outhandle "NULPlug processing \"$filename\"\n" -
trunk/gsdl/perllib/plugins/OggVorbisPlug.pm
r10254 r11090 87 87 my $outhandle = $self->{'outhandle'}; 88 88 89 # filename is the full pathname of the file 90 my $filename = &util::filename_cat($base_dir, $file); 91 return 0 if $self->{block_exp} ne "" && $filename =~ /$self->{'block_exp'}/; 92 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 93 return undef; 94 } 89 #check process and block exps, smart block, etc 90 my ($block_status,$filename) = $self->read_block(@_); 91 return $block_status if ((!defined $block_status) || ($block_status==0)); 95 92 96 # Report that we're processing the file93 # Report that we're processing the file 97 94 print STDERR "<Processing n='$file' p='OggVorbisPlug'>\n" if ($gli); 98 95 print $outhandle "OggVorbisPlug: processing $file\n" -
trunk/gsdl/perllib/plugins/OpenDocumentPlug.pm
r10997 r11090 148 148 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 149 149 150 my $filename = $file; 151 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; 152 153 if ($self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/) { 154 $self->{'num_blocked'} ++; 155 return 0; 156 } 157 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 158 return undef; 159 } 150 # check process and block exps, smart block, associate_ext etc 151 my ($block_status,$filename) = $self->read_block(@_); 152 return $block_status if ((!defined $block_status) || ($block_status==0)); 160 153 161 154 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up -
trunk/gsdl/perllib/plugins/PagedImgPlug.pm
r10613 r11090 539 539 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 540 540 my $outhandle = $self->{'outhandle'}; 541 my $smart_block = $self->{'smart_block'}; 542 543 my $filename = &util::filename_cat($base_dir, $file); 544 545 if ($self->associate_with($file,$filename,$metadata)) { 546 # a form of smart block 547 $self->{'num_blocked'} ++; 548 return 0; # blocked 549 } 550 551 if ($smart_block) { 552 if (defined $self->{'file_blocks'}->{$filename} && $self->{'file_blocks'}->{$filename} == 1){ 553 $self->{'num_blocked'} ++; 554 return 0; # blocked 555 } 556 } elsif ($self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/) { 557 $self->{'num_blocked'} ++; 558 return 0; # blocked 559 } 560 561 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 562 return undef; 563 } 541 542 #check process and block exps, smart block, etc 543 my ($block_status,$filename) = $self->read_block(@_); 544 return $block_status if ((!defined $block_status) || ($block_status==0)); 564 545 565 546 print $outhandle "PagedImgPlug processing \"$filename\"\n" … … 731 712 # assign pagenum as what?? 732 713 my $pagenum = $_{'pagenum'}; #TODO!! 733 $doc_obj->set_utf8_metadata_element($self->{'current_section'}, 'PageNum', $pagenum); 714 if (defined $pagenum) { 715 $doc_obj->set_utf8_metadata_element($self->{'current_section'}, 'PageNum', $pagenum); 716 } 734 717 my ($imgfile) = $_{'imgfile'}; 735 718 if (defined $imgfile) { … … 832 815 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 833 816 my $topsection = $doc_obj->get_top_section(); 817 $doc_obj->add_utf8_metadata($topsection, "Plugin", "$self->{'plugin_type'}"); 818 $doc_obj->add_metadata($topsection, "FileFormat", "PagedImg"); 834 819 835 820 if ($self->{'documenttype'} eq 'paged') { … … 849 834 next unless $line =~ /\w/; 850 835 chomp $line; 836 next if $line =~ /^#/; # ignore comment lines 851 837 if ($line =~ /^<([^>]*)>\s*(.*?)\s*$/) { 852 838 $doc_obj->set_utf8_metadata_element ($topsection, $1, $2); -
trunk/gsdl/perllib/plugins/RealMediaPlug.pm
r10395 r11090 86 86 my $outhandle = $self->{'outhandle'}; 87 87 88 # filename is the full pathname of the file 89 my $filename = &util::filename_cat($base_dir, $file); 90 return 0 if $self->{block_exp} ne "" && $filename =~ /$self->{'block_exp'}/; 91 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 92 return undef; 93 } 88 #check process and block exps, smart block, etc 89 my ($block_status,$filename) = $self->read_block(@_); 90 return $block_status if ((!defined $block_status) || ($block_status==0)); 94 91 95 92 # Report that we're processing the file -
trunk/gsdl/perllib/plugins/RogPlug.pm
r10254 r11090 64 64 65 65 return bless $self, $class; 66 }67 68 sub is_recursive {69 my $self = shift (@_);70 71 return 0; # this is not a recursive plugin72 66 } 73 67 -
trunk/gsdl/perllib/plugins/SplitPlug.pm
r10254 r11090 93 93 $self->{'process_exp'} = $self->get_default_process_exp (); 94 94 if ($self->{'process_exp'} eq "") { 95 warn ref($self) . " Warning: Non-recursiveplugin has no process_exp\n";95 warn ref($self) . " Warning: plugin has no process_exp\n"; 96 96 } 97 97 } … … 185 185 my $verbosity = $self->{'verbosity'}; 186 186 187 # Figure out the exact filename of this file (and maybe block it) 188 my $filename = &util::filename_cat($base_dir, $file); 189 my $block_exp = $self->{'block_exp'}; 190 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 191 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 192 return undef; 193 } 187 #check process and block exps, smart block, etc 188 my ($block_status,$filename) = $self->read_block(@_); 189 return $block_status if ((!defined $block_status) || ($block_status==0)); 190 194 191 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up 195 192 … … 228 225 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "SourceSegment", "$segment"); 229 226 if ($self->{'cover_image'}) { 230 $self->associate_cover_image($doc_obj, $filename);227 $self->associate_cover_image($doc_obj, $filename); 231 228 } 232 229 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Plugin", "$self->{'plugin_type'}"); -
trunk/gsdl/perllib/plugins/UnknownPlug.pm
r10985 r11090 179 179 180 180 # Make sure we're processing the correct file 181 my $filename = &util::filename_cat($base_dir, $file); 182 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 183 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 184 return undef; 185 } 181 my ($block_status,$filename) = $self->read_block(@_); 182 return $block_status if ((!defined $block_status) || ($block_status==0)); 183 186 184 print STDERR "<Processing n='$file' p='UnknownPlug'>\n" if ($gli); 187 185 print $outhandle "UnknownPlug processing \"$filename\"\n" -
trunk/gsdl/perllib/plugins/W3ImgPlug.pm
r10347 r11090 250 250 # image extraction done through read() 251 251 sub process { 252 my ($self, $textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj ) = @_;252 my ($self, $textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_; 253 253 $self->{'imglist'} = (); 254 254 if ( $self->{'index_pages'} ) { 255 my $ok = $self->SUPER::process($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj );255 my $ok = $self->SUPER::process($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli); 256 256 if ( ! $ok ) { return $ok } 257 257 $self->{'htdoc_obj'} = $doc_obj; -
trunk/gsdl/perllib/plugins/XMLPlug.pm
r10254 r11090 69 69 $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs); 70 70 71 if ($self->{'info_only'}) { 72 # don't worry about any options etc 73 return bless $self, $class; 74 } 75 71 76 my $parser = new XML::Parser('Style' => 'Stream', 72 77 'Handlers' => {'Char' => \&Char, … … 153 158 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_; 154 159 155 my $filename = $file; 156 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; 157 158 if ($self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/) { 159 $self->{'num_blocked'} ++; 160 return 0; 161 } 162 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 163 return undef; 164 } 160 # Make sure we're processing the correct file, do blocking etc 161 my ($block_status,$filename) = $self->read_block(@_); 162 return $block_status if ((!defined $block_status) || ($block_status==0)); 165 163 166 164 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up -
trunk/gsdl/perllib/plugins/ZIPPlug.pm
r10254 r11090 82 82 my $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs); 83 83 84 # BasPlug is explicitly set not to set process_exp if recursive plugin85 # Not sure of this reasoning. Want it to be set in ZIPPlug, so explicitly86 # pass it in as default value87 88 ## do we need this???? --kjdon89 if (!$self->{'process_exp'}) {90 $self->{'process_exp'} = get_default_process_exp();91 }92 93 84 return bless $self, $class; 94 85 } … … 113 104 my $outhandle = $self->{'outhandle'}; 114 105 115 if ($file =~ /$self->{'process_exp'}/) { 116 117 my $filename = $file; 118 $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/; 119 if (!-e $filename) { 120 print $outhandle "ZIPPLug: WARNING: $filename does not exist\n"; 121 return undef; 122 } 106 # check process_exp, block_exp, associate_ext etc 107 my ($block_status,$filename) = $self->read_block(@_); 108 return $block_status if ((!defined $block_status) || ($block_status==0)); 123 109 124 my ($file_only) = $file =~ /([^\\\/]*)$/; 125 my $tmpdir = &util::get_tmp_filename (); 126 &util::mk_all_dir ($tmpdir); 127 128 print $outhandle "ZIPPlug: extracting $file_only to $tmpdir\n" 129 if $self->{'verbosity'} > 1; 130 131 # save current working directory 132 my $cwd = cwd(); 133 chdir ($tmpdir) || die "Unable to change to $tmpdir"; 134 &util::cp ($filename, $tmpdir); 135 136 if ($file =~ /\.bz$/i) { 137 $self->bunzip ($file_only); 138 } elsif ($file =~ /\.bz2$/i) { 139 $self->bunzip2 ($file_only); 140 } elsif ($file =~ /\.(zip|jar)$/i) { 141 $self->unzip ($file_only); 142 } elsif ($file =~ /\.tar$/i) { 143 $self->untar ($file_only); 144 } else { 145 $self->gunzip ($file_only); 146 } 147 148 chdir ($cwd) || die "Unable to change back to $cwd"; 149 150 my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $metadata, $processor, $maxdocs, $total_count, $gli); 151 &util::rm_r ($tmpdir); 152 153 $self->{'num_archives'} ++; 154 155 return $numdocs; 156 110 my ($file_only) = $file =~ /([^\\\/]*)$/; 111 my $tmpdir = &util::get_tmp_filename (); 112 &util::mk_all_dir ($tmpdir); 113 114 print $outhandle "ZIPPlug: extracting $file_only to $tmpdir\n" 115 if $self->{'verbosity'} > 1; 116 117 # save current working directory 118 my $cwd = cwd(); 119 chdir ($tmpdir) || die "Unable to change to $tmpdir"; 120 &util::cp ($filename, $tmpdir); 121 122 if ($file =~ /\.bz$/i) { 123 $self->bunzip ($file_only); 124 } elsif ($file =~ /\.bz2$/i) { 125 $self->bunzip2 ($file_only); 126 } elsif ($file =~ /\.(zip|jar)$/i) { 127 $self->unzip ($file_only); 128 } elsif ($file =~ /\.tar$/i) { 129 $self->untar ($file_only); 157 130 } else { 158 return undef;131 $self->gunzip ($file_only); 159 132 } 133 134 chdir ($cwd) || die "Unable to change back to $cwd"; 135 136 my $numdocs = &plugin::read ($pluginfo, "", $tmpdir, $metadata, $processor, $maxdocs, $total_count, $gli); 137 &util::rm_r ($tmpdir); 138 139 $self->{'num_archives'} ++; 140 141 return $numdocs; 142 160 143 } 161 144
Note:
See TracChangeset
for help on using the changeset viewer.