line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Exporter::MARC; |
2
|
7
|
|
|
7
|
|
295628
|
use Catmandu::Sane; |
|
7
|
|
|
|
|
800650
|
|
|
7
|
|
|
|
|
41
|
|
3
|
7
|
|
|
7
|
|
1597
|
use Catmandu::Util; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
223
|
|
4
|
7
|
|
|
7
|
|
34
|
use Moo; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.21'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has type => (is => 'ro' , default => sub { 'ISO' }); |
9
|
|
|
|
|
|
|
has skip_errors => (is => 'ro'); |
10
|
|
|
|
|
|
|
has _exporter => (is => 'ro'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'Catmandu::Exporter'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub BUILD { |
15
|
6
|
|
|
6
|
0
|
17717
|
my ($self,$args) = @_; |
16
|
|
|
|
|
|
|
|
17
|
6
|
|
|
|
|
25
|
my $type = $self->type; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# keep USMARC temporary as alias for ISO, remove in future version |
20
|
|
|
|
|
|
|
# print deprecation warning |
21
|
6
|
100
|
|
|
|
22
|
if ($type eq 'USMARC') { |
22
|
1
|
|
|
|
|
3
|
$type = 'ISO'; |
23
|
1
|
|
|
|
|
16
|
warn( "deprecated", "Oops! Exporter \"USMARC\" is deprecated. Use \"ISO\" instead." ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
6
|
|
|
|
|
31
|
my $pkg = Catmandu::Util::require_package($type,'Catmandu::Exporter::MARC'); |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
137
|
delete $args->{file}; |
29
|
6
|
|
|
|
|
10
|
delete $args->{fix}; |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
103
|
$self->{_exporter} = $pkg->new(file => $self->file, %$args); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub add { |
35
|
|
|
|
|
|
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
if ($self->skip_errors) { |
38
|
|
|
|
|
|
|
eval { |
39
|
|
|
|
|
|
|
$self->_exporter->add($_[1]); |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if ($@) { |
43
|
|
|
|
|
|
|
$self->log->error("error at record " . $self->count . " : $@"); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
|
|
|
|
|
|
$self->_exporter->add($_[1]); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub commit { |
52
|
|
|
|
|
|
|
$_[0]->_exporter->commit; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Catmandu::Exporter::MARC - Exporter for MARC records |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Convert MARC to MARC |
66
|
|
|
|
|
|
|
$ catmandu convert MARC to MARC < /foo/bar.mrc > /foo/output.mrc |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Add fixes |
69
|
|
|
|
|
|
|
$ catmandu convert MARC to MARC --fix myfixes.txt < /foo/bar.mrc > /foo/output.mrc |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Convert on format to another format |
72
|
|
|
|
|
|
|
$ catmandu convert MARC --type ISO to MARC --type ALEPHSEQ < /foo/bar.mrc > /foo/bar.aleph |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 DESCRIPTION |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Catmandu::Exporter::MARC is a L<Catmandu::Exporter> to serialize (write) MARC records |
77
|
|
|
|
|
|
|
to a file or the standard output. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 CONFIGURATION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item file |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Write output to a local file given by its path or file handle. Alternatively a |
86
|
|
|
|
|
|
|
scalar reference can be passed to write to a string and a code reference can be |
87
|
|
|
|
|
|
|
used to write to a callback function. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item fh |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Write the output to an L<IO::Handle>. If not specified, |
92
|
|
|
|
|
|
|
L<Catmandu::Util::io|Catmandu::Util/IO-functions> is used to create the output |
93
|
|
|
|
|
|
|
handle from the C<file> argument or by using STDOUT. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item fix |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
An ARRAY of one or more fixes or file scripts to be applied to exported items. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item type |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
The MARC format to parse. The following MARC parsers are available: |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
ISO: L<Catmandu::Importer::MARC::ISO> (default) - a strict ISO 2709 exporter |
104
|
|
|
|
|
|
|
ALEPHSEQ: L<Catmandu::Importer::MARC::ALEPHSEQ> - an exporter for Ex Libris Aleph sequential files |
105
|
|
|
|
|
|
|
MARCMaker: L<Catmandu::Importer::MARC::MARCMaker> - an exporter for MARCMaker/MARCBreaker records |
106
|
|
|
|
|
|
|
MiJ: L<Catmandu::Importer::MARC::MiJ> (MARC in JSON) - an export for the MARC-in-JSON format |
107
|
|
|
|
|
|
|
XML: L<Catmandu::Importer::MARC::XML> - an exporter for the MARC XML format |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item skip_errors |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
If set, then any errors when parsing MARC output will be skipped and ignored. Use the |
112
|
|
|
|
|
|
|
debug setting of catmandu to view all error messages: |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$ catmandu -D convert MARC to MARC --skip_errors 1 --fix myfixes.txt < /foo/bar.mrc |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item <other> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Every MARC importer can have its own options. Check the documentation of the specific importer. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SEE ALSO |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
L<Catmandu::Importer::MARC> |