caltechdata-api 1.8.1__tar.gz → 1.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/PKG-INFO +1 -1
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/cli.py +5 -2
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/customize_schema.py +1 -2
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/get_metadata.py +29 -8
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/PKG-INFO +1 -1
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/LICENSE +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/README.md +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/__init__.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/caltechdata_edit.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/caltechdata_write.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/download_file.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/get_files.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/md_to_json.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/utils.py +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/SOURCES.txt +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/dependency_links.txt +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/entry_points.txt +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/requires.txt +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/top_level.txt +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/setup.cfg +0 -0
- {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/setup.py +0 -0
|
@@ -71,6 +71,11 @@ def get_or_set_token(production=True):
|
|
|
71
71
|
with open(token_file, "rb") as f:
|
|
72
72
|
encrypted_token = f.read()
|
|
73
73
|
token = decrypt_token(encrypted_token, key)
|
|
74
|
+
print(
|
|
75
|
+
"Using saved CaltechDATA production token."
|
|
76
|
+
if production
|
|
77
|
+
else "Using saved CaltechDATA test token."
|
|
78
|
+
)
|
|
74
79
|
return token
|
|
75
80
|
except FileNotFoundError:
|
|
76
81
|
while True:
|
|
@@ -422,8 +427,6 @@ def main():
|
|
|
422
427
|
|
|
423
428
|
def create_record(production):
|
|
424
429
|
token = get_or_set_token(production)
|
|
425
|
-
# keep_file = input("Do you want to keep your existing files? (yes/no): ").lower() == "yes"
|
|
426
|
-
print("Using CaltechDATA token:", token)
|
|
427
430
|
while True:
|
|
428
431
|
choice = get_user_input(
|
|
429
432
|
"Do you want to use metadata from an existing file or create new metadata? (existing/create): "
|
|
@@ -8,26 +8,43 @@ from datacite import schema43
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def get_metadata(
|
|
11
|
-
idv,
|
|
11
|
+
idv,
|
|
12
|
+
production=True,
|
|
13
|
+
validate=True,
|
|
14
|
+
emails=False,
|
|
15
|
+
schema="43",
|
|
16
|
+
token=False,
|
|
17
|
+
authors=False,
|
|
12
18
|
):
|
|
13
19
|
# Returns just DataCite metadata or DataCite metadata with emails
|
|
14
20
|
|
|
15
21
|
if production == True:
|
|
16
|
-
|
|
22
|
+
if authors:
|
|
23
|
+
url = "https://authors.library.caltech.edu/api/records/"
|
|
24
|
+
else:
|
|
25
|
+
url = "https://data.caltech.edu/api/records/"
|
|
17
26
|
verify = True
|
|
18
27
|
else:
|
|
19
|
-
|
|
28
|
+
if authors:
|
|
29
|
+
url = "https://authors.caltechlibrary.dev/api/records/"
|
|
30
|
+
else:
|
|
31
|
+
url = "https://data.caltechlibrary.dev/api/records/"
|
|
20
32
|
verify = True
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
if authors:
|
|
35
|
+
headers = {
|
|
36
|
+
"accept": "application/json",
|
|
37
|
+
}
|
|
38
|
+
validate = False
|
|
39
|
+
else:
|
|
40
|
+
headers = {
|
|
41
|
+
"accept": "application/vnd.datacite.datacite+json",
|
|
42
|
+
}
|
|
25
43
|
|
|
26
44
|
if token:
|
|
27
45
|
headers["Authorization"] = "Bearer %s" % token
|
|
28
46
|
|
|
29
47
|
response = requests.get(url + idv, headers=headers, verify=verify)
|
|
30
|
-
print(response.headers)
|
|
31
48
|
if response.status_code != 200:
|
|
32
49
|
raise Exception(response.text)
|
|
33
50
|
else:
|
|
@@ -59,6 +76,7 @@ if __name__ == "__main__":
|
|
|
59
76
|
help="The CaltechDATA ID for each record of interest",
|
|
60
77
|
)
|
|
61
78
|
parser.add_argument("-test", dest="production", action="store_false")
|
|
79
|
+
parser.add_argument("-authors", dest="authors", action="store_true")
|
|
62
80
|
parser.add_argument("-xml", dest="save_xml", action="store_true")
|
|
63
81
|
parser.add_argument(
|
|
64
82
|
"-skip_validate",
|
|
@@ -72,6 +90,7 @@ if __name__ == "__main__":
|
|
|
72
90
|
|
|
73
91
|
production = args.production
|
|
74
92
|
schema = args.schema
|
|
93
|
+
authors = args.authors
|
|
75
94
|
skip_validate = args.skip_validate
|
|
76
95
|
if skip_validate:
|
|
77
96
|
validate = False
|
|
@@ -79,7 +98,9 @@ if __name__ == "__main__":
|
|
|
79
98
|
validate = True
|
|
80
99
|
|
|
81
100
|
for idv in args.ids:
|
|
82
|
-
metadata = get_metadata(
|
|
101
|
+
metadata = get_metadata(
|
|
102
|
+
idv, production, validate, schema=schema, authors=authors
|
|
103
|
+
)
|
|
83
104
|
outfile = open(str(idv) + ".json", "w")
|
|
84
105
|
outfile.write(json.dumps(metadata, indent=4))
|
|
85
106
|
outfile.close()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|