Skip to content

Commit

Permalink
re-tidied _add_struct_map, in which i had introduced a syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarin committed Sep 19, 2024
1 parent f3a80a6 commit 5e1b9bc
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/HTFeed/METS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -829,21 +829,20 @@ sub _add_struct_map {
my $mets = $self->{mets};
my $volume = $self->{volume};
my $get_pagedata = $self->{pagedata};
my $struct_map = new METS::StructMap(
id => 'SM1',
type => 'physical'
);
my $struct_map = new METS::StructMap(id => 'SM1', type => 'physical');
my $voldiv = new METS::StructMap::Div(type => 'volume');
$struct_map->add_div($voldiv);

my $order = 1;
my $file_groups_by_page = $volume->get_structmap_file_groups_by_page();
foreach my $seqnum (sort(keys(%$file_groups_by_page))) {

foreach my $seqnum (sort keys %$file_groups_by_page) {
my $pagefiles = $file_groups_by_page->{$seqnum};
my $pagediv_ids = [];
my $pagedata;
my @pagedata;
while (my ($filegroup_name, $files) = each(%$pagefiles)) {

while (my ($filegroup_name, $files) = each %$pagefiles) {
foreach my $file (@$files) {
my $fileid = $self->{filegroups}{$filegroup_name}->get_file_id($file);
if (not defined $fileid) {
Expand All @@ -864,9 +863,9 @@ sub _add_struct_map {
@pagedata = %$pagedata if defined $pagedata;
} else {
my $other_pagedata = &$get_pagedata($file);
while (my ($key, $val) = each(%$pagedata)) {
while (my ($key, $val) = each %$pagedata) {
my $val1 = $other_pagedata->{$key};
unless ( not defined $val and not defined $val1 ) or ( $val eq $val1 ) {
unless ( (not defined $val and not defined $val1) or ($val eq $val1) ) {
$self->set_error(
"NotEqualValues",
actual => "other=$val ,$fileid=$val1",
Expand All @@ -876,9 +875,11 @@ sub _add_struct_map {
}
}
}

push(@$pagediv_ids, $fileid);
}
}

$voldiv->add_file_div(
$pagediv_ids,
order => $order++,
Expand All @@ -891,12 +892,11 @@ sub _add_struct_map {

sub _save_mets {
my $self = shift;
my $mets = $self->{mets};

my $mets = $self->{mets};
my $mets_path = $self->{outfile};

open( my $metsxml, ">", "$mets_path" )
or die("Can't open METS xml $mets_path for writing: $!");
open(my $metsxml, ">", "$mets_path") or die("Can't open METS xml $mets_path for writing: $!");
print $metsxml $mets->to_node()->toString(1);
close($metsxml);
}
Expand Down

0 comments on commit 5e1b9bc

Please sign in to comment.