View | Details | Raw Unified | Return to bug 37478
Collapse All | Expand All

(-)a/misc/migration_tools/bulkmarcimport.pl (-1 / +17 lines)
Lines 9-14 use Modern::Perl; Link Here
9
use MARC::File::USMARC;
9
use MARC::File::USMARC;
10
use MARC::File::XML;
10
use MARC::File::XML;
11
use MARC::Batch;
11
use MARC::Batch;
12
use MARC::Lint;
12
use Encode;
13
use Encode;
13
14
14
use Koha::Script;
15
use Koha::Script;
Lines 76-81 my $localcust; Link Here
76
my $marc_mod_template    = '';
77
my $marc_mod_template    = '';
77
my $marc_mod_template_id = -1;
78
my $marc_mod_template_id = -1;
78
my $skip_indexing        = 0;
79
my $skip_indexing        = 0;
80
my $strict_mode;
79
$| = 1;
81
$| = 1;
80
82
81
GetOptions(
83
GetOptions(
Lines 113-118 GetOptions( Link Here
113
    'custom:s'          => \$localcust,
115
    'custom:s'          => \$localcust,
114
    'marcmodtemplate:s' => \$marc_mod_template,
116
    'marcmodtemplate:s' => \$marc_mod_template,
115
    'si|skip_indexing'  => \$skip_indexing,
117
    'si|skip_indexing'  => \$skip_indexing,
118
    'st|strict'         => \$strict_mode,
116
);
119
);
117
120
118
$biblios ||= !$authorities;
121
$biblios ||= !$authorities;
Lines 320-325 my $record_number = 0; Link Here
320
my $logger        = Koha::Logger->get;
323
my $logger        = Koha::Logger->get;
321
my $schema        = Koha::Database->schema;
324
my $schema        = Koha::Database->schema;
322
my $marc_records  = [];
325
my $marc_records  = [];
326
my $lint          = MARC::Lint->new;
323
RECORD: while () {
327
RECORD: while () {
324
    my $record;
328
    my $record;
325
    $record_number++;
329
    $record_number++;
Lines 339-344 RECORD: while () { Link Here
339
    }
343
    }
340
    if ($record) {
344
    if ($record) {
341
345
346
        if ($strict_mode) {
347
            my $xml = $record->as_xml_record();
348
            eval { MARC::Record::new_from_xml( $xml, 'UTF-8', "MARC21" ); };
349
            if ($@) {
350
                print "Record $record_number generated invalid xml:\n";
351
                $lint->check_record($record);
352
                foreach my $warning ( $lint->warnings ) {
353
                    print "    " . $warning . "\n";
354
                }
355
                print "    Record skipped!";
356
                next;
357
            }
358
        }
342
        # transcode the record to UTF8 if needed & applicable.
359
        # transcode the record to UTF8 if needed & applicable.
343
        if ( $record->encoding() eq 'MARC-8' and not $skip_marc8_conversion ) {
360
        if ( $record->encoding() eq 'MARC-8' and not $skip_marc8_conversion ) {
344
            my ( $guessed_charset, $charset_errors );
361
            my ( $guessed_charset, $charset_errors );
345
- 

Return to bug 37478