From 6cb814b9940efed81fe33b0a3df20780ec623d98 Mon Sep 17 00:00:00 2001 From: Jason Boyer Date: Fri, 18 Nov 2022 08:31:31 -0500 Subject: [PATCH] LP1754455: Sanity checking and auto-strip 852s when using --items If a user passes --strip / inform them that their request to output nothing but empty records has been denied. Also auto-remove existing 852 fields when using --items because only actual holdings data should be output in that case. Signed-off-by: Jason Boyer Signed-off-by: Galen Charlton --- Open-ILS/src/support-scripts/marc_export.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/support-scripts/marc_export.in b/Open-ILS/src/support-scripts/marc_export.in index 78c9c4f8ff..fd6a33d5cb 100755 --- a/Open-ILS/src/support-scripts/marc_export.in +++ b/Open-ILS/src/support-scripts/marc_export.in @@ -166,13 +166,13 @@ libraries with the short names "BR1" and "BR2": $0 --library BR1 --library BR2 --encoding UTF-8 > sys1_bibs.mrc The --strip option can be used more than once which imples an "OR" operation. -If the fie]d argument is omitted (e.g., "/0", it is treated like "..." (all fields). +If the field argument is omitted (e.g., "/0", it is treated like "..." (all fields). If the subfield argument is omitted (e.g. "100/", it is treated like "." (all subfields). Examples: --strip /0 Remove all 0 subfields --strip 1[23]. Remove fields with tags 120 through 139, inclusive. - --strip / Remove all subfields (probably not useful). + --strip 856/x Remove subfield x from 856 tags HELP exit; } @@ -213,6 +213,10 @@ HELP foreach my $strip_value (@{$opts{strip}}) { my $trec = {}; + if ($strip_value eq "/") { + print STDERR "Ignoring empty --strip parameter; all records would be empty.\n"; + next; + } if ($strip_value =~ /\//) { $trec->{tag} = $`; $trec->{tag} = "..." if ($` eq ""); @@ -596,6 +600,8 @@ sub next { } if ($Marque::config->option_value('items')) { + # If --items was passed discard any static 852 fields; they're either dupes, out-of-sync, or junk. + $marc->delete_fields($marc->field('852')); my @acps = $self->acps_for_bre($r); foreach my $acp (@acps) { next unless ($acp); -- 2.11.0