Changeset 246
- Timestamp:
- 05/04/06 18:52:09 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/soft/ObsData/ObsData/Repository.pm
r243 r246 550 550 my $regexp = $self->{obsdata}->getvalue($datatype, 'match') or next; 551 551 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); 554 559 } 555 560 } … … 564 569 sub archive_match { 565 570 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; 567 572 my @data = $self->{archivefile} =~ /$regexp/; 568 573 return @data; 569 574 } 570 575 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 578 First arg is: 579 undef if no plugin 580 0 no match 581 1 match, %list follow 582 583 =cut 584 585 sub get_info_from_plugin { 586 my ($self, $datatype, $datafile) = @_; 587 598 588 my %val; 599 589 … … 624 614 scalar(@result), 625 615 ); 626 %val = @result;616 return(1, @result); 627 617 } else { 628 618 $self->logging(4, … … 632 622 scalar(@result), 633 623 ); 634 return ;624 return undef; 635 625 } 636 626 } else { … … 640 630 $datatype, 641 631 ); 642 return ;632 return 0; 643 633 } 644 } 645 634 } else { 635 return undef; 636 } 637 } 638 639 =head3 build_dest_filename($datafile) 640 641 Build the destination file from original filename and optionnaly. 642 Return the datatype and the filename. If no datatype apply, 643 return undef, if destination file cannot be build, return only the datatype. 644 645 If object datatype is not defined, the function try to find the right datatype from 646 configuration. 647 648 =cut 649 650 sub 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 646 660 my $dest = $self->{obsdata}->getvalue($datatype, 'dest'); 647 661 my @matcharg = split(/\s+/, $self->{obsdata}->getvalue($datatype, 'matcharg') || ''); … … 651 665 652 666 foreach (@matcharg) { 653 $val{$_} = shift(@ data);667 $val{$_} = shift(@$data); 654 668 } 655 669 foreach (@matcharg_ar) { 656 $val{$_} = shift(@ ardata);670 $val{$_} = shift(@$dataar); 657 671 } 658 672 # FIXME Is this need ?
Note: See TracChangeset
for help on using the changeset viewer.