dcicutils 8.7.0.1b3__py3-none-any.whl → 8.7.0.1b5__py3-none-any.whl
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.
- dcicutils/portal_utils.py +50 -16
- {dcicutils-8.7.0.1b3.dist-info → dcicutils-8.7.0.1b5.dist-info}/METADATA +1 -1
- {dcicutils-8.7.0.1b3.dist-info → dcicutils-8.7.0.1b5.dist-info}/RECORD +6 -6
- {dcicutils-8.7.0.1b3.dist-info → dcicutils-8.7.0.1b5.dist-info}/LICENSE.txt +0 -0
- {dcicutils-8.7.0.1b3.dist-info → dcicutils-8.7.0.1b5.dist-info}/WHEEL +0 -0
- {dcicutils-8.7.0.1b3.dist-info → dcicutils-8.7.0.1b5.dist-info}/entry_points.txt +0 -0
dcicutils/portal_utils.py
CHANGED
@@ -202,28 +202,45 @@ class Portal:
|
|
202
202
|
def vapp(self) -> Optional[TestApp]:
|
203
203
|
return self._vapp
|
204
204
|
|
205
|
-
def get(self, url: str, follow: bool = True, **kwargs) -> OptionalResponse:
|
205
|
+
def get(self, url: str, follow: bool = True, raise_for_status: bool = False, **kwargs) -> OptionalResponse:
|
206
|
+
url = self.url(url)
|
206
207
|
if not self._vapp:
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
response
|
211
|
-
|
208
|
+
response = requests.get(url, allow_redirects=follow, **self._kwargs(**kwargs))
|
209
|
+
else:
|
210
|
+
response = self._vapp.get(url, **self._kwargs(**kwargs))
|
211
|
+
if response and response.status_code in [301, 302, 303, 307, 308] and follow:
|
212
|
+
response = response.follow()
|
213
|
+
response = self._response(response)
|
214
|
+
if raise_for_status:
|
215
|
+
response.raise_for_status()
|
216
|
+
return response
|
212
217
|
|
213
|
-
def patch(self, url: str, data: Optional[dict] = None, json: Optional[dict] = None,
|
218
|
+
def patch(self, url: str, data: Optional[dict] = None, json: Optional[dict] = None,
|
219
|
+
raise_for_status: bool = False, **kwargs) -> OptionalResponse:
|
220
|
+
url = self.url(url)
|
214
221
|
if not self._vapp:
|
215
|
-
|
216
|
-
|
222
|
+
response = requests.patch(url, data=data, json=json, **self._kwargs(**kwargs))
|
223
|
+
else:
|
224
|
+
response = self._vapp.patch_json(url, json or data, **self._kwargs(**kwargs))
|
225
|
+
response = self._response(response)
|
226
|
+
if raise_for_status:
|
227
|
+
response.raise_for_status()
|
228
|
+
return response
|
217
229
|
|
218
|
-
def post(self, url: str, data: Optional[dict] = None, json: Optional[dict] = None,
|
219
|
-
|
230
|
+
def post(self, url: str, data: Optional[dict] = None, json: Optional[dict] = None, files: Optional[dict] = None,
|
231
|
+
raise_for_status: bool = False, **kwargs) -> OptionalResponse:
|
232
|
+
url = self.url(url)
|
220
233
|
if not self._vapp:
|
221
|
-
|
222
|
-
if files:
|
223
|
-
response = self._vapp.post(self.url(url), json or data, upload_files=files, **self._kwargs(**kwargs))
|
234
|
+
response = requests.post(url, data=data, json=json, files=files, **self._kwargs(**kwargs))
|
224
235
|
else:
|
225
|
-
|
226
|
-
|
236
|
+
if files:
|
237
|
+
response = self._vapp.post(url, json or data, upload_files=files, **self._kwargs(**kwargs))
|
238
|
+
else:
|
239
|
+
response = self._vapp.post_json(url, json or data, upload_files=files, **self._kwargs(**kwargs))
|
240
|
+
response = self._response(response)
|
241
|
+
if raise_for_status:
|
242
|
+
response.raise_for_status()
|
243
|
+
return response
|
227
244
|
|
228
245
|
def get_metadata(self, object_id: str) -> Optional[dict]:
|
229
246
|
return get_metadata(obj_id=object_id, vapp=self._vapp, key=self._key)
|
@@ -257,11 +274,28 @@ class Portal:
|
|
257
274
|
def schema_name(name: str) -> str:
|
258
275
|
return to_camel_case(name if not name.endswith(".json") else name[:-5]) if isinstance(name, str) else ""
|
259
276
|
|
277
|
+
def is_schema_type(self, value: dict, schema_type: str) -> bool:
|
278
|
+
"""
|
279
|
+
Returns True iff the given object isa type of the given schema type.
|
280
|
+
"""
|
281
|
+
if isinstance(value, dict) and (value_types := value.get("@type")):
|
282
|
+
if isinstance(value_types, str):
|
283
|
+
return self.is_specified_schema(value_types, schema_type)
|
284
|
+
elif isinstance(value_types, list):
|
285
|
+
for value_type in value_types:
|
286
|
+
if self.is_specified_schema(value_type, schema_type):
|
287
|
+
return True
|
288
|
+
return False
|
289
|
+
|
260
290
|
def is_specified_schema(self, schema_name: str, schema_type: str) -> bool:
|
261
291
|
"""
|
262
292
|
Returns True iff the given schema name isa type of the given schema type name,
|
263
293
|
i.e. has an ancestor which is of type that given type.
|
264
294
|
"""
|
295
|
+
schema_name = self.schema_name(schema_name)
|
296
|
+
schema_type = self.schema_name(schema_type)
|
297
|
+
if schema_name == schema_type:
|
298
|
+
return True
|
265
299
|
if super_type_map := self.get_schemas_super_type_map():
|
266
300
|
if super_type := super_type_map.get(schema_type):
|
267
301
|
return self.schema_name(schema_name) in super_type
|
@@ -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=0fZ-PMB-oUDroUkMdoZ55xLEpfDz9a94jOZXrK3A0n8,23069
|
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.1b5.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
|
68
|
+
dcicutils-8.7.0.1b5.dist-info/METADATA,sha256=Dz4-8ARIZnllxNziTwz3y_Jnd-kdoRb2diBJhRh2bUE,3314
|
69
|
+
dcicutils-8.7.0.1b5.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
70
|
+
dcicutils-8.7.0.1b5.dist-info/entry_points.txt,sha256=8wbw5csMIgBXhkwfgsgJeuFcoUc0WsucUxmOyml2aoA,209
|
71
|
+
dcicutils-8.7.0.1b5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|