caltechdata-api 1.10.1__tar.gz → 1.10.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 (22) hide show
  1. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/PKG-INFO +1 -1
  2. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/__init__.py +1 -0
  3. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/caltechdata_edit.py +42 -0
  4. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/customize_schema.py +1 -1
  5. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api.egg-info/PKG-INFO +1 -1
  6. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/setup.cfg +1 -1
  7. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/LICENSE +0 -0
  8. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/README.md +0 -0
  9. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/caltechdata_write.py +0 -0
  10. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/cli.py +0 -0
  11. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/download_file.py +0 -0
  12. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/get_files.py +0 -0
  13. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/get_metadata.py +0 -0
  14. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/md_to_json.py +0 -0
  15. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api/utils.py +0 -0
  16. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api.egg-info/SOURCES.txt +0 -0
  17. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api.egg-info/dependency_links.txt +0 -0
  18. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api.egg-info/entry_points.txt +0 -0
  19. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api.egg-info/requires.txt +0 -0
  20. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/caltechdata_api.egg-info/top_level.txt +0 -0
  21. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/pyproject.toml +0 -0
  22. {caltechdata_api-1.10.1 → caltechdata_api-1.10.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: caltechdata_api
3
- Version: 1.10.1
3
+ Version: 1.10.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, Rohan Bhattarai, Elizabeth Won, Alexander A Abakah, Kshemaahna Nagi
@@ -8,6 +8,7 @@ from .caltechdata_edit import (
8
8
  caltechdata_edit,
9
9
  caltechdata_unembargo,
10
10
  caltechdata_accept,
11
+ caltechdata_reject,
11
12
  )
12
13
  from .customize_schema import customize_schema, validate_metadata
13
14
  from .get_metadata import get_metadata
@@ -49,6 +49,48 @@ def caltechdata_accept(ids, token=None, production=False):
49
49
  raise Exception(result.text)
50
50
 
51
51
 
52
+ def caltechdata_reject(ids, token=None, production=False, authors=False):
53
+ # Reject a record from a community
54
+
55
+ # If no token is provided, get from RDMTOK environment variable
56
+ if not token:
57
+ token = os.environ["RDMTOK"]
58
+
59
+ if production == True:
60
+ if authors:
61
+ url = "https://authors.library.caltech.edu"
62
+ else:
63
+ url = "https://data.caltech.edu"
64
+ else:
65
+ if authors:
66
+ url = "https://authors.caltechlibrary.dev"
67
+ else:
68
+ url = "https://data.caltechlibrary.dev"
69
+
70
+ headers = {
71
+ "Authorization": "Bearer %s" % token,
72
+ "Content-type": "application/json",
73
+ }
74
+
75
+ for idv in ids:
76
+ result = requests.get(
77
+ url + "/api/records/" + idv + "/draft/review", headers=headers
78
+ )
79
+ print(url + "/api/records/" + idv + "/draft/review")
80
+ if result.status_code != 200:
81
+ raise Exception(result.text)
82
+ accept_link = result.json()["links"]["actions"]["decline"]
83
+ data = comment = {
84
+ "payload": {
85
+ "content": "This record was declined automatically with the CaltechDATA API",
86
+ "format": "html",
87
+ }
88
+ }
89
+ result = requests.post(accept_link, json=data, headers=headers)
90
+ if result.status_code != 200:
91
+ raise Exception(result.text)
92
+
93
+
52
94
  def caltechdata_edit(
53
95
  idv,
54
96
  metadata={},
@@ -17,7 +17,7 @@ def grid_to_ror(grid):
17
17
  elif grid == "grid.465477.3":
18
18
  ror = "00em52312"
19
19
  else:
20
- url = f"https://api.ror.org/organizations?query.advanced=external_ids.GRID.all:{grid}"
20
+ url = f"https://api.ror.org/organizations?query.advanced=external_ids.all:{grid}"
21
21
  results = requests.get(url).json()
22
22
  if len(results["items"]) == 0:
23
23
  print(url + "doesn't have a valid ROR")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: caltechdata-api
3
- Version: 1.10.1
3
+ Version: 1.10.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, Rohan Bhattarai, Elizabeth Won, Alexander A Abakah, Kshemaahna Nagi
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [metadata]
6
6
  name = caltechdata_api
7
- version = 1.10.1
7
+ version = 1.10.2
8
8
  author = Thomas E Morrell, Rohan Bhattarai, Elizabeth Won, Alexander A Abakah, Kshemaahna Nagi
9
9
  author_email = tmorrell@caltech.edu, aabakah@caltech.edu, knagi@caltech.edu
10
10
  description = Python wrapper for CaltechDATA API.