Skip to content

Commit

Permalink
reduce subfields and repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
hornc committed Mar 16, 2023
1 parent 2c3802c commit f8878e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion openlibrary/catalog/marc/marc_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def read_fields(self, want=None):

def get_linkage(self, original, link):
"""
:param original str: The original field .e.g. '245'
:param original str: The original field e.g. '245'
:param link str: The linkage {original}$6 value e.g. '880-01'
:rtype: BinaryDataField
:return: alternate script field (880) corresponding to original
Expand Down
5 changes: 2 additions & 3 deletions openlibrary/catalog/marc/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,11 @@ def read_title(rec):
# For cataloging punctuation complexities, see https://www.oclc.org/bibformats/en/onlinecataloging.html#punctuation
STRIP_CHARS = r' /,;:=' # Typical trailing punctuation for 245 subfields in ISBD cataloging standards
fields = rec.get_fields('245') or rec.get_fields('740')

if not fields:
raise NoTitle('No Title found in either 245 or 740 fields.')
# example MARC record with multiple titles:
# https://openlibrary.org/show-marc/marc_western_washington_univ/wwu_bibs.mrc_revrev.mrc:299505697:862
contents = fields[0].get_contents(['a', 'b', 'c', 'h', 'n', 'p', 's'])
contents = fields[0].get_contents(['a', 'c', 'h'])
linkages = fields[0].get_contents(['6'])
bnps = [i for i in fields[0].get_subfield_values(['b', 'n', 'p', 's']) if i]
ret = {}
Expand All @@ -251,7 +250,7 @@ def read_title(rec):
title = remove_trailing_dot(title)
if '6' in linkages:
ret['other_titles'] = [title]
alternate = rec.get_linkage('245', linkages['6'][0]).get_contents(['a', 'b', 'c', 'h', 'n', 'p', 's'])
alternate = rec.get_linkage('245', linkages['6'][0]).get_contents(['a'])
title = ' '.join(x.strip(STRIP_CHARS) for x in alternate['a'])
ret['title'] = remove_trailing_dot(title)
else:
Expand Down

0 comments on commit f8878e4

Please sign in to comment.