new_record = pymarc.Record(to_unicode=True, force_utf8=True)
add_cat_source(record, options) # 040
- add_restriction(record, options) # 506
# 590
if 'note' in options:
add_marc_source(record, options) # 598
publisher = add_publisher(record, options) # 710
+ add_restriction(record, options, publisher) # 506
add_platform(record, options) # 710
marked_isbn = mark_isbn_for_sfx(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:
+ if pub == publisher or (pub == publisher + '.'):
munge_publisher = True
for rel in sten.get_subfields('4'):
if rel == 'pbl':
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',
# Iterate through all of the existing 710 fields
for sten in record.get_fields('710'):
for pub in sten.get_subfields('a'):
- if pub == platform:
+ 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',
return isbn
-def add_restriction(new_record, options):
+def add_restriction(new_record, options, publisher):
"""
Adds a 506 access restriction note per institution
authnote += '.'
for library in options['libraries']:
+
+ # Skip auth note if Algoma + CUP
+ if library == 'algoma' and 'Cambridge' in publisher:
+ continue
+
libopts = options['settings'].get_settings(library)
# Add the access restriction note
note = pymarc.Field(tag = '506',
indicators = ['1', ' '],
subfields = [
- 'a', libopts['access_note'],
- 'b', options['consortium'] + ' ; ',
+ 'a', append_space_semi_space(libopts['access_note']),
+ 'b', append_space_semi_space(options['consortium']),
'e', authnote,
'9', libopts['code']
]
)
new_record.add_field(note)
+def append_space_semi_space(note):
+ """
+ Try to ensure the given text ends with ' ; '
+ """
+
+ if note[-3:] == ' ; ':
+ pass
+ elif note[-1] == ';':
+ note += ' '
+ elif note[-1] == ' ':
+ note += '; '
+
+ return note
+
def add_cat_source(record, options):
"""Add or extend the 040 field to identify the cataloguing source"""