/[webpac2]/trunk/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 /trunk/run.pl

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

revision 539 by dpavlin, Thu Jun 29 15:29:32 2006 UTC revision 546 by dpavlin, Thu Jun 29 22:53:21 2006 UTC
# Line 19  use Getopt::Long; Line 19  use Getopt::Long;
19  use File::Path;  use File::Path;
20  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
21  use File::Slurp;  use File::Slurp;
22    use MARC::Record 2.0;   # need 2.0 for utf-8 encoding see marcpm.sf.net
23    
24  =head1 NAME  =head1 NAME
25    
# Line 225  while (my ($database, $db_config) = each Line 226  while (my ($database, $db_config) = each
226    
227                  foreach my $normalize (@norm_array) {                  foreach my $normalize (@norm_array) {
228    
                         my $rules;  
229                          my $normalize_path = $normalize->{path} || $log->logdie("can't find normalize path in config");                          my $normalize_path = $normalize->{path} || $log->logdie("can't find normalize path in config");
230    
231                          $log->logdie("Found '$normalize_path' as normalization file which isn't supported any more!") unless ( $normalize_path =~ m!\.pl$!i );                          $log->logdie("Found '$normalize_path' as normalization file which isn't supported any more!") unless ( $normalize_path =~ m!\.pl$!i );
# Line 234  while (my ($database, $db_config) = each Line 234  while (my ($database, $db_config) = each
234    
235                          $log->info("Using $normalize_path for normalization...");                          $log->info("Using $normalize_path for normalization...");
236    
237                            my $marc_fh;
238                            if (my $path = $normalize->{marc21}) {
239                                    open($marc_fh, '>', $path) ||
240                                            $log->logdie("can't open MARC output $path: $!");
241    
242                                    $log->info("Creating MARC export file $path\n");
243                            }
244    
245                          # reset position in database                          # reset position in database
246                          $input_db->seek(1);                          $input_db->seek(1);
247    
# Line 260  while (my ($database, $db_config) = each Line 268  while (my ($database, $db_config) = each
268                                          row => $row,                                          row => $row,
269                                          rules => $rules,                                          rules => $rules,
270                                          lookup => $lookup ? $lookup->lookup_hash : undef,                                          lookup => $lookup ? $lookup->lookup_hash : undef,
271                                            marc_encoding => 'utf-8',
272                                  );                                  );
273    
274                                  $db->save_ds(                                  $db->save_ds(
# Line 272  while (my ($database, $db_config) = each Line 281  while (my ($database, $db_config) = each
281                                          id => $input->{name} . "/" . $mfn,                                          id => $input->{name} . "/" . $mfn,
282                                          ds => $ds,                                          ds => $ds,
283                                          type => $config->{$use_indexer}->{type},                                          type => $config->{$use_indexer}->{type},
284                                  ) if ($indexer);                                  ) if ($indexer && $ds);
285    
286                                    if ($marc_fh) {
287                                            my $marc = new MARC::Record;
288                                            $marc->encoding( 'utf-8' );
289                                            $marc->add_fields( WebPAC::Normalize::_get_marc21_fields() );
290                                            print $marc_fh $marc->as_usmarc;
291                                    }
292    
293                                  $total_rows++;                                  $total_rows++;
294                          }                          }
295    
296                          $log->info("statistics of fields usage:\n", $input_db->stats) if ($stats);                          $log->info("statistics of fields usage:\n", $input_db->stats) if ($stats);
297    
298                  };                          # close MARC file
299                            close($marc_fh) if ($marc_fh);
300    
301                    }
302    
303          }          }
304    

Legend:
Removed from v.539  
changed lines
  Added in v.546

  ViewVC Help
Powered by ViewVC 1.1.26