/[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 552 by dpavlin, Fri Jun 30 20:43:18 2006 UTC revision 556 by dpavlin, Sat Jul 1 20:29:09 2006 UTC
# Line 4  use strict; Line 4  use strict;
4    
5  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
6  use File::Temp qw/tempdir/;  use File::Temp qw/tempdir/;
 use Data::Dumper;  
7  use lib './lib';  use lib './lib';
8    
9  use WebPAC::Common 0.02;  use WebPAC::Common 0.02;
# Line 20  use File::Path; Line 19  use File::Path;
19  use Time::HiRes qw/time/;  use Time::HiRes qw/time/;
20  use File::Slurp;  use File::Slurp;
21  use MARC::Record 2.0;   # need 2.0 for utf-8 encoding see marcpm.sf.net  use MARC::Record 2.0;   # need 2.0 for utf-8 encoding see marcpm.sf.net
22    use MARC::Lint;
23    use Data::Dump qw/dump/;
24    
25  =head1 NAME  =head1 NAME
26    
# Line 71  This option specifies normalisation file Line 72  This option specifies normalisation file
72    
73  Optional path to output file  Optional path to output file
74    
75    =item --marc-lint
76    
77    By default turned on if C<--marc-normalize> is used. You can disable lint
78    messages with C<--no-arc-lint>.
79    
80  =back  =back
81    
82  =cut  =cut
# Line 85  my $only_filter; Line 91  my $only_filter;
91  my $stats = 0;  my $stats = 0;
92  my $validate_path;  my $validate_path;
93  my ($marc_normalize, $marc_output);  my ($marc_normalize, $marc_output);
94    my $marc_lint = 1;
95    
96  GetOptions(  GetOptions(
97          "limit=i" => \$limit,          "limit=i" => \$limit,
# Line 98  GetOptions( Line 105  GetOptions(
105          "validate=s" => \$validate_path,          "validate=s" => \$validate_path,
106          "marc-normalize=s" => \$marc_normalize,          "marc-normalize=s" => \$marc_normalize,
107          "marc-output=s" => \$marc_output,          "marc-output=s" => \$marc_output,
108            "marc-lint!" => \$marc_lint,
109  );  );
110    
111  $config = LoadFile($config);  $config = LoadFile($config);
112    
113  print "config = ",Dumper($config) if ($debug);  print "config = ",dump($config) if ($debug);
114    
115  die "no databases in config file!\n" unless ($config->{databases});  die "no databases in config file!\n" unless ($config->{databases});
116    
# Line 131  my $start_t = time(); Line 139  my $start_t = time();
139  my @links;  my @links;
140  my $indexer;  my $indexer;
141    
142    my $lint = new MARC::Lint if ($marc_lint);
143    
144  while (my ($database, $db_config) = each %{ $config->{databases} }) {  while (my ($database, $db_config) = each %{ $config->{databases} }) {
145    
146          my ($only_database,$only_input) = split(m#/#, $only_filter) if ($only_filter);          my ($only_database,$only_input) = split(m#/#, $only_filter) if ($only_filter);
# Line 260  while (my ($database, $db_config) = each Line 270  while (my ($database, $db_config) = each
270                                  open($marc_fh, '>', $path) ||                                  open($marc_fh, '>', $path) ||
271                                          $log->logdie("can't open MARC output $path: $!");                                          $log->logdie("can't open MARC output $path: $!");
272    
273                                  $log->info("Creating MARC export file $path\n");                                  $log->info("Creating MARC export file $path", $marc_lint ? ' (with lint)' : '', "\n");
274                          }                          }
275    
276                          # reset position in database                          # reset position in database
# Line 307  while (my ($database, $db_config) = each Line 317  while (my ($database, $db_config) = each
317                                  if ($marc_fh) {                                  if ($marc_fh) {
318                                          my $marc = new MARC::Record;                                          my $marc = new MARC::Record;
319                                          $marc->encoding( 'utf-8' );                                          $marc->encoding( 'utf-8' );
320                                          $marc->add_fields( WebPAC::Normalize::_get_marc_fields() );                                          my @marc_fields = WebPAC::Normalize::_get_marc_fields();
321                                          print $marc_fh $marc->as_usmarc;                                          if (! @marc_fields) {
322                                                    $log->warn("MARC record $mfn is empty, skipping");
323                                            } else {
324                                                    $marc->add_fields( @marc_fields );
325                                                    if ($marc_lint) {
326                                                            $lint->check_record( $marc );
327                                                            my $err = join( "\n", $lint->warnings );
328                                                            $log->error("MARC lint detected warning on MFN $mfn\n",
329                                                                    "Original imput row: ",dump($row), "\n",
330                                                                    "Normalized MARC row: ",dump(@marc_fields), "\n",
331                                                                    "MARC lint warnings: ",$err,"\n"
332                                                            ) if ($err);
333                                                    }
334                                                    print $marc_fh $marc->as_usmarc;
335                                            }
336                                  }                                  }
337    
338                                  $total_rows++;                                  $total_rows++;

Legend:
Removed from v.552  
changed lines
  Added in v.556

  ViewVC Help
Powered by ViewVC 1.1.26