Skip to content

Commit e9b11ac

Browse files
committed
Initial authors version
1 parent 6121411 commit e9b11ac

File tree

3 files changed

+149
-4
lines changed

3 files changed

+149
-4
lines changed

caltechdata_api/caltechdata_write.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def caltechdata_write(
124124
file_links=[],
125125
s3=None,
126126
community=None,
127+
authors=False
127128
):
128129
"""
129130
File links are links to files existing in external systems that will
@@ -172,11 +173,18 @@ def caltechdata_write(
172173
}
173174
metadata["pids"] = pids
174175

175-
data = customize_schema.customize_schema(copy.deepcopy(metadata), schema=schema)
176-
if production == True:
177-
url = "https://data.caltech.edu/"
176+
if authors == False:
177+
data = customize_schema.customize_schema(copy.deepcopy(metadata), schema=schema)
178+
if production == True:
179+
url = "https://data.caltech.edu/"
180+
else:
181+
url = "https://data.caltechlibrary.dev/"
178182
else:
179-
url = "https://data.caltechlibrary.dev/"
183+
data = metadata
184+
if production == True:
185+
url = "https://authors.caltech.edu/"
186+
else:
187+
url = "https://authors.caltechlibrary.dev/"
180188

181189
headers = {
182190
"Authorization": "Bearer %s" % token,

rdm.json

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
{
2+
"pids": {
3+
"doi": {
4+
"identifier": "10.5281/inveniordm.1234",
5+
"provider": "datacite",
6+
"client": "inveniordm"
7+
}
8+
},
9+
"metadata": {
10+
"resource_type": {"id": "image-photo"},
11+
"creators": [
12+
{
13+
"person_or_org": {
14+
"name": "Nielsen, Lars Holm",
15+
"type": "personal",
16+
"given_name": "Lars Holm",
17+
"family_name": "Nielsen",
18+
"identifiers": [
19+
{"scheme": "orcid", "identifier": "0000-0001-8135-3489"}
20+
]
21+
},
22+
"affiliations": [{"name": "free-text"}]
23+
}
24+
],
25+
"title": "InvenioRDM",
26+
"additional_titles": [
27+
{
28+
"title": "a research data management platform",
29+
"type": {"id": "subtitle"},
30+
"lang": {"id": "eng"}
31+
}
32+
],
33+
"publisher": "InvenioRDM",
34+
"publication_date": "2018/2020-09",
35+
"subjects": [
36+
{"subject": "custom"}
37+
],
38+
"contributors": [
39+
{
40+
"person_or_org": {
41+
"name": "Nielsen, Lars Holm",
42+
"type": "personal",
43+
"given_name": "Lars Holm",
44+
"family_name": "Nielsen",
45+
"identifiers": [
46+
{"scheme": "orcid", "identifier": "0000-0001-8135-3489"}
47+
]
48+
},
49+
"role": {"id": "other"}
50+
}
51+
],
52+
"dates": [
53+
{"date": "1939/1945", "type": {"id": "other"}, "description": "A date"}
54+
],
55+
"languages": [{"id": "dan"}, {"id": "eng"}],
56+
"identifiers": [{"identifier": "1924MNRAS..84..308E", "scheme": "bibcode"}],
57+
"related_identifiers": [
58+
{
59+
"identifier": "10.1234/foo.bar",
60+
"scheme": "doi",
61+
"relation_type": {"id": "iscitedby"},
62+
"resource_type": {"id": "dataset"}
63+
}
64+
],
65+
"sizes": ["11 pages"],
66+
"formats": ["application/pdf"],
67+
"version": "v1.0",
68+
"rights": [
69+
{
70+
"title": {"en": "A custom license"},
71+
"description": {"en": "A description"},
72+
"link": "https://customlicense.org/licenses/by/4.0/"
73+
},
74+
{"id": "cc-by-4.0"}
75+
],
76+
"description": "<h1>A description</h1> <p>with HTML tags</p>",
77+
"additional_descriptions": [
78+
{
79+
"description": "Bla bla bla",
80+
"type": {"id": "methods"},
81+
"lang": {"id": "eng"}
82+
}
83+
],
84+
"locations": {
85+
"features": [
86+
{
87+
"geometry": {
88+
"type": "Point",
89+
"coordinates": [-32.94682, -60.63932]
90+
},
91+
"place": "test location place",
92+
"description": "test location description",
93+
"identifiers": [
94+
{"identifier": "12345abcde", "scheme": "wikidata"},
95+
{"identifier": "12345abcde", "scheme": "geonames"}
96+
]
97+
}
98+
]
99+
},
100+
"references": [
101+
{
102+
"reference": "Nielsen et al,..",
103+
"identifier": "0000 0001 1456 7559",
104+
"scheme": "isni"
105+
}
106+
]
107+
}
108+
}

write_authors.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import argparse, os, json
2+
from caltechdata_api import caltechdata_write
3+
4+
parser = argparse.ArgumentParser(
5+
description="Write files and a DataCite 4 standard json record\
6+
to CaltechDATA repository"
7+
)
8+
parser.add_argument(
9+
"json_file", nargs=1, help="file name for json DataCite metadata file"
10+
)
11+
parser.add_argument("-fnames", nargs="*", help="New Files")
12+
parser.add_argument("-schema", default="43", help="Metadata Schema")
13+
14+
args = parser.parse_args()
15+
16+
# Get access token as environment variable
17+
token = os.environ["RDMTOK"]
18+
19+
metaf = open(args.json_file[0], "r")
20+
metadata = json.load(metaf)
21+
22+
production = False
23+
publish = True
24+
authors = True
25+
26+
response = caltechdata_write(
27+
metadata, token, args.fnames, production, args.schema, publish, authors=authors
28+
)
29+
print(response)

0 commit comments

Comments
 (0)