|
8 | 8 | def epxml_to_datacite(eprint, customization=None): |
9 | 9 |
|
10 | 10 | print(eprint["type"]) |
11 | | - if eprint["type"] not in ["monograph", "teaching_resource"]: |
| 11 | + if eprint["type"] not in ["monograph", "teaching_resource", "conference_item"]: |
12 | 12 | raise Exception("This code has only been tested on tech reports") |
13 | 13 |
|
14 | 14 | metadata = {} |
@@ -95,6 +95,11 @@ def epxml_to_datacite(eprint, customization=None): |
95 | 95 | "resourceTypeGeneral": "Text", |
96 | 96 | "resourceType": "Teaching Resource", |
97 | 97 | } |
| 98 | + elif eprint["type"] == "conference_item": |
| 99 | + metadata["types"] = { |
| 100 | + "resourceTypeGeneral": "Text", |
| 101 | + "resourceType": "Conference Item", |
| 102 | + } |
98 | 103 | else: |
99 | 104 | metadata["types"] = { |
100 | 105 | "resourceTypeGeneral": "Text", |
@@ -135,30 +140,35 @@ def epxml_to_datacite(eprint, customization=None): |
135 | 140 | number = resolver[-1] |
136 | 141 | name_and_series = [eprint["local_group"]["item"][0], number] |
137 | 142 | 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] |
142 | 148 |
|
143 | 149 | # Add DOI to identifiers |
144 | 150 | if "doi" in eprint: |
145 | 151 | ids.append({"identifier": eprint["doi"], "identifierType": "DOI"}) |
| 152 | + # Add Eprints ID |
| 153 | + ids.append({"identifier": eprint["eprintid"], "identifierType": "Eprint_ID"}) |
146 | 154 |
|
147 | 155 | # Save Series Info, dependent on customization |
148 | 156 | if customization == "KISS": |
149 | 157 | metadata["publisher"] = "Keck Institute for Space Studies" |
150 | 158 | 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 |
162 | 172 |
|
163 | 173 | metadata["descriptions"] = description |
164 | 174 |
|
@@ -354,7 +364,9 @@ def epxml_to_datacite(eprint, customization=None): |
354 | 364 | repo_url = "http://authorstest.library.caltech.edu" |
355 | 365 | else: |
356 | 366 | d = DataCiteRESTClient( |
357 | | - username="CALTECH.LIBRARY", password=password, prefix="10.7907", |
| 367 | + username="CALTECH.LIBRARY", |
| 368 | + password=password, |
| 369 | + prefix="10.7907", |
358 | 370 | ) |
359 | 371 | repo_url = "https://authors.library.caltech.edu" |
360 | 372 |
|
|
0 commit comments