File tree 1 file changed +47
-0
lines changed 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ import sys ,os ,csv ,json
2
+ import requests
3
+ from irdm import eprint2rdm
4
+ from caltechdata_api import caltechdata_edit
5
+ from ames .harvesters import get_series_records
6
+
7
+
8
+ token = os .environ ["CTATOK" ]
9
+
10
+ group = sys .argv [1 ]
11
+ to_update = get_series_records (group , token = token )
12
+ print (len (to_update ))
13
+
14
+ completed = []
15
+ infile = open ('completed.csv' ,'r' )
16
+ reader = csv .reader (infile )
17
+ for row in reader :
18
+ completed .append (row [0 ])
19
+
20
+ for record in to_update :
21
+ rdmid = record ['id' ]
22
+ if rdmid not in completed :
23
+ for identifier in record ['metadata' ]['identifiers' ]:
24
+ if identifier ['scheme' ] == 'eprintid' :
25
+ eprintid = identifier ['identifier' ]
26
+ print (eprintid )
27
+ eprint_data = eprint2rdm (eprintid )[0 ]['metadata' ]
28
+ pub_date = None
29
+ for dates in eprint_data ['dates' ]:
30
+ if dates ['type' ]['id' ] == 'completed' :
31
+ pub_date = dates ['date' ]
32
+ if pub_date :
33
+ record ['metadata' ]['publication_date' ] = pub_date
34
+ else :
35
+ print (f"Missing pub date for { eprintid } " )
36
+ exit ()
37
+ record ['metadata' ]['resource_type' ] = {'id' :'publication-technicalnote' }
38
+ caltechdata_edit (
39
+ rdmid ,
40
+ metadata = record ,
41
+ token = token ,
42
+ production = True ,
43
+ publish = True ,
44
+ authors = True ,
45
+ )
46
+ outfile = open ('completed.csv' ,'a' )
47
+ outfile .write (rdmid + '\n ' )
You can’t perform that action at this time.
0 commit comments