File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 33import requests
44from datacite import schema43 , DataCiteRESTClient
55from caltechdata_api import caltechdata_write , caltechdata_edit
6+ from tqdm import tqdm
67
78folder = "0_gregoire"
89
5960for doi in excluded :
6061 records .remove (doi )
6162
62- for record in records :
63+ for record in tqdm ( records ) :
6364 base = record .split ("/" )[1 ]
6465 meta_path = path + base + "/metadata.json"
6566 metadata = None
195196 s3 = s3 ,
196197 community = community ,
197198 )
198- print (new_id )
199199 url = f"https://data.caltech.edu/records/{ new_id } "
200200
201201 # record_ids[old_id] = new_id
202202 # with open("new_ids.json", "w") as outfile:
203203 # json.dump(record_ids, outfile)
204-
205- doi = datacite .update_doi (doi = record , metadata = metadata , url = url )["doi" ]
204+
205+ result = requests .get (f'https://api.datacite.org/dois/{ doi } ' )
206+ if result .status_code != 200 :
207+ doi = datacite .public_doi (doi = record , metadata = metadata , url = url )
208+ else :
209+ doi = datacite .update_doi (doi = record , metadata = metadata , url = url )["doi" ]
206210 completed .append (doi )
207211 with open ("completed_dois.json" , "w" ) as outfile :
208212 data = json .dump (completed , outfile )
209213
210- exit ()
You can’t perform that action at this time.
0 commit comments