Skip to content

Commit 9a80ce5

Browse files
committed
Add id return option to caltechdata_edit
1 parent c1b4ab5 commit 9a80ce5

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

caltechdata_api/caltechdata_edit.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def caltechdata_edit(
6666
default_preview=None,
6767
authors=False,
6868
keepfiles=False,
69+
return_id=False,
6970
):
7071
# Make a copy of the metadata to make sure our local changes don't leak
7172
metadata = copy.deepcopy(metadata)
@@ -299,10 +300,13 @@ def caltechdata_edit(
299300
result = requests.post(publish_link, headers=headers)
300301
if result.status_code != 202:
301302
raise Exception(result.text)
302-
pids = result.json()["pids"]
303-
if "doi" in pids:
304-
return pids["doi"]["identifier"]
303+
if return_id:
304+
return result.json()["id"]
305305
else:
306-
return pids["oai"]["identifier"]
306+
pids = result.json()["pids"]
307+
if "doi" in pids:
308+
return pids["doi"]["identifier"]
309+
else:
310+
return pids["oai"]["identifier"]
307311
else:
308312
return idv

0 commit comments

Comments
 (0)