/[webpac2]/branches/Sack/run.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/Sack/run.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1184 by dpavlin, Mon May 18 18:51:40 2009 UTC revision 1246 by dpavlin, Wed Jul 22 09:23:36 2009 UTC
# Line 22  use File::Slurp; Line 22  use File::Slurp;
22  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
23  use Storable qw/dclone/;  use Storable qw/dclone/;
24  use Pod::Usage qw/pod2usage/;  use Pod::Usage qw/pod2usage/;
25  use LWP::Simple;  use LWP::Simple qw//;
26    
27  use POSIX ":sys_wait_h"; # imports WNOHANG  use POSIX ":sys_wait_h"; # imports WNOHANG
28    
# Line 383  foreach my $database ( sort keys %{ $con Line 383  foreach my $database ( sort keys %{ $con
383                          next;                          next;
384                  }                  }
385    
386                  next if ($only_input && ($input_name !~ m#$only_input#i && $input->{type} !~ m#$only_input#i));                  next if defined $only_input && $input_name !~ m#$only_input#i;
387    
388                  my $type = lc($input->{type});                  my $type = lc($input->{type});
389    
# Line 417  foreach my $database ( sort keys %{ $con Line 417  foreach my $database ( sort keys %{ $con
417                          $base =~ s{/[^/]+$}{};                          $base =~ s{/[^/]+$}{};
418                          mkpath $base unless -e $base;                          mkpath $base unless -e $base;
419    
420                          my $rc = mirror( "$mirror/$path", $path );                          my $rc = LWP::Simple::mirror( "$mirror/$path", $path );
421                          if (is_error( $rc )) {                          if (LWP::Simple::is_error( $rc )) {
422                                  die "can't mirror $mirror/$path -> $path [$rc]";                                  die "can't mirror $mirror/$path -> $path [$rc]";
423                          } else {                          } else {
424                                  $log->info( "mirror ", $path, " [$rc] ", -s $path, " bytes" );                                  $log->info( "mirror ", $path, " [$rc] ", -s $path, " bytes" );
# Line 542  foreach my $database ( sort keys %{ $con Line 542  foreach my $database ( sort keys %{ $con
542                  }                  }
543    
544                  my $rules = $parser->normalize_rules($database,$input_name);                  my $rules = $parser->normalize_rules($database,$input_name);
545                  $log->logwarn("no normalize rules for $database/$input_name") unless $rules;                  if ( ! $rules ) {
546                            $log->logwarn("no normalize rules for $database/$input_name", $input_db->input_module->can('normalize') ? " using normalize from input module" : '');
547                            next;
548                    }
549    
550                  $log->debug("parsed normalize rules:\n$rules");                  $log->debug("parsed normalize rules:\n$rules");
551    
# Line 603  foreach my $database ( sort keys %{ $con Line 606  foreach my $database ( sort keys %{ $con
606                                  push @{ $row->{'000'} }, $pos;                                  push @{ $row->{'000'} }, $pos;
607                          }                          }
608    
609                            foreach my $out ( @output_modules ) {
610                                    $out->add_row( $mfn, $row ) if $out->can('add_row');
611                            }
612    
613                          if ($validate) {                          if ($validate) {
614                                  if ( my $errors = $validate->validate_rec( $row, $input_db->dump_ascii ) ) {                                  if ( my $errors = $validate->validate_rec( $row, $input_db->dump_ascii ) ) {
# Line 613  foreach my $database ( sort keys %{ $con Line 619  foreach my $database ( sort keys %{ $con
619                                  next;   # validation doesn't create any output                                  next;   # validation doesn't create any output
620                          }                          }
621    
622                            my $ds;
623    
624                          if ($rules) {                          if ($rules) {
625    
626                                  my $ds = WebPAC::Normalize::data_structure(                                  $ds = WebPAC::Normalize::data_structure(
627                                          row => $row,                                          row => $row,
628                                          rules => $rules,                                          rules => $rules,
629                                          lookup => $lookup_hash,                                          lookup => $lookup_hash,
# Line 632  foreach my $database ( sort keys %{ $con Line 640  foreach my $database ( sort keys %{ $con
640                                          },                                          },
641                                  );                                  );
642    
643                                  $log->debug("ds = ", sub { dump($ds) });                          } elsif ( $input_db->input_module->can('normalize') ) {
644                                    $ds = $input_db->input_module->normalize( $mfn );
645                                  if ( $ds ) {                          }
646    
647                                          $store->save_ds(                          if ( $ds ) {
648                                                  database => $database,                                  $log->debug("ds = ", sub { dump($ds) });
                                                 input => $input_name,  
                                                 id => $mfn,  
                                                 ds => $ds,  
                                         ) if !$stats;  
   
                                         $indexer->add(  
                                                 id => "${input_name}/${mfn}",  
                                                 ds => $ds,  
                                                 type => $config->get($indexer_config)->{type},  
                                         ) if $indexer;  
649    
650                                          foreach my $out ( @output_modules ) {                                  $store->save_ds(
651                                                  $out->add( $mfn, $ds ) if $out->can('add');                                          database => $database,
652                                          }                                          input => $input_name,
653                                            id => $mfn,
654                                            ds => $ds,
655                                    ) if !$stats;
656    
657                                    $indexer->add(
658                                            id => "${input_name}/${mfn}",
659                                            ds => $ds,
660                                            type => $config->get($indexer_config)->{type},
661                                    ) if $indexer;
662    
663                                  } else {                                  foreach my $out ( @output_modules ) {
664                                          $log->warn("record $pos didn't produce any output after normalization rules!") unless $marc;                                          $out->add( $mfn, $ds ) if $out->can('add');
665                                  }                                  }
                         }  
666    
667                            } else {
668                                    $log->warn("record $pos didn't produce any output after normalization rules!") unless $marc;
669                            }
670                          if ($marc) {                          if ($marc) {
671                                  my $i = 0;                                  my $i = 0;
672    

Legend:
Removed from v.1184  
changed lines
  Added in v.1246

  ViewVC Help
Powered by ViewVC 1.1.26