bugfixes and improvements: skip MARC databases that can't be opened,
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 27 Jan 2005 20:23:36 +0000 (20:23 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 27 Jan 2005 20:23:36 +0000 (20:23 +0000)
fix progress bar on MARC databases (so that it finish on 100%),
minor pod update

git-svn-id: file:///home/dpavlin/private/svn/webpac/trunk@650 13eb9ef6-21d5-0310-b721-a9d68796d827

all2xml.pl

index 94a5f06..ae244dd 100755 (executable)
@@ -741,7 +741,7 @@ print STDERR "using: $type...\n";
                my $max_rowid = $db->count;
 
                if (! $max_rowid) {
-                       print STDERR "FATAL: can't read database: $isis_db, skipping...\n";
+                       print STDERR "FATAL: can't read ISIS database: $isis_db, skipping...\n";
                        next;
                }
 
@@ -841,13 +841,17 @@ print STDERR "using: $type...\n";
                warn "marc_format is no longer used!" if ($config->{marc_format});
                print STDERR "Reading MARC file '$marc_file'\n";
 
-               my $marc = MARC::File::USMARC->in( $marc_file )
-                       || die "Can't open MARC file '$marc_file': ".$MARC::File::ERROR;
+               my $marc = MARC::File::USMARC->in( $marc_file );
+
+               if (! $marc) {
+                       print STDERR "FATAL: can't read MARC file: $marc_file, skipping...\n";
+                       next;
+               }
 
                # count records in MARC file
                sub marc_count {
                        my $filename = shift || die;
-                       my $file = MARC::File::USMARC->in($filename) || die $MARC::File::ERROR;
+                       my $file = MARC::File::USMARC->in($filename) || return;
                        my $count = 0;
                        while ($file->skip()) {
                                $count++;
@@ -857,11 +861,11 @@ print STDERR "using: $type...\n";
 
                my $count = marc_count($marc_file) || warn "no records in '$marc_file'?";
 
-               my $i = 0;
+               my $i = 1;
 
                while( my $rec = $marc->next() ) {
 
-                       progress($i++,$count);
+                       progress($i,$count);
 
                        my $swishpath = $database."#".$i;
 
@@ -872,6 +876,8 @@ print STDERR "using: $type...\n";
                                print "Content-Length: ".(length($xml)+1)."\n";
                                print "Document-Type: XML\n\n$xml\n";
                        }
+
+                       $i++;
                }
 
                print STDERR "\n";
@@ -936,8 +942,8 @@ all2xml.pl - read various file formats and dump XML for SWISH-E
 
 =head1 DESCRIPTION
 
-This command will read ISIS data file using IsisDB perl module, MARC
-records using MARC module and optionally Micro$oft Excel files to
+This command will read ISIS data file using Biblio::Isis perl module, MARC
+records using MARC::File module and optionally Micro$oft Excel files to
 create one XML file for usage with I<SWISH-E> indexer. Dispite it's name,
 this script B<isn't general xml generator> from isis files (isis allready
 has something like that). Output of this script is tailor-made for SWISH-E.