-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFR-2288 Querying by OCLC Number uses metadata API MARCXML endpoint #464
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ def __init__(self, source, namespace, constants): | |
super(CatalogMapping, self).__init__(source, namespace, constants) | ||
self.mapping = self.createMapping() | ||
|
||
def remove_oclc_prefixes(self, oclc_id): | ||
return oclc_id.removeprefix('(OCoLC)').removeprefix('on').removeprefix('ocn').removeprefix('ocm') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend pulling up prefixes into a set or list above as a constant, e.g. OCLC_PREFIXES = ['(OCoLC)', 'on', 'ocn', 'ocm']. That way we can just do:
In theory ha There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated! |
||
|
||
def createMapping(self): | ||
return { | ||
'title': ('//oclc:datafield[@tag=\'245\']/oclc:subfield[@code=\'a\' or @code=\'b\']/text()', '{0} {1}'), | ||
|
@@ -158,12 +161,13 @@ def createMapping(self): | |
|
||
def applyFormatting(self): | ||
self.record.source = 'oclcCatalog' | ||
self.record.identifiers[0] = self.remove_oclc_prefixes(self.record.identifiers[0]) | ||
self.record.source_id = self.record.identifiers[0] | ||
self.record.frbr_status = 'complete' | ||
|
||
_, _, lang_3, *_ = tuple(self.record.languages[0].split('|')) | ||
self.record.languages = [('||{}'.format(lang_3[35:38]))] | ||
|
||
self.record.has_part = self.record.has_part[:10] | ||
|
||
self.record.has_part = list(filter(None, [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!