Changeset 96


Ignore:
Timestamp:
12/03/05 04:59:51 (19 years ago)
Author:
thauvin
Message:
  • split code again
Location:
trunk/soft/ObsData
Files:
3 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.30 to 1.31
    r88 r96  
    270270} 
    271271 
    272 sub find_file_obs { 
     272sub process_obs { 
    273273    my ($self, $obs) = @_; 
    274274    my %datadir = $self->list_obsdatadir($obs); 
     
    276276     
    277277    foreach my $datatype (keys %datadir) { 
    278         my $or = ObsData::Repository::dir->new( 
    279             { 
    280                 obsdata => $self, 
    281                 dir => $datadir{$datatype}, 
    282                 obs => $obs, 
    283                 datatype => $datatype, 
    284                 statusfile => "$datadir{$datatype}/obsdata.ini" 
    285             } 
     278        my $or = $self->get_obs_data_handle($obs, $datatype); 
     279        $or or next; 
     280        $or->process; 
     281    } 
     282} 
     283 
     284sub get_obs_data_handle { 
     285    my ($self, $obs, $datatype) = @_; 
     286 
     287    my $dir = $self->getvalue($obs, ($datatype ? "datadir/$datatype" : "datadir")); 
     288    if (!$dir) { 
     289        $self->loging(4, 
     290            "Can't find data directory for %s, type: %s", 
     291            $obs, $datatype || '(none)' 
    286292        ); 
    287         if (!defined($or)) { 
    288             $self->loging(4, "Can't parse %s, check directory exists", $datadir{$datatype}); 
    289             next; 
    290         } 
    291         $or->process; 
    292     } 
     293        return undef; 
     294    } 
     295    my $or = ObsData::Repository::dir->new( 
     296        { 
     297            obsdata => $self, 
     298            dir => $dir, 
     299            obs => $obs, 
     300            datatype => $datatype, 
     301            statusfile => "$dir/obsdata.ini" 
     302        } 
     303    ); 
     304    if (!defined($or)) { 
     305        $self->loging(4, "Can't parse %s, check directory exists", $dir); 
     306        return undef; 
     307    } 
     308     
     309    return($or); 
    293310} 
    294311 
  • trunk/soft/ObsData/ObsData/Repository.pm

    • Property cvs2svn:cvs-rev changed from 1.33 to 1.34
    r95 r96  
    141141            archivefile => $file, 
    142142        ); 
     143        $orda->get_info; 
     144        if(!$orda->file_need_parse) { 
     145            next; 
     146        } 
    143147        $orda->process; 
    144148    } 
     
    157161    $or->{dir} or die "No dir given"; 
    158162    $or->{archivefile} or die "No archivefile given"; 
     163     
     164    $or->loging(0, 
     165        "Preparing to parse %s/%s", 
     166         $or->{dir}, 
     167         $or->{archivefile} 
     168    ); 
    159169 
    160170    bless($or, $class); 
     
    236246    foreach (keys %{$self->{changes}}) { 
    237247        if (defined($self->{changes}{$_}) && $self->{do_if_change}{$_}) { 
    238             $self->loging(0, $self->{changes}{$_}); 
     248            $self->loging(0, "%s => make parse need", $self->{changes}{$_}); 
    239249            $need++; 
    240250        } 
     
    411421    my ($self) = @_; 
    412422 
    413     if (!$self->get_info) { 
    414         return 0; 
    415     } 
    416  
    417423    foreach my $data ($self->list_archive) { 
    418424        if ($self->data_lastcheck($data)) { 
  • trunk/soft/ObsData/bin/obsdata

    • Property cvs2svn:cvs-rev changed from 1.7 to 1.8
    r82 r96  
    1313    'c=s' => \my $configfile, 
    1414    'logfile=s' => \my $log, 
    15     'i|init' => \my $init, 
    1615    'debug' => sub { $verbose = 0 }, 
    1716    'v' => sub { $verbose-- }, 
     
    2827) or die "Can't create obsdata obj"; 
    2928 
    30 if ($init) { 
    31     $obsdata->init_repository or die "Can't init repository"; 
    32 } 
    3329 
    3430$obsdata->load or die "Can load osbdata"; 
    3531 
    36 $obsdata->find_file_obs('ohp'); 
     32my @obs = $obsdata->list_obs; 
     33my @datatype = (); 
     34 
     35foreach my $o (@obs) { 
     36    my %datadir = $obsdata->list_obsdatadir($o); 
     37    foreach my $d (keys %datadir) { 
     38        if(@datatype && !grep { $_ eq $d } @datatype) { 
     39            next; 
     40        } 
     41        my $dir = $obsdata->get_obs_data_handle($o, $d) or next; 
     42        $dir->process; 
     43    } 
     44} 
Note: See TracChangeset for help on using the changeset viewer.