Add 598 field to track MARC file source
authorDan Scott <dan@coffeecode.net>
Thu, 14 Jul 2011 21:27:02 +0000 (17:27 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:36:20 +0000 (14:36 -0400)
Also shift 506 institutional code to subfield 9 despite the MARC
standard suggesting that it should be in subfield 5.

Also add semicolons to the 506 fields for better display. Still
need to add spaces, though.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/ebooks/prep_ebook_records.py

index af6fbec..2bf9d1c 100644 (file)
@@ -14,6 +14,7 @@ be accommodated in batch load.
 """
 
 import os, os.path, sys, getopt, pymarc, pymarc.marc8, re, urllib2
+from datetime import date
 from BeautifulSoup import BeautifulSoup
 
 class Institution():
@@ -27,7 +28,7 @@ class Institution():
             "proxy": "http://libproxy.auc.ca/login?url=", \
             "link_text": "Available online", \
             "sfx_url": "http://sfx.scholarsportal.info/algoma", \
-            "access_note": "Access restricted to users with a valid Algoma University ID" \
+            "access_note": "Access restricted to users with a valid Algoma University ID ;" \
         }
         
         self.laurentian = { \
@@ -36,7 +37,7 @@ class Institution():
             "proxy": "https://librweb.laurentian.ca/login?url=", \
             "link_text": "Available online / disponible en ligne", \
             "sfx_url": "http://sfx.scholarsportal.info/laurentian", \
-            "access_note": "Access restricted to users with a valid Laurentian University ID" \
+            "access_note": "Access restricted to users with a valid Laurentian University ID ;" \
         }
 
         self.windsor = { \
@@ -45,7 +46,7 @@ class Institution():
             "proxy": "http://ezproxy.uwindsor.ca/login?url=", \
             "link_text": "Available online", \
             "sfx_url": "http://sfx.scholarsportal.info/windsor", \
-            "access_note": "Access restricted to users with a valid University of Windsor ID" \
+            "access_note": "Access restricted to users with a valid University of Windsor ID ;" \
         }
 
     def get_settings(self, lib):
@@ -312,6 +313,7 @@ def process_fields(record, options):
         new_record.add_field(note)
 
     add_cat_source(new_record, options)
+    add_marc_source(new_record, options)
 
     return new_record
 
@@ -416,7 +418,7 @@ def clean_isbn(isbn):
         return None
      
     # Replace hyphens
-    isbn = isbn_match.group(1).replace('-', '');
+    isbn = isbn_match.group(1).replace('-', '')
 
     return isbn
 
@@ -428,7 +430,7 @@ def add_restriction(new_record, options):
       * $a - Standard text to display
       * $b - Jurisdiction (identifies the consortial license)
       * $e - Authorization (online platform that enforces authorization) 
-      * $5 - Institutional code to which this note applies
+      * $9 - Institutional code to which this note applies
     """
 
     for library in options['libraries']:
@@ -440,7 +442,7 @@ def add_restriction(new_record, options):
                 'a', libopts['access_note'],
                 'b', options['consortium'],
                 'e', options['authorization'],
-                '5', libopts['code']
+                '9', libopts['code']
             ]
         )
         new_record.add_field(note)
@@ -464,6 +466,21 @@ def add_cat_source(record, options):
         )
         record.add_field(forty)
 
+def add_marc_source(record, options):
+    """
+    Add a 598 field identifying the source MARC file name and processing date
+    """
+
+    source = os.path.basename(options['input'])
+
+    marc_source = pymarc.Field(tag = '598',
+        indicators = [' ', ' '],
+        subfields = [
+            'a', source,
+            'b', date.today().isoformat()
+        ]
+    )
+    record.add_field(marc_source)
 
 def process_urls(field, options):
     """Creates 856 fields required by Conifer"""