Skip to content

Commit

Permalink
feat: publisher for DBR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
phette23 committed Feb 7, 2024
1 parent a5592aa commit 2a3849a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
27 changes: 21 additions & 6 deletions migrate/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,27 +281,42 @@ def dates(self) -> list[dict[str, Any]]:
@property
def publisher(self) -> str:
# https://inveniordm.docs.cern.ch/reference/metadata/#publisher-0-1
publisher = ""

# 1) DBR articles have a variable publisher depending on date:
# Winter 1983 - Spring 1990: Design Book Review
# Winter 1991 - Winter/Spring 1995: MIT Press
# Winter 1996/1997: Design Book Review
# 1997 - on: California College of the Arts
# https://vault.cca.edu/items/bd3b483b-52b9-423c-a96e-d37863511d75/1/%3CXML%3E
# mods/relatedItem[@type="host"]/titleInfo/title == DBR
# ri = self.xml.get("mods", {}).get("relatedItem", {})
related_item = self.xml.get("mods", {}).get("relatedItem", {})
related_title_infos = mklist(related_item.get("titleInfo"))
for ti in related_title_infos:
if ti.get("title") == "Design Book Review":
issue = related_item.get("part", {}).get("detail", {}).get("number")
if issue:
# there are some double issues with numbers like 37/38
issue = int(issue[:2])
if issue < 19:
return "Design Book Review"
elif issue < 36:
return "MIT Press"
elif issue < 39:
return "Design Book Review"
else:
return "California College of the Arts"

# 2) CCA/C archives has publisher info mods/originInfo/publisher
# https://vault.cca.edu/items/c4583fe6-2e85-4613-a1bc-774824b3e826/1/%3CXML%3E
oipub = (
publisher = (
self.xml.get("mods", {}).get("originInfo", {}).get("publisher", "")
).strip()
if oipub:
publisher = oipub
if publisher:
return publisher

# 3) Press Clips items are not CCA but have only publication, not publisher, info
# 4) Student work has no publisher
return publisher
return ""

@property
def type(self) -> dict[str, str]:
Expand Down
25 changes: 25 additions & 0 deletions migrate/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,31 @@ def test_type(input, expect):
x("<mods></mods>"),
"",
),
# various DBR publishers depending on issue
(
x(
"<mods><relatedItem type='host'><titleInfo><title>Design Book Review</title></titleInfo><part><detail type='number'><number>12</number></detail></part></relatedItem></mods>"
),
"Design Book Review",
),
(
x(
"<mods><relatedItem type='host'><titleInfo><title>Design Book Review</title></titleInfo><part><detail type='number'><number>29/30</number></detail></part></relatedItem></mods>"
),
"MIT Press",
),
(
x(
"<mods><relatedItem type='host'><titleInfo><title>Design Book Review</title></titleInfo><part><detail type='number'><number>37/38</number></detail></part></relatedItem></mods>"
),
"Design Book Review",
),
(
x(
"<mods><relatedItem type='host'><titleInfo><title>Design Book Review</title></titleInfo><part><detail type='number'><number>43</number></detail></part></relatedItem></mods>"
),
"California College of the Arts",
),
],
)
def test_publisher(input, expect):
Expand Down

0 comments on commit 2a3849a

Please sign in to comment.