Changeset 113


Ignore:
Timestamp:
12/11/05 17:52:32 (19 years ago)
Author:
thauvin
Message:
  • fill doc
File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.39 to 1.40
    r112 r113  
    1515=head1 METHODS 
    1616 
    17 =head2 new 
     17=head2 ObsData::Repository 
     18 
     19=head3 new 
     20 
     21Create a new ObsData::Repository object 
    1822 
    1923=cut 
     
    5559} 
    5660 
     61=head3 save_status 
     62 
     63Save current information about parsed files into status file 
     64 
     65=cut 
     66 
    5767sub save_status { 
    5868    my ($self) = @_; 
     
    6878} 
    6979 
     80=head3 loging($level, $msg, ...) 
     81 
     82Pass a message for loging to ObsData Object. See L<ObsData> 
     83 
     84=cut 
     85 
    7086sub loging { 
    7187    my $self = shift; 
     
    7389} 
    7490 
     91=head2 ObsData::Repository::dir 
     92 
     93The child class to handle directory 
     94 
     95=cut 
     96 
    7597package ObsData::Repository::dir; 
    7698 
    7799our @ISA = qw(ObsData::Repository); 
     100 
     101=head3 new 
     102 
     103=cut 
    78104 
    79105sub new { 
     
    84110    bless($or, $class); 
    85111} 
     112 
     113=head3 findfile 
     114 
     115Return the list of files needing to be checked 
     116 
     117=cut 
    86118 
    87119sub findfile { 
     
    110142} 
    111143 
     144=head3 process 
     145 
     146Process all files in directory 
     147 
     148=cut 
     149 
    112150sub process { 
    113151    my ($self) = @_; 
     
    131169} 
    132170 
     171=head2 ObsData::Repository::dir::archive 
     172 
     173Object to handle archive and to dispatch data 
     174 
     175=cut 
     176 
    133177package ObsData::Repository::dir::archive; 
    134178 
    135179our @ISA = qw(ObsData::Repository); 
     180 
     181=head3 new 
     182 
     183=cut 
    136184 
    137185sub new { 
     
    153201    bless($or, $class); 
    154202} 
     203 
     204=head3 load_archive 
     205 
     206Try to read archive, return 1 on success 
     207 
     208=cut 
     209 
     210sub load_archive { 
     211    my ($self) = @_; 
     212    if ($self->{Oarchive}) { 
     213        return 1; 
     214    } else { 
     215        $self->{Oarchive} = ObsData::Archive->new("$self->{dir}/$self->{archivefile}"); 
     216        if ($self->{Oarchive}) { 
     217            $self->loging(0, 
     218                "Archive %s/%s properly load", 
     219                $self->{dir}, $self->{archivefile} 
     220            ); 
     221            return 1; 
     222        } else { 
     223            $self->loging(4,  
     224                "Can't handle archive %s/%s: %s, skipping", 
     225                $self->{dir}, $self->{archivefile}, 
     226                ObsData::Archive->error 
     227            ); 
     228            return 0; 
     229        } 
     230    } 
     231} 
     232 
     233=head3 checks 
     234 
     235=cut 
    155236 
    156237my $checks = { 
     
    216297        } 
    217298    }, 
     299 
     300    data_extracted => sub { 
     301        my ($self, $datafile) = @_; 
     302        my $last_process = $self->{status}->val($self->{archivefile}, "data_processtime_$datafile"); 
     303        if ($last_process) { 
     304            $self->loging(0, "%s/%s has been already processed at %s", 
     305                $self->{archivefile}, 
     306                $datafile, 
     307                scalar(localtime($last_process)), 
     308            ); 
     309        } 
     310        $last_process 
     311    }, 
    218312}; 
    219313 
     
    224318#} 
    225319 
     320=head3 do_check($check, @args) 
     321 
     322Perform $check with @args if exists and return result of check 
     323 
     324=cut 
     325 
    226326sub do_check { 
    227327    my ($self, $check, @args) = @_; 
     
    237337} 
    238338 
    239 sub do_continue { 
    240     my ($self, $why, @args) = @_; 
    241  
    242     if ($self->{interative_callback}) { 
    243         return $self->{interative_callback}->($self, $why, @args); 
    244     } else { 
    245         return $self->default_checks($why, @args); 
    246     } 
    247 } 
     339=head3 default_checks($why, @args) 
     340 
     341Perform defaults checks 
     342 
     343=cut 
    248344 
    249345sub default_checks { 
     
    281377} 
    282378 
    283 sub load_archive { 
    284     my ($self) = @_; 
    285     if ($self->{Oarchive}) { 
    286         return 1; 
     379=head3 do_continue($why, @args) 
     380 
     381Perform default or call the interactive callback. 
     382 
     383    $why is the reason of the call 
     384    @args are argument to passed to callback 
     385 
     386=cut 
     387 
     388sub do_continue { 
     389    my ($self, $why, @args) = @_; 
     390 
     391    if ($self->{interative_callback}) { 
     392        return $self->{interative_callback}->($self, $why, @args); 
    287393    } else { 
    288         $self->{Oarchive} = ObsData::Archive->new("$self->{dir}/$self->{archivefile}"); 
    289         if ($self->{Oarchive}) { 
    290             $self->loging(0, 
    291                 "Archive %s/%s properly load", 
    292                 $self->{dir}, $self->{archivefile} 
    293             ); 
    294             return 1; 
    295         } else { 
    296             $self->loging(4,  
    297                 "Can't handle archive %s/%s: %s, skipping", 
    298                 $self->{dir}, $self->{archivefile}, 
    299                 ObsData::Archive->error 
    300             ); 
    301             return 0; 
    302         } 
    303     } 
    304 } 
     394        return $self->default_checks($why, @args); 
     395    } 
     396} 
     397 
     398=head3 list_archive 
     399 
     400Return archive content 
     401 
     402=cut 
    305403 
    306404sub list_archive { 
     
    310408    return $self->{Oarchive}->ls; 
    311409} 
     410 
     411=head3 update_status 
     412 
     413Update status information about current archive 
     414 
     415=cut 
    312416 
    313417sub update_status { 
     
    325429# Sub data function: 
    326430 
    327 sub data_lastcheck { 
    328     my ($self, $datafile) = @_; 
    329     my $last_process = $self->{status}->val($self->{archivefile}, "data_processtime_$datafile"); 
    330     if ($last_process) { 
    331         $self->loging(0, "%s/%s has been already processed at %s", 
    332             $self->{archivefile}, 
    333             $datafile, 
    334             scalar(localtime($last_process)), 
    335         ); 
    336     } 
    337     $last_process 
    338 } 
     431=head3 get_data_dest($datafile) 
     432 
     433Return the datatype and destination for $datafile 
     434 
     435=cut 
    339436 
    340437sub get_data_dest { 
     
    356453    return($t, $d); 
    357454} 
     455 
     456=head3 extract_data($datafile, $datatype, $destfile) 
     457 
     458Extract data file into $destfile, $datafile is informationnal only. 
     459 
     460$datatype and $destfile are the result of L<get_data_dest>. 
     461 
     462A basic call is: 
     463    $o->extract_data($file, $self->get_data_dest($file)); 
     464 
     465Return 1 on success 
     466 
     467=cut 
    358468 
    359469sub extract_data { 
     
    438548} 
    439549 
     550=head3 process 
     551 
     552Process all files in the archive 
     553 
     554=cut 
     555 
    440556sub process { 
    441557    my ($self) = @_; 
     
    458574} 
    459575 
     576=head1 AUTHOR 
     577 
     578Olivier Thauvin <olivier.thauvin@aerov.jussieu.fr> 
     579 
     580=cut 
     581 
    4605821; 
Note: See TracChangeset for help on using the changeset viewer.