Skip to content

Commit 9c6afa7

Browse files
committed
Add conference item type and reorganize identifiers
1 parent 988752d commit 9c6afa7

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

caltech_authors_tech_report.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
def epxml_to_datacite(eprint, customization=None):
99

1010
print(eprint["type"])
11-
if eprint["type"] not in ["monograph", "teaching_resource"]:
11+
if eprint["type"] not in ["monograph", "teaching_resource", "conference_item"]:
1212
raise Exception("This code has only been tested on tech reports")
1313

1414
metadata = {}
@@ -95,6 +95,11 @@ def epxml_to_datacite(eprint, customization=None):
9595
"resourceTypeGeneral": "Text",
9696
"resourceType": "Teaching Resource",
9797
}
98+
elif eprint["type"] == "conference_item":
99+
metadata["types"] = {
100+
"resourceTypeGeneral": "Text",
101+
"resourceType": "Conference Item",
102+
}
98103
else:
99104
metadata["types"] = {
100105
"resourceTypeGeneral": "Text",
@@ -135,30 +140,35 @@ def epxml_to_datacite(eprint, customization=None):
135140
number = resolver[-1]
136141
name_and_series = [eprint["local_group"]["item"][0], number]
137142
else:
138-
resolver = eprint["official_url"].split(":")
139-
name = resolver[1].split("/")[-1]
140-
number = resolver[-1]
141-
name_and_series = [name, number]
143+
if eprint["type"] == "monograph":
144+
resolver = eprint["official_url"].split(":")
145+
name = resolver[1].split("/")[-1]
146+
number = resolver[-1]
147+
name_and_series = [name, number]
142148

143149
# Add DOI to identifiers
144150
if "doi" in eprint:
145151
ids.append({"identifier": eprint["doi"], "identifierType": "DOI"})
152+
# Add Eprints ID
153+
ids.append({"identifier": eprint["eprintid"], "identifierType": "Eprint_ID"})
146154

147155
# Save Series Info, dependent on customization
148156
if customization == "KISS":
149157
metadata["publisher"] = "Keck Institute for Space Studies"
150158
else:
151-
description += [
152-
{
153-
"descriptionType": "SeriesInformation",
154-
"description": name_and_series[0] + " " + name_and_series[1],
155-
}
156-
]
157-
ids.append(
158-
{"identifier": name_and_series[1], "identifierType": name_and_series[0]}
159-
)
160-
if ids != []:
161-
metadata["identifiers"] = ids
159+
if eprint["type"] == "monograph":
160+
description += [
161+
{
162+
"descriptionType": "SeriesInformation",
163+
"description": name_and_series[0] + " " + name_and_series[1],
164+
}
165+
]
166+
ids.append(
167+
{"identifier": name_and_series[1], "identifierType": name_and_series[0]}
168+
)
169+
170+
# At a minimum, we always have an Eprints ID
171+
metadata["identifiers"] = ids
162172

163173
metadata["descriptions"] = description
164174

@@ -354,7 +364,9 @@ def epxml_to_datacite(eprint, customization=None):
354364
repo_url = "http://authorstest.library.caltech.edu"
355365
else:
356366
d = DataCiteRESTClient(
357-
username="CALTECH.LIBRARY", password=password, prefix="10.7907",
367+
username="CALTECH.LIBRARY",
368+
password=password,
369+
prefix="10.7907",
358370
)
359371
repo_url = "https://authors.library.caltech.edu"
360372

0 commit comments

Comments
 (0)