Be more consistent when applying the period to 710 $a
authorDan Scott <dan@coffeecode.net>
Thu, 11 Aug 2011 15:38:42 +0000 (11:38 -0400)
committerDan Scott <dscott@laurentian.ca>
Tue, 7 May 2013 18:37:15 +0000 (14:37 -0400)
Signed-off-by: Dan Scott <dscott@laurentian.ca>
tools/ebooks/prep_ebook_records.py

index ca05f49..aba1d21 100644 (file)
@@ -205,7 +205,8 @@ def check_options(options):
         sys.exit(0)
 
     clean_opts = dict()
-    clean_opts['publisher'] = options['--publisher']
+    clean_opts['publisher'] = append_period(options['--publisher'])
+
     clean_opts['consortium'] = options['--consortium']
     clean_opts['authorization'] = options['--authorization']
 
@@ -216,7 +217,7 @@ def check_options(options):
         clean_opts['note'] = options['--note']
 
     if '--platform' in options:
-        clean_opts['platform'] = options['--platform']
+        clean_opts['platform'] = append_period(options['--platform'])
 
     clean_opts['libraries'] = _libraries
     clean_opts['input'] = _input
@@ -225,6 +226,16 @@ def check_options(options):
 
     return clean_opts
 
+def append_period(text):
+    """
+    Append a period to the incoming text if required
+    """
+
+    if text[-1] != '.':
+        text += '.'
+
+    return text
+
 def check_libraries(options):
     """Build a dict of the libraries that were requested for this batch"""
     
@@ -452,6 +463,7 @@ def add_publisher(record, options):
     """
 
     publisher = options['publisher']
+
     munge_publisher = False
     need_publisher = True
     need_relator = True
@@ -471,7 +483,7 @@ def add_publisher(record, options):
     # Iterate through all of the existing 710 fields
     for sten in record.get_fields('710'):
         for pub in sten.get_subfields('a'):
-            if pub == publisher or (pub == publisher + '.'):
+            if pub == publisher:
                 munge_publisher = True
                 for rel in sten.get_subfields('4'): 
                     if rel == 'pbl':
@@ -482,10 +494,6 @@ def add_publisher(record, options):
                     sten.add_subfield('4', 'pbl')
                     need_publisher = False
 
-    # Append a period to the publisher name
-    if publisher[-1] != '.':
-        publisher += '.'
-
     if need_publisher:
         # Add the publisher, with relator code
         seven_ten = pymarc.Field(tag = '710',
@@ -517,10 +525,6 @@ def add_platform(record, options):
             if pub == platform or (pub == platform + '.'):
                 need_platform = False
 
-    # Append a period to the publisher name
-    if platform[-1] != '.':
-        platform += '.'
-
     if need_platform:
         # Add the platform
         seven_ten = pymarc.Field(tag = '710',