Changeset 113
- Timestamp:
- 12/11/05 17:52:32 (19 years ago)
- 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 15 15 =head1 METHODS 16 16 17 =head2 new 17 =head2 ObsData::Repository 18 19 =head3 new 20 21 Create a new ObsData::Repository object 18 22 19 23 =cut … … 55 59 } 56 60 61 =head3 save_status 62 63 Save current information about parsed files into status file 64 65 =cut 66 57 67 sub save_status { 58 68 my ($self) = @_; … … 68 78 } 69 79 80 =head3 loging($level, $msg, ...) 81 82 Pass a message for loging to ObsData Object. See L<ObsData> 83 84 =cut 85 70 86 sub loging { 71 87 my $self = shift; … … 73 89 } 74 90 91 =head2 ObsData::Repository::dir 92 93 The child class to handle directory 94 95 =cut 96 75 97 package ObsData::Repository::dir; 76 98 77 99 our @ISA = qw(ObsData::Repository); 100 101 =head3 new 102 103 =cut 78 104 79 105 sub new { … … 84 110 bless($or, $class); 85 111 } 112 113 =head3 findfile 114 115 Return the list of files needing to be checked 116 117 =cut 86 118 87 119 sub findfile { … … 110 142 } 111 143 144 =head3 process 145 146 Process all files in directory 147 148 =cut 149 112 150 sub process { 113 151 my ($self) = @_; … … 131 169 } 132 170 171 =head2 ObsData::Repository::dir::archive 172 173 Object to handle archive and to dispatch data 174 175 =cut 176 133 177 package ObsData::Repository::dir::archive; 134 178 135 179 our @ISA = qw(ObsData::Repository); 180 181 =head3 new 182 183 =cut 136 184 137 185 sub new { … … 153 201 bless($or, $class); 154 202 } 203 204 =head3 load_archive 205 206 Try to read archive, return 1 on success 207 208 =cut 209 210 sub 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 155 236 156 237 my $checks = { … … 216 297 } 217 298 }, 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 }, 218 312 }; 219 313 … … 224 318 #} 225 319 320 =head3 do_check($check, @args) 321 322 Perform $check with @args if exists and return result of check 323 324 =cut 325 226 326 sub do_check { 227 327 my ($self, $check, @args) = @_; … … 237 337 } 238 338 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 341 Perform defaults checks 342 343 =cut 248 344 249 345 sub default_checks { … … 281 377 } 282 378 283 sub load_archive { 284 my ($self) = @_; 285 if ($self->{Oarchive}) { 286 return 1; 379 =head3 do_continue($why, @args) 380 381 Perform 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 388 sub do_continue { 389 my ($self, $why, @args) = @_; 390 391 if ($self->{interative_callback}) { 392 return $self->{interative_callback}->($self, $why, @args); 287 393 } 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 400 Return archive content 401 402 =cut 305 403 306 404 sub list_archive { … … 310 408 return $self->{Oarchive}->ls; 311 409 } 410 411 =head3 update_status 412 413 Update status information about current archive 414 415 =cut 312 416 313 417 sub update_status { … … 325 429 # Sub data function: 326 430 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 433 Return the datatype and destination for $datafile 434 435 =cut 339 436 340 437 sub get_data_dest { … … 356 453 return($t, $d); 357 454 } 455 456 =head3 extract_data($datafile, $datatype, $destfile) 457 458 Extract data file into $destfile, $datafile is informationnal only. 459 460 $datatype and $destfile are the result of L<get_data_dest>. 461 462 A basic call is: 463 $o->extract_data($file, $self->get_data_dest($file)); 464 465 Return 1 on success 466 467 =cut 358 468 359 469 sub extract_data { … … 438 548 } 439 549 550 =head3 process 551 552 Process all files in the archive 553 554 =cut 555 440 556 sub process { 441 557 my ($self) = @_; … … 458 574 } 459 575 576 =head1 AUTHOR 577 578 Olivier Thauvin <olivier.thauvin@aerov.jussieu.fr> 579 580 =cut 581 460 582 1;
Note: See TracChangeset
for help on using the changeset viewer.