dcicutils 8.7.0.1b2__py3-none-any.whl → 8.7.0.1b4__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 +31 -4
- {dcicutils-8.7.0.1b2.dist-info → dcicutils-8.7.0.1b4.dist-info}/METADATA +1 -1
- {dcicutils-8.7.0.1b2.dist-info → dcicutils-8.7.0.1b4.dist-info}/RECORD +6 -6
- {dcicutils-8.7.0.1b2.dist-info → dcicutils-8.7.0.1b4.dist-info}/LICENSE.txt +0 -0
- {dcicutils-8.7.0.1b2.dist-info → dcicutils-8.7.0.1b4.dist-info}/WHEEL +0 -0
- {dcicutils-8.7.0.1b2.dist-info → dcicutils-8.7.0.1b4.dist-info}/entry_points.txt +0 -0
dcicutils/portal_utils.py
CHANGED
@@ -257,15 +257,39 @@ class Portal:
|
|
257
257
|
def schema_name(name: str) -> str:
|
258
258
|
return to_camel_case(name if not name.endswith(".json") else name[:-5]) if isinstance(name, str) else ""
|
259
259
|
|
260
|
-
def
|
260
|
+
def is_schema_type(self, value: dict, schema_type: str) -> bool:
|
261
261
|
"""
|
262
|
-
Returns True iff the given
|
262
|
+
Returns True iff the given object isa type of the given schema type.
|
263
|
+
"""
|
264
|
+
if isinstance(value, dict) and (value_types := value.get("@type")):
|
265
|
+
if isinstance(value_types, str):
|
266
|
+
return self.is_specified_schema(value_types, schema_type)
|
267
|
+
elif isinstance(value_types, list):
|
268
|
+
for value_type in value_types:
|
269
|
+
if self.is_specified_schema(value_type, schema_type):
|
270
|
+
return True
|
271
|
+
return False
|
272
|
+
|
273
|
+
def is_specified_schema(self, schema_name: str, schema_type: str) -> bool:
|
274
|
+
"""
|
275
|
+
Returns True iff the given schema name isa type of the given schema type name,
|
276
|
+
i.e. has an ancestor which is of type that given type.
|
263
277
|
"""
|
278
|
+
schema_name = self.schema_name(schema_name)
|
279
|
+
schema_type = self.schema_name(schema_type)
|
280
|
+
if schema_name == schema_type:
|
281
|
+
return True
|
264
282
|
if super_type_map := self.get_schemas_super_type_map():
|
265
|
-
if
|
266
|
-
return self.schema_name(schema_name) in
|
283
|
+
if super_type := super_type_map.get(schema_type):
|
284
|
+
return self.schema_name(schema_name) in super_type
|
267
285
|
return False
|
268
286
|
|
287
|
+
def is_file_schema(self, schema_name: str) -> bool:
|
288
|
+
"""
|
289
|
+
Returns True iff the given schema name isa File type, i.e. has an ancestor which is of type File.
|
290
|
+
"""
|
291
|
+
return self.is_specified_schema(schema_name, Portal.FILE_SCHEMA_NAME)
|
292
|
+
|
269
293
|
def get_schemas_super_type_map(self) -> dict:
|
270
294
|
"""
|
271
295
|
Returns the "super type map" for all of the known schemas (via /profiles).
|
@@ -335,6 +359,9 @@ class Portal:
|
|
335
359
|
return getattr(self._response, attr)
|
336
360
|
def json(self): # noqa
|
337
361
|
return self._response.json
|
362
|
+
def raise_for_status(self): # noqa
|
363
|
+
if self.status_code < 200 or self.status_code > 399:
|
364
|
+
raise requests.exceptions.HTTPError(f"HTTP Error: {self.status_code}", response=self)
|
338
365
|
response = TestResponseWrapper(response)
|
339
366
|
return response
|
340
367
|
|
@@ -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=e7MnUbEXNOS-_NiCV4Xod3BT_K1Cy-crsRAqZdG_sXo,22528
|
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.1b4.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
|
68
|
+
dcicutils-8.7.0.1b4.dist-info/METADATA,sha256=Fc1lyyT3RwFRF93kxrHZ-j8zGImaJktcCUQno5PTXRs,3314
|
69
|
+
dcicutils-8.7.0.1b4.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
70
|
+
dcicutils-8.7.0.1b4.dist-info/entry_points.txt,sha256=8wbw5csMIgBXhkwfgsgJeuFcoUc0WsucUxmOyml2aoA,209
|
71
|
+
dcicutils-8.7.0.1b4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|