Changeset 246


Ignore:
Timestamp:
05/04/06 18:52:09 (18 years ago)
Author:
nanardon
Message:
  • run all test to see if a data match rules, not only the regexp on datafile, then ensure all rules are processed before saying a file has no destination
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/soft/ObsData/ObsData/Repository.pm

    r243 r246  
    550550        my $regexp = $self->{obsdata}->getvalue($datatype, 'match') or next; 
    551551        my @data = $datafile =~ /$regexp/; 
    552         if (@data) { 
    553             return ($datatype, @data); 
     552        my @dataar = $self->archive_match($datatype); 
     553        my ($pret, %parg) = $self->get_info_from_plugin($datatype, $datafile); 
     554        # if no regexp => return undef 
     555        # if regexp and match, @dataar contain something 
     556        # if regexp no match, @dataar is empty  
     557        if (@data && (@dataar || !defined($dataar[0])) && (!defined($pret) || $pret)) { 
     558            return ($datatype, \@data, \@dataar); 
    554559        } 
    555560    } 
     
    564569sub archive_match { 
    565570    my ($self, $datatype) = @_; 
    566     my $regexp = $self->{obsdata}->getvalue($datatype, 'match_archive') or next; 
     571    my $regexp = $self->{obsdata}->getvalue($datatype, 'match_archive') or return undef; 
    567572    my @data = $self->{archivefile} =~ /$regexp/; 
    568573    return @data; 
    569574} 
    570575 
    571 =head3 build_dest_filename($datafile) 
    572  
    573 Build the destination file from original filename and optionnaly. 
    574 Return the datatype and the filename. If no datatype apply, 
    575 return undef, if destination file cannot be build, return only the datatype. 
    576  
    577 If object datatype is not defined, the function try to find the right datatype from 
    578 configuration. 
    579  
    580 =cut 
    581  
    582 sub build_dest_filename { 
    583     my ($self, $datafile) = @_; 
    584     my ($datatype, @data) = $self->match_data_type($datafile); 
    585      
    586     if (! $datatype) { 
    587         return; 
    588     } 
    589  
    590     my @ardata = (); 
    591     if (my $arregexp = $self->{obsdata}->getvalue($datatype, 'match_archive')) { 
    592         @ardata = $self->{archivefile} =~ /$arregexp/; 
    593         if (!@ardata) { 
    594             return; # FIXME is this what we want ? 
    595         } 
    596     } 
    597  
     576=head3 get_info_from_plugin($datatype, $datafile) 
     577 
     578First arg is: 
     579  undef if no plugin 
     580  0 no match 
     581  1 match, %list follow 
     582 
     583=cut 
     584 
     585sub get_info_from_plugin { 
     586    my ($self, $datatype, $datafile) = @_; 
     587     
    598588    my %val; 
    599589     
     
    624614                    scalar(@result), 
    625615                ); 
    626                 %val = @result; 
     616                return(1, @result); 
    627617            } else { 
    628618                $self->logging(4, 
     
    632622                    scalar(@result), 
    633623                ); 
    634                 return; 
     624                return undef; 
    635625            } 
    636626        } else { 
     
    640630                $datatype, 
    641631            ); 
    642             return; 
     632            return 0; 
    643633        } 
    644     } 
    645      
     634    } else { 
     635        return undef; 
     636    } 
     637} 
     638 
     639=head3 build_dest_filename($datafile) 
     640 
     641Build the destination file from original filename and optionnaly. 
     642Return the datatype and the filename. If no datatype apply, 
     643return undef, if destination file cannot be build, return only the datatype. 
     644 
     645If object datatype is not defined, the function try to find the right datatype from 
     646configuration. 
     647 
     648=cut 
     649 
     650sub build_dest_filename { 
     651    my ($self, $datafile) = @_; 
     652    my ($datatype, $data, $dataar, $parg) = $self->match_data_type($datafile); 
     653     
     654    if (! $datatype) { 
     655        return; 
     656    } 
     657 
     658    my %val = %{$parg || {}}; 
     659 
    646660    my $dest = $self->{obsdata}->getvalue($datatype, 'dest'); 
    647661    my @matcharg = split(/\s+/, $self->{obsdata}->getvalue($datatype, 'matcharg') || ''); 
     
    651665 
    652666    foreach (@matcharg) { 
    653         $val{$_} = shift(@data); 
     667        $val{$_} = shift(@$data); 
    654668    } 
    655669    foreach (@matcharg_ar) { 
    656         $val{$_} = shift(@ardata); 
     670        $val{$_} = shift(@$dataar); 
    657671    } 
    658672    # FIXME Is this need ? 
Note: See TracChangeset for help on using the changeset viewer.