Skip to content

Commit

Permalink
Use list comprehension for holdings list
Browse files Browse the repository at this point in the history
  • Loading branch information
tijmenbaarda committed Dec 23, 2024
1 parent d34f9a4 commit 4ad8f6b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions edpop_explorer/readers/stcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ def _wrap_contributor(actor_data: dict) -> ContributorField:
return field


def _wrap_holding(holding_data: dict) -> Field:
institution = safeget(holding_data, ("data", "institutionName"))
shelfmark = safeget(holding_data, ("data", "shelfmark"))
summary = f"{institution} - {shelfmark}"
return Field(summary)


class STCNBaseReader(CERLReader):
"""STCN uses the same search API for its bibliographical records and
its biographical records (persons and publishers/printers), but the
Expand Down Expand Up @@ -218,13 +225,7 @@ def _get_holdings(cls, rawrecord: dict) -> List[Field]:
holdings = safeget(rawrecord, ("data", "holdings"))
if holdings is None:
return []
fields = []
for holding in holdings:
institution = safeget(holding, ("data", "institutionName"))
shelfmark = safeget(holding, ("data", "shelfmark"))
summary = f"{institution} - {shelfmark}"
fields.append(Field(summary))
return fields
return [_wrap_holding(x) for x in holdings]

@classmethod
def _convert_record(cls, rawrecord: dict) -> BibliographicalRecord:
Expand Down

0 comments on commit 4ad8f6b

Please sign in to comment.