From 8801c35bb026435a2f8f46f6f1788fc62974c358 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 8 Dec 2017 09:03:36 +0100 Subject: [PATCH] added --marcxml flag --- lib/WebPAC/Output/MARC.pm | 15 +++++++++------ run.pl | 11 +++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/WebPAC/Output/MARC.pm b/lib/WebPAC/Output/MARC.pm index 00de7cf..97500e1 100644 --- a/lib/WebPAC/Output/MARC.pm +++ b/lib/WebPAC/Output/MARC.pm @@ -37,6 +37,7 @@ L. marc_encoding => 'utf-8', lint => 1, dump => 0, + marcxml => 0, ) =cut @@ -56,13 +57,15 @@ sub new { $self->{marc_encoding} ||= 'utf-8'; if (my $path = $self->{path}) { - open($self->{fh}, '>', $path) || + open($self->{fh}, '>', $path . '.marc') || $log->logdie("can't open MARC output $path: $!"); binmode($self->{fh}, ':utf8'); - $log->info("Creating MARC export file $path", $self->{lint} ? ' (with lint)' : '', " encoding ", $self->{marc_encoding}, "\n"); - if ( $ENV{MARCXML} ) { - open($self->{fh_marcxml}, '>:utf8', "$path.marcxml"); + $log->info("Creating MARC export file $path.marc", $self->{lint} ? ' (with lint)' : '', " encoding ", $self->{marc_encoding}, "\n"); + if ( $self->{marcxml} || $ENV{MARCXML} ) { + open($self->{fh_marcxml}, '>:utf8', "$path.marcxml") || + $log->logdie("can't open MARCXML output $path.marcxml: $!"); + $log->info("Creating MARCXML export file $path.marcxml"); print {$self->{fh_marcxml}} qq{\n\n}; } } else { @@ -179,11 +182,11 @@ sub finish { my $log = $self->get_logger; - close( $self->{fh} ) or $log->logdie("can't close ", $self->{path}, ": $!"); + close( $self->{fh} ) or $log->logdie("can't close ", $self->{path}, ".marc: $!"); if ( $self->{fh_marcxml} ) { print {$self->{fh_marcxml}} qq{\n}; - $log->info("MARCXML file size ", -s $self->{fh_marcxml}, " bytes"); + $log->info("MARCXML file ", $self->{path}, ".marcxml ", -s $self->{fh_marcxml}, " bytes"); close( $self->{fh_marcxml} ); } if (my $w = $self->{_marc_lint_warnings}) { diff --git a/run.pl b/run.pl index 5560537..a8c4e70 100755 --- a/run.pl +++ b/run.pl @@ -86,6 +86,10 @@ You can use this option as C<--no-marc-generate> to disable MARC generation. By default turned on if normalisation file has C directives. You can disable lint messages with C<--no-marc-lint>. +=item --marc-xml + +Creeate MARCXML file (this can be quite large) + =item --marc-dump Force dump or input and marc record for debugging. @@ -122,8 +126,9 @@ my $stats = 0; my $validate_path; my $validate_delimiters_path; my $marc_generate = 1; -my $marc_lint = 1; +my $marc_lint = 0; my $marc_dump = 0; +my $marc_xml = 0; my $parallel = 0; my $only_links = 0; my $merge = 0; @@ -146,6 +151,7 @@ GetOptions( "marc-generate!" => \$marc_generate, "marc-lint!" => \$marc_lint, "marc-dump!" => \$marc_dump, + "marcxml!" => \$marc_xml, "parallel=i" => \$parallel, "only-links!" => \$only_links, "merge" => \$merge, @@ -535,9 +541,10 @@ foreach my $database ( sort keys %{ $config->databases } ) { mkpath $out_marc unless -e $out_marc; $marc = new WebPAC::Output::MARC( - path => "$out_marc/${database}-${input_name}.marc", + path => "$out_marc/${database}-${input_name}", lint => $marc_lint, dump => $marc_dump, + marcxml => $marc_xml, ); } -- 2.20.1