From: dpavlin Date: Mon, 25 May 2015 13:23:27 +0000 (+0200) Subject: cleanup dead code for eprints xml generation X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;ds=sidebyside;h=cb462403ab7f7b56b54d61979d6cbf790a54e10f;p=koha-eprints cleanup dead code for eprints xml generation --- diff --git a/tsv2eprints.pl b/tsv2eprints.pl index a86a04f..d49fd95 100755 --- a/tsv2eprints.pl +++ b/tsv2eprints.pl @@ -79,175 +79,6 @@ warn "# got ", scalar keys %$files, " files\n"; store $files, "$koha_path.biblionumber.file"; my $stat; -my $this_id = ''; -my $item; - -binmode STDOUT, ":utf8"; - -sub dump_item { - my $item = shift || return; - - my $f200 = $item->{200}->[0] || die "no 200 in ",dump($item); - - if ( $f200 =~ s/\s*;\s*([^;]+?)$//i ) { - $item->{mentor} = $1; - $item->{mentor} =~ s/^\s*voditelji?\s*(?:rada)\s*//i; - } else { - warn "MISSING ; voditelj [$f200]\n"; - } - - if ( $f200 =~ s{\s*/\s*([^/]+?)$}{} ) { - $item->{autor} = $1; - } else { - warn "MISSING / autor [$f200]\n"; - } - - if ( $f200 =~ s{\s*:\s*([^:]+?)$}{} ) { - $item->{tip} = lc($1); - } else { - warn "MISSING : tip [$f200]\n"; - } - - $item->{title} = $f200; - - if ( exists $item->{991} ) { - my $file_id = $item->{991}->[0]; - if ( exists $files->{ $file_id } ) { - $item->{full_path} = delete $files->{ $file_id }; - } elsif ( $file_id =~ s/(\w)0*(\d)/$1$2/ ) { - if ( exists $files->{ $file_id } ) { - $item->{full_path} = delete $files->{ $file_id }; - } - } - } - - if ( ! exists $item->{full_path} ) { - my $file_id = ucfirst( $item->{300}->[0] . ' ' . $item->{700}->[0] ); - $file_id =~ s/[\.\,]//g; - if ( exists $files->{ $file_id } ) { - $item->{full_path} = delete $files->{ $file_id }; - } - } - - warn "MISSING file for $eprintid\n" unless exists $item->{full_path}; - - warn "# item ",dump($item); - - my $eprint = { - eprintid => $eprintid++ - }; - - $eprint->{filename} = $1 if $item->{full_path} =~ m{/([^/]+)$}; - $eprint->{full_path} = $item->{full_path}; - - $eprint->{date} = $1 if $item->{210}->[0] =~ m/\$d(\d+)/; - $eprint->{pages} = $1 if $item->{215}->[0] =~ m/^(\d+)/; - - ( $eprint->{creators_family}, $eprint->{creators_given} ) = split(/,\s*/, $item->{700}->[0] ); - - $eprint->{title} = $item->{title}; - - $eprint->{keywords} = join(", ", @{ $item->{610} }) if exists $item->{610}; - - if ( exists $item->{700}->[1] ) { - ( $eprint->{thesis_mentor_family}, $eprint->{thesis_mentor_given} ) = split(/,\s*/, $item->{700}->[1] ); - } elsif ( $item->{mentor} ) { - ( $eprint->{thesis_mentor_given}, $eprint->{thesis_mentor_family} ) = split(/\s+/, $item->{mentor} ); - } - - $eprint->{thesis_mentor_family} =~ s/(\S+)\s*-\s*(\S+)/$1-$2/; # fix spaces between dash in double surname - - $eprint->{thesis_callnumber} = $item->{990}->[0]; - $eprint->{thesis_invnumber} = $item->{991}->[0]; # FIXME? - - # fallback za radove bez datuma na godinu - if ( ! $eprint->{thesis_date} && $item->{990}->[0] =~ m{/(\d\d\d\d)/} ) { - $eprint->{thesis_date} = $1; - } - - if ( ! $eprint->{date} ) { - $eprint->{date} = $eprint->{thesis_date}; - } - - warn "# eprint ",dump($eprint); - - print qq| - - - $eprint->{eprintid} - - |; - - if ( $eprint->{full_path} ) { - print qq| - - - - - - - document - $eprint->{filename} - application/pdf - file://$eprint->{full_path} - - - application/pdf - application/pdf - hr - validuser -
$eprint->{filename}
-
-
- - |; - } - print qq| - - archive - $eprint->{type} - show - - - - $eprint->{creators_family} - $eprint->{creators_given} - - - - $eprint->{title} - unpub - - 2.06 - - restricted - $eprint->{keywords} - $eprint->{date} - completed - $eprint->{pages} - Grafički fakultet - - $eprint->{thesis_date} - $eprint->{thesis_callnumber} - $eprint->{thesis_invnumber} - - - $eprint->{thesis_mentor_family} - $eprint->{thesis_mentor_given} - - -
- - |; - -} - -print qq{ - -}; - open(my $tsv_fh, '<:encoding(UTF-8)', "$koha_path.tsv"); open(my $marc_fh, '<', "$koha_path.marc"); @@ -277,9 +108,7 @@ warn "## row = ",dump( \%row ); exit if $ENV{LAST} && $eprintid >= $ENV{LAST}; - my $item; - - if ( $item->{full_path} = $files->{$biblionumber} ) { + if ( delete $files->{$biblionumber} ) { $stat->{file}++; seek $marc_fh, $last_offset, 0; @@ -295,11 +124,6 @@ warn "## row = ",dump( \%row ); } -print qq{ - -}; - - warn "# files left ", dump($files); warn "# stat ", dump($stat);