dcicutils 8.7.0.1b7__py3-none-any.whl → 8.7.0.1b9__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- dcicutils/portal_utils.py +19 -19
- {dcicutils-8.7.0.1b7.dist-info → dcicutils-8.7.0.1b9.dist-info}/METADATA +1 -1
- {dcicutils-8.7.0.1b7.dist-info → dcicutils-8.7.0.1b9.dist-info}/RECORD +6 -6
- {dcicutils-8.7.0.1b7.dist-info → dcicutils-8.7.0.1b9.dist-info}/LICENSE.txt +0 -0
- {dcicutils-8.7.0.1b7.dist-info → dcicutils-8.7.0.1b9.dist-info}/WHEEL +0 -0
- {dcicutils-8.7.0.1b7.dist-info → dcicutils-8.7.0.1b9.dist-info}/entry_points.txt +0 -0
dcicutils/portal_utils.py
CHANGED
@@ -207,10 +207,10 @@ class Portal:
|
|
207
207
|
|
208
208
|
def get(self, url: str, follow: bool = True, raise_for_status: bool = False, **kwargs) -> OptionalResponse:
|
209
209
|
url = self.url(url)
|
210
|
-
if not self.
|
210
|
+
if not self.vapp:
|
211
211
|
response = requests.get(url, allow_redirects=follow, **self._kwargs(**kwargs))
|
212
212
|
else:
|
213
|
-
response = self.
|
213
|
+
response = self.vapp.get(url, **self._kwargs(**kwargs))
|
214
214
|
if response and response.status_code in [301, 302, 303, 307, 308] and follow:
|
215
215
|
response = response.follow()
|
216
216
|
response = self._response(response)
|
@@ -221,10 +221,10 @@ class Portal:
|
|
221
221
|
def patch(self, url: str, data: Optional[dict] = None, json: Optional[dict] = None,
|
222
222
|
raise_for_status: bool = False, **kwargs) -> OptionalResponse:
|
223
223
|
url = self.url(url)
|
224
|
-
if not self.
|
224
|
+
if not self.vapp:
|
225
225
|
response = requests.patch(url, data=data, json=json, **self._kwargs(**kwargs))
|
226
226
|
else:
|
227
|
-
response = self.
|
227
|
+
response = self.vapp.patch_json(url, json or data, **self._kwargs(**kwargs))
|
228
228
|
response = self._response(response)
|
229
229
|
if raise_for_status:
|
230
230
|
response.raise_for_status()
|
@@ -233,29 +233,29 @@ class Portal:
|
|
233
233
|
def post(self, url: str, data: Optional[dict] = None, json: Optional[dict] = None, files: Optional[dict] = None,
|
234
234
|
raise_for_status: bool = False, **kwargs) -> OptionalResponse:
|
235
235
|
url = self.url(url)
|
236
|
-
if not self.
|
236
|
+
if not self.vapp:
|
237
237
|
response = requests.post(url, data=data, json=json, files=files, **self._kwargs(**kwargs))
|
238
238
|
else:
|
239
239
|
if files:
|
240
|
-
response = self.
|
240
|
+
response = self.vapp.post(url, json or data, upload_files=files, **self._kwargs(**kwargs))
|
241
241
|
else:
|
242
|
-
response = self.
|
242
|
+
response = self.vapp.post_json(url, json or data, upload_files=files, **self._kwargs(**kwargs))
|
243
243
|
response = self._response(response)
|
244
244
|
if raise_for_status:
|
245
245
|
response.raise_for_status()
|
246
246
|
return response
|
247
247
|
|
248
248
|
def get_metadata(self, object_id: str) -> Optional[dict]:
|
249
|
-
return get_metadata(obj_id=object_id, vapp=self.
|
249
|
+
return get_metadata(obj_id=object_id, vapp=self.vapp, key=self.key)
|
250
250
|
|
251
251
|
def patch_metadata(self, object_id: str, data: str) -> Optional[dict]:
|
252
|
-
if self.
|
253
|
-
return patch_metadata(obj_id=object_id, patch_item=data, key=self.
|
252
|
+
if self.key:
|
253
|
+
return patch_metadata(obj_id=object_id, patch_item=data, key=self.key)
|
254
254
|
return self.patch(f"/{object_id}", data).json()
|
255
255
|
|
256
256
|
def post_metadata(self, object_type: str, data: str) -> Optional[dict]:
|
257
|
-
if self.
|
258
|
-
return post_metadata(schema_name=object_type, post_item=data, key=self.
|
257
|
+
if self.key:
|
258
|
+
return post_metadata(schema_name=object_type, post_item=data, key=self.key)
|
259
259
|
return self.post(f"/{object_type}", data).json()
|
260
260
|
|
261
261
|
def get_health(self) -> OptionalResponse:
|
@@ -268,14 +268,14 @@ class Portal:
|
|
268
268
|
return False
|
269
269
|
|
270
270
|
def get_schema(self, schema_name: str) -> Optional[dict]:
|
271
|
-
return get_schema(self.schema_name(schema_name), portal_vapp=self.
|
271
|
+
return get_schema(self.schema_name(schema_name), portal_vapp=self.vapp, key=self.key)
|
272
272
|
|
273
273
|
def get_schemas(self) -> dict:
|
274
274
|
return self.get("/profiles/").json()
|
275
275
|
|
276
276
|
@staticmethod
|
277
277
|
def schema_name(name: str) -> str:
|
278
|
-
return to_camel_case(name if not name.endswith(".json") else name[:-5])
|
278
|
+
return to_camel_case(name.replace(" ", "") if not name.endswith(".json") else name[:-5])
|
279
279
|
|
280
280
|
def is_schema_type(self, value: dict, schema_type: str) -> bool:
|
281
281
|
"""
|
@@ -348,13 +348,13 @@ class Portal:
|
|
348
348
|
return url
|
349
349
|
if not (url := re.sub(r"/+", "/", url)).startswith("/"):
|
350
350
|
url = "/"
|
351
|
-
return self.
|
351
|
+
return self.server + url if self.server else url
|
352
352
|
|
353
353
|
def _kwargs(self, **kwargs) -> dict:
|
354
354
|
result_kwargs = {"headers":
|
355
355
|
kwargs.get("headers", {"Content-type": "application/json", "Accept": "application/json"})}
|
356
|
-
if self.
|
357
|
-
result_kwargs["auth"] = self.
|
356
|
+
if self.key_pair:
|
357
|
+
result_kwargs["auth"] = self.key_pair
|
358
358
|
if isinstance(timeout := kwargs.get("timeout"), int):
|
359
359
|
result_kwargs["timeout"] = timeout
|
360
360
|
return result_kwargs
|
@@ -457,9 +457,9 @@ class Portal:
|
|
457
457
|
return config.make_wsgi_app()
|
458
458
|
|
459
459
|
def start_for_testing(self, port: int = 7070, asynchronous: bool = False) -> Optional[Thread]:
|
460
|
-
if isinstance(self.
|
460
|
+
if isinstance(self.vapp, TestApp) and hasattr(self.vapp, "app") and isinstance(self.vapp.app, PyramidRouter):
|
461
461
|
def start_server() -> None: # noqa
|
462
|
-
with wsgi_make_server("0.0.0.0", port or 7070, self.
|
462
|
+
with wsgi_make_server("0.0.0.0", port or 7070, self.vapp.app) as server:
|
463
463
|
server.serve_forever()
|
464
464
|
if asynchronous:
|
465
465
|
server_thread = Thread(target=start_server)
|
@@ -43,7 +43,7 @@ dcicutils/log_utils.py,sha256=7pWMc6vyrorUZQf-V-M3YC6zrPgNhuV_fzm9xqTPph0,10883
|
|
43
43
|
dcicutils/misc_utils.py,sha256=bMRWWxdbhuF3PKdCZEH-H4U1ecgT3Nag3EL92D9XGoY,100973
|
44
44
|
dcicutils/obfuscation_utils.py,sha256=fo2jOmDRC6xWpYX49u80bVNisqRRoPskFNX3ymFAmjw,5963
|
45
45
|
dcicutils/opensearch_utils.py,sha256=V2exmFYW8Xl2_pGFixF4I2Cc549Opwe4PhFi5twC0M8,1017
|
46
|
-
dcicutils/portal_utils.py,sha256=
|
46
|
+
dcicutils/portal_utils.py,sha256=td4Z3tQPbQVo9k_r2PisT7BPUSg83R4LcrBfx-QmvVA,23297
|
47
47
|
dcicutils/project_utils.py,sha256=qPdCaFmWUVBJw4rw342iUytwdQC0P-XKpK4mhyIulMM,31250
|
48
48
|
dcicutils/qa_checkers.py,sha256=cdXjeL0jCDFDLT8VR8Px78aS10hwNISOO5G_Zv2TZ6M,20534
|
49
49
|
dcicutils/qa_utils.py,sha256=TT0SiJWiuxYvbsIyhK9VO4uV_suxhB6CpuC4qPacCzQ,160208
|
@@ -64,8 +64,8 @@ dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
|
|
64
64
|
dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
|
65
65
|
dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
|
66
66
|
dcicutils/zip_utils.py,sha256=rnjNv_k6L9jT2SjDSgVXp4BEJYLtz9XN6Cl2Fy-tqnM,2027
|
67
|
-
dcicutils-8.7.0.
|
68
|
-
dcicutils-8.7.0.
|
69
|
-
dcicutils-8.7.0.
|
70
|
-
dcicutils-8.7.0.
|
71
|
-
dcicutils-8.7.0.
|
67
|
+
dcicutils-8.7.0.1b9.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
|
68
|
+
dcicutils-8.7.0.1b9.dist-info/METADATA,sha256=rRVu3P48wn85bGP0Os3PYo_l4T81vxf7RKRrQicp-3Q,3314
|
69
|
+
dcicutils-8.7.0.1b9.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
70
|
+
dcicutils-8.7.0.1b9.dist-info/entry_points.txt,sha256=8wbw5csMIgBXhkwfgsgJeuFcoUc0WsucUxmOyml2aoA,209
|
71
|
+
dcicutils-8.7.0.1b9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|