Changeset 193


Ignore:
Timestamp:
01/13/06 15:08:27 (18 years ago)
Author:
thauvin
Message:
  • delete obsoleted functions
Location:
trunk/soft/ObsData
Files:
3 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.49 to 1.50
    r189 r193  
    268268    grep { $_ !~ /^Obs\s+/ } 
    269269    grep { !$self->is_obs($_) } $self->{config}->Sections; 
    270 } 
    271  
    272 =head2 match_data_type($datatype, $label) 
    273  
    274 Check if $label match the regexp associate to $datatype, return match values 
    275 or nothing if no match. 
    276  
    277 =cut 
    278  
    279 sub match_data_type { 
    280     my ($self, $datatype, $label) = @_; 
    281     my $regexp = $self->getvalue($datatype, 'match') or return; 
    282     my @data = $label =~ /$regexp/; 
    283     if (! @data) { 
    284         return; 
    285     } 
    286     return @data; 
    287 } 
    288  
    289 =head2 find_match_data_type($label) 
    290  
    291 Check if $label match one of the regexp associate to datatype in the 
    292 configuration, if yes, return the datatype and assiociate values, else 
    293 return nothing 
    294  
    295 =cut 
    296  
    297 sub find_match_data_type { 
    298     my ($self, $label) = @_; 
    299     foreach my $datatype ($self->list_datatype) { 
    300         my @data = $self->match_data_type($datatype, $label); 
    301         if (@data) { 
    302             return($datatype, @data); 
    303         } 
    304     } 
    305 } 
    306  
    307 =head2 build_dest_filename($label, $datatype, $magic_words) 
    308  
    309 Build the destination file from original filename ($label) and optionnaly 
    310 from $datatype. Return the datatype and the filename. If no datatype apply, 
    311 return undef, if destination file cannot be build, return only the datatype. 
    312  
    313 If $datatype is not defined, the function try to find the right datatype from 
    314 configuration. 
    315  
    316 =cut 
    317  
    318 sub build_dest_filename { 
    319     my ($self, $label, $datatype, $magic_words) = @_; 
    320     my @data; 
    321     if ($datatype) { 
    322         @data = $self->match_data_type($datatype, $label); 
    323     } else { 
    324         ($datatype, @data) = $self->find_match_data_type($label); 
    325     } 
    326  
    327     if ($datatype && @data) { 
    328         my $dest = $self->getvalue($datatype, 'dest'); 
    329         my @matcharg = split(/\s+/, $self->getvalue($datatype, 'matcharg')); 
    330         my @destarg = split(/\s+/, $self->getvalue($datatype, 'destarg')); 
    331         my @gmtime = gmtime; 
    332         my %val; 
    333         foreach (@matcharg) { 
    334             $val{$_} = shift(@data); 
    335         } 
    336         foreach (keys %{$magic_words || {}}) { 
    337             $val{'$' . $_} = $magic_words->{$_}; 
    338         } 
    339         $val{'$datafile'} = $label; 
    340         return ($datatype, sprintf( 
    341             $dest, 
    342             map { m/^%/ ? strftime($_, @gmtime) : $val{$_} } @destarg, 
    343         )); 
    344     } 
    345     undef; 
    346270} 
    347271 
  • trunk/soft/ObsData/ObsData/Repository.pm

    • Property cvs2svn:cvs-rev changed from 1.69 to 1.70
    r192 r193  
    506506} 
    507507 
     508=head3 find_match_data_type($label) 
     509 
     510Check if datafile match one of the regexp associate to datatype in the 
     511configuration, if yes, return the datatype and assiociate values, else 
     512return nothing 
     513 
     514=cut 
     515 
    508516sub match_data_type { 
    509517    my ($self, $datafile) =  @_; 
     
    517525} 
    518526 
     527=head3 build_dest_filename($datafile) 
     528 
     529Build the destination file from original filename and optionnaly. 
     530Return the datatype and the filename. If no datatype apply, 
     531return undef, if destination file cannot be build, return only the datatype. 
     532 
     533If object datatype is not defined, the function try to find the right datatype from 
     534configuration. 
     535 
     536=cut 
     537 
     538 
    519539sub build_dest_filename { 
    520540    my ($self, $datafile) = @_; 
     
    556576    my ($self, $datafile) = @_; 
    557577 
    558     my ($t, $d) = $self->{obsdata}->build_dest_filename( 
     578    my ($t, $d) = $self->build_dest_filename( 
    559579        $datafile, 
    560580        $self->{datatype} 
  • trunk/soft/ObsData/t/O-02.t

    • Property cvs2svn:cvs-rev changed from 1.18 to 1.19
    r169 r193  
    44use warnings; 
    55 
    6 use Test::More tests => 29; 
     6use Test::More tests => 20; 
    77use File::Temp qw(tempdir); 
    88use POSIX qw(strftime); 
     
    4141print STDERR join(" ", $o->list_datatype); 
    4242 
    43 # Testing match rules 
    44 ok($o->match_data_type('ozone', 'ozone12'), "String matching setting"); 
    45 ok(!$o->match_data_type('ozone', 'foo12'), "String no matching setting"); 
    46  
    47 ok($o->find_match_data_type('ozone12'), "is able to find good datatype"); 
    48 ok(!$o->find_match_data_type('foo12'), "is able to find good datatype"); 
    49  
    50 ok( 
    51     eq_array(  
    52         [ $o->build_dest_filename('ozone12') ],  
    53         [ 'ozone', '12/dest12' ] 
    54     ),  
    55     "Can build dest string" 
    56 ); 
    57 ok( 
    58     eq_array( 
    59         [ $o->build_dest_filename('ozone12', 'ozone') ], 
    60         [ 'ozone', '12/dest12' ] 
    61     ), 
    62     "Can build dest string with datatype" 
    63 ); 
    64 ok( 
    65     eq_array( 
    66         [ $o->build_dest_filename('oxygene12', 'oxygene') ], 
    67         [ 'oxygene', strftime("%Y/dest12/oxygene12", gmtime) ] 
    68     ), 
    69     "Can build dest string with datatype" 
    70 ); 
    71 ok(!defined($o->build_dest_filename('foo12')), "Return undef if no match"); 
    72 ok(!defined($o->build_dest_filename('ozone12', 'oxygene')), "Return undef if no match"); 
    73  
    7443$o = undef; # Explicit destroy 
Note: See TracChangeset for help on using the changeset viewer.