forked from caltechlibrary/caltechdata_api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite.py
28 lines (22 loc) · 757 Bytes
/
write.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
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 = False
publish = True
response = caltechdata_write(
metadata, token, args.fnames, production, args.schema, publish
)
print(response)