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.
Files changed (21) hide show
  1. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/PKG-INFO +1 -1
  2. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/cli.py +5 -2
  3. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/customize_schema.py +1 -2
  4. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/get_metadata.py +29 -8
  5. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/PKG-INFO +1 -1
  6. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/LICENSE +0 -0
  7. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/README.md +0 -0
  8. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/__init__.py +0 -0
  9. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/caltechdata_edit.py +0 -0
  10. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/caltechdata_write.py +0 -0
  11. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/download_file.py +0 -0
  12. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/get_files.py +0 -0
  13. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/md_to_json.py +0 -0
  14. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api/utils.py +0 -0
  15. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/SOURCES.txt +0 -0
  16. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/dependency_links.txt +0 -0
  17. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/entry_points.txt +0 -0
  18. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/requires.txt +0 -0
  19. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/caltechdata_api.egg-info/top_level.txt +0 -0
  20. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/setup.cfg +0 -0
  21. {caltechdata_api-1.8.1 → caltechdata_api-1.8.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: caltechdata_api
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Python wrapper for CaltechDATA API.
5
5
  Home-page: https://github.com/caltechlibrary/caltechdata_api
6
6
  Author: Thomas E Morrell, Bhattarai Rohan , Won Elizabeth
@@ -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): "
@@ -1,5 +1,4 @@
1
- # Convert a DataCite 4 or 4.3 standard schema json record to the customized internal
2
- # schema used by TIND in CaltechDATA
1
+ # Convert a DataCite 4.3 standard schema json record to the InvenioRDM schema
3
2
  import argparse
4
3
  import json
5
4
  from datetime import date
@@ -8,26 +8,43 @@ from datacite import schema43
8
8
 
9
9
 
10
10
  def get_metadata(
11
- idv, production=True, validate=True, emails=False, schema="43", token=False
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
- url = "https://data.caltech.edu/api/records/"
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
- url = "https://data.caltechlibrary.dev/api/records/"
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
- headers = {
23
- "accept": "application/vnd.datacite.datacite+json",
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(idv, production, validate, schema)
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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: caltechdata-api
3
- Version: 1.8.1
3
+ Version: 1.8.2
4
4
  Summary: Python wrapper for CaltechDATA API.
5
5
  Home-page: https://github.com/caltechlibrary/caltechdata_api
6
6
  Author: Thomas E Morrell, Bhattarai Rohan , Won Elizabeth
File without changes