Create or extend the 040 according to MARC spec (040 = NR)
authordbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Thu, 25 Nov 2010 15:59:19 +0000 (15:59 +0000)
committerdbs <dbs@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Thu, 25 Nov 2010 15:59:19 +0000 (15:59 +0000)
Also, don't identify OWA as a modifying source if they're not
part of the batch load.

git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/branches/rel_1_6_1@1087 6d9bc8c9-1ec2-4278-b937-99fde70a366f

tools/ebooks/prep_ebook_records.py

index 7f630cb..b986005 100644 (file)
@@ -245,13 +245,29 @@ def process_records(options):
             )
             new_record.add_field(note)
 
+        add_cat_source(new_record, options)
+
+        writer.write(new_record)
+
+def add_cat_source(record, options):
+    """Add or extend the 040 field to identify the cataloguing source"""
+
+    # Only Windsor wants to do this
+    if 'windsor' not in options['libraries']:
+        return
+
+    cat_source = record['040']
+    if cat_source:
+        # Add subfield 'd' identifying Windsor
+        cat_source.add_subfield('d', 'CaOWA')
+    else:
+        # Add a 040 with subfield 'd' identifying Windsor
         forty = pymarc.Field(tag = '040',
             indicators = [' ', ' '],
-            subfields = [ 'a', 'CaOWA' ]
+            subfields = [ 'd', 'CaOWA' ]
         )
-        new_record.add_field(forty)
+        record.add_field(forty)
 
-        writer.write(new_record)
 
 def process_urls(field, options):
     """Creates 856 fields required by Conifer"""