Ignore:
Timestamp:
2008-07-14T14:57:38+12:00 (16 years ago)
Author:
kjdon
Message:

global block pass: read_block is no more, use can_process_this_file to see whether a file is for us or not. extra arg (block_hash) to read, read_into_doc_obj, metadata_read etc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/plugins/LOMPlugin.pm

    r16019 r16392  
    106106
    107107
    108 
     108sub can_process_this_file {
     109    my $self = shift(@_);
     110    my ($filename) = @_;
     111
     112    if ($self->SUPER::can_process_this_file($filename) && $self->check_doctype($filename)) {
     113    return 1; # its a file for us
     114    }
     115    return 0;
     116}
    109117
    110118sub metadata_read {
    111119    my $self = shift (@_);
    112     my ($pluginfo, $base_dir, $file, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli) = @_;
     120    my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli) = @_;
    113121
    114122    my $outhandle = $self->{'outhandle'};
    115123
    116     my $filename = $file;
    117     $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
    118    
    119     if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) {
    120     return undef; # can't recognise
    121     }
    122     if (!$self->check_doctype($filename)) {
    123     # this file is not for us
    124     return undef;
    125     }
     124    # can we process this file??
     125    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
     126    return undef unless $self->can_process_this_file($filename_full_path);
    126127
    127128    $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up
     
    130131    if $self->{'verbosity'} > 1;
    131132
    132     my ($dir,$tail) = $filename =~ /^(.*?)([^\/\\]*)$/;
     133    my ($dir,$tail) = $filename_full_path =~ /^(.*?)([^\/\\]*)$/;
    133134    $self->{'output_dir'} = $dir;
    134135
    135136    eval {
    136     $self->{'parser'}->parsefile($filename);
     137    $self->{'parser'}->parsefile($filename_full_path);
    137138    };
    138139   
    139140    if ($@) {
    140     print $outhandle "LOMPlugin: skipping $filename as not conformant to LOM syntax\n" if ($self->{'verbosity'} > 1);
     141    print $outhandle "LOMPlugin: skipping $filename_full_path as not conformant to LOM syntax\n" if ($self->{'verbosity'} > 1);
    141142    print $outhandle "\n Perl Error:\n $@\n" if ($self->{'verbosity'}>2);
    142143    return 0;
     
    212213sub read {
    213214    my $self = shift (@_);
    214     my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
     215    my ($pluginfo, $base_dir, $file, $block_hash, $metadata, $processor, $maxdocs, $total_count, $gli) = @_;
    215216
    216217    my $outhandle = $self->{'outhandle'};
     
    218219    return 0 if (defined $self->{'extra_blocks'}->{$file});
    219220
    220     # need to check whether this file is for us
    221     my ($block_status,$filename) = $self->read_block(@_);   
    222     return $block_status if ((!defined $block_status) || ($block_status==0));
    223     if (!$self->check_doctype($filename)) {
    224     # this file is not for us
    225     return undef;
    226     }
     221    # can we process this file??
     222    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
     223    return undef unless $self->can_process_this_file($filename_full_path);
    227224
    228225    $self->{'metadata_table'} = $metadata;
Note: See TracChangeset for help on using the changeset viewer.