forked from caltechlibrary/caltechdata_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite_authors.py
37 lines (31 loc) · 890 Bytes
/
write_authors.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import argparse, os, json
from caltechdata_api import caltechdata_write
parser = argparse.ArgumentParser(
description="Write files and a DataCite 4 standard json record\
to CaltechDATA repository"
)
parser.add_argument(
"json_file", nargs=1, help="file name for json DataCite metadata file"
)
parser.add_argument("-fnames", nargs="*", help="New Files")
parser.add_argument("-schema", default="43", help="Metadata Schema")
args = parser.parse_args()
# Get access token as environment variable
token = os.environ["RDMTOK"]
metaf = open(args.json_file[0], "r")
metadata = json.load(metaf)
production = True
publish = False
authors = True
community = "669e5e57-7d9e-4d19-8ab5-9c6158562fb3"
response = caltechdata_write(
metadata,
token,
args.fnames,
production,
args.schema,
publish,
community=community,
authors=authors,
)
print(response)