Bugzilla – Attachment 23133 Details for
Bug 11278
Adjusting bulkmarcimport.pl for customization routine and verbose printing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11278: Adjusting bulkmarcimport.pl for customization routine and verbose printing
Bug-11278-Adjusting-bulkmarcimportpl-for-customiza.patch (text/plain), 3.14 KB, created by
Marcel de Rooy
on 2013-11-25 13:52:09 UTC
(
hide
)
Description:
Bug 11278: Adjusting bulkmarcimport.pl for customization routine and verbose printing
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-11-25 13:52:09 UTC
Size:
3.14 KB
patch
obsolete
>From 8788e2f2666c42fd4930e859245cb5116382209e Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 21 Nov 2013 11:29:59 +0100 >Subject: [PATCH] Bug 11278: Adjusting bulkmarcimport.pl for customization > routine and verbose printing >Content-Type: text/plain; charset=utf-8 > >This patch makes two adjustments: >[1] For the verbose option, verbose level 2 now means print the formatted >marcxml per record. >[2] If a module LocalChanges.pm is found in misc/migration_tools, the routine >customize in this module is called for each marc record. This allows you to >make local changes to these marc records before importing them. > >Test plan: >[1] Test the verbose option: do no use -v on the command line, use -v 1 and >-v 2 on the command line. (Do not yet copy LocalChanges.pm in the folder.) >You may used the attached example file on Bugzilla: >perl misc/migration_tools/bulkmarcimport.pl -file zztest01.xml -v 2 -b -m XML -t | more >Note the option t for test; no records will be imported. >[2] Copy LocalChanges.pm in the migration_tools folder. You may use the >example provided on Bugzilla (in a patch). If you use the example module, >check the contents of 001, 005 and 590 fields. (The verbose 2 option allows >you to easily check that.) >--- > misc/migration_tools/bulkmarcimport.pl | 16 ++++++++++++---- > 1 files changed, 12 insertions(+), 4 deletions(-) > >diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl >index 9ca7b31..13de020 100755 >--- a/misc/migration_tools/bulkmarcimport.pl >+++ b/misc/migration_tools/bulkmarcimport.pl >@@ -31,6 +31,11 @@ use Getopt::Long; > use IO::File; > use Pod::Usage; > >+my $localcust= $FindBin::Bin.'/LocalChanges.pm'; >+$localcust= -e $localcust? $localcust: undef; >+require $localcust if $localcust; >+$localcust=\&customize if $localcust; >+ > use open qw( :std :encoding(UTF-8) ); > binmode( STDOUT, ":encoding(UTF-8)" ); > my ( $input_marc_file, $number, $offset) = ('',0,0); >@@ -52,7 +57,7 @@ GetOptions( > 't|test' => \$test_parameter, > 's' => \$skip_marc8_conversion, > 'c:s' => \$char_encoding, >- 'v:s' => \$verbose, >+ 'v:i' => \$verbose, > 'fk' => \$fk_off, > 'm:s' => \$format, > 'l:s' => \$logfile, >@@ -202,9 +207,10 @@ RECORD: while ( ) { > # skip if we get an empty record (that is MARC valid, but will result in AddBiblio failure > last unless ( $record ); > $i++; >- print "."; >- print "\n$i" unless $i % 100; >- >+ if( ($verbose//1)==1 ) { #no dot for verbose==2 >+ print "." . ( $i % 100==0 ? "\n$i" : '' ); >+ } >+ > # transcode the record to UTF8 if needed & applicable. > if ($record->encoding() eq 'MARC-8' and not $skip_marc8_conversion) { > # FIXME update condition >@@ -216,6 +222,7 @@ RECORD: while ( ) { > } > } > SetUTF8Flag($record); >+ &$localcust($record) if $localcust; > my $isbn; > # remove trailing - in isbn (only for biblios, of course) > if ($biblios && $cleanisbn) { >@@ -457,6 +464,7 @@ RECORD: while ( ) { > } > $dbh->commit() if (0 == $i % $commitnum); > } >+ print $record->as_formatted()."\n" if ($verbose//0)==2; > last if $i == $number; > } > $dbh->commit(); >-- >1.7.7.6
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11278
:
23061
|
23062
|
23063
|
23133
|
23134
|
24748
|
24749
|
24750
|
26087
|
26088
|
26090
|
26099
|
26100
|
26101