Merge branch 'master' of git://git.sitka.bclibraries.ca/sitka/sitka-tools
authorroot <root@app3-2.sitka.bclibraries.ca>
Fri, 7 Oct 2011 20:58:41 +0000 (13:58 -0700)
committerroot <root@app3-2.sitka.bclibraries.ca>
Fri, 7 Oct 2011 20:58:41 +0000 (13:58 -0700)
1  2 
marc_export_custom/marc_export_custom

@@@ -49,10 -49,7 +49,10 @@@ GetOptions
        'output-file=s' => \$output_file,
  );
  
 -$cfg = new Config::Simple($exclusion_ini) if ($exclusion_ini);
 +if ($exclusion_ini) {
 +      die "exclusion ini file does not exist" unless (-r $exclusion_ini and -s $exclusion_ini);
 +      $cfg = new Config::Simple($exclusion_ini) 
 +}
  
  if ($help) {
  print <<"HELP";
@@@ -244,6 -241,18 +244,18 @@@ sub export_record 
              add_bib_holdings($bib, $r);
          }
  
+         if($force901){
+             $r->delete_field( $r->field('901') );
+             $r->append_fields(
+                 MARC::Field->new(
+                     '901', ' ', ' ',
+                     a => $bib->tcn_value,
+                     b => $bib->tcn_source,
+                     c => $bib->id
+                 )
+             );
+         }
          if ($format eq 'XML') {
              my $xml = $r->as_xml_record;
              $xml =~ s/^<\?.+?\?>$//mo;
              try {
                  my $r = MARC::Record->new_from_xml( $mfhd->marc, $encoding, $format );
  
+                 if($force901){
+                     $r->delete_field( $r->field('901') );
+                     $r->append_fields(
+                         MARC::Field->new(
+                             '901', ' ', ' ',
+                             a => $bib->tcn_value,
+                             b => $bib->tcn_source,
+                             c => $bib->id
+                         )
+                     );
+                 }
                  if ($format eq 'XML') {
                      my $xml = $r->as_xml_record;
                      $xml =~ s/^<\?.+?\?>$//mo;
@@@ -557,18 -578,7 +581,7 @@@ sub add_bib_holdings 
                          )
                      );
  
-                     if($force901){
-                         $r->delete_field( $r->field('901') );
-                         $r->append_fields(
-                             MARC::Field->new(
-                                 '901', ' ', ' ',
-                                 a => $bib->tcn_value,
-                                 b => $bib->tcn_source,
-                                 c => $bib->id
-                             )
-                         );
  
-                     }
  
                      stats() if (! ($count{cp} % 100 ));
                  } # for cnmap
  } # sub
  
  sub skipnote { 
 -      printf(STDOUT "Skipped %s due to config: %s\n",$1,$2); 
 +      my $id = shift;
 +      my $note = shift;
 +      my $outf = *STDERR;
 +      $outf = *STDOUT if($output_file) ;
 +      printf($outf "Skipped %s due to config: %s\n",$id,$note); 
  }