osbot-utils 1.74.0__py3-none-any.whl → 1.75.0__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.
@@ -276,7 +276,7 @@ class Type_Safe:
276
276
  return new_value
277
277
 
278
278
  # todo: this needs refactoring, since the logic and code is getting quite complex (to be inside methods like this)
279
- def deserialize_from_dict(self, data):
279
+ def deserialize_from_dict(self, data, raise_on_not_found=False):
280
280
 
281
281
  for key, value in data.items():
282
282
  if hasattr(self, key) and isinstance(getattr(self, key), Type_Safe):
@@ -284,7 +284,10 @@ class Type_Safe:
284
284
  else:
285
285
  if hasattr(self, '__annotations__'): # can only do type safety checks if the class does not have annotations
286
286
  if hasattr(self, key) is False: # make sure we are now adding new attributes to the class
287
- raise ValueError(f"Attribute '{key}' not found in '{self.__class__.__name__}'")
287
+ if raise_on_not_found:
288
+ raise ValueError(f"Attribute '{key}' not found in '{self.__class__.__name__}'")
289
+ else:
290
+ continue
288
291
  if obj_is_attribute_annotation_of_type(self, key, dict): # handle the case when the value is a dict
289
292
  value = self.deserialize_dict__using_key_value_annotations(key, value)
290
293
  else:
@@ -319,11 +322,11 @@ class Type_Safe:
319
322
  pprint(serialize_to_dict(self))
320
323
 
321
324
  @classmethod
322
- def from_json(cls, json_data):
325
+ def from_json(cls, json_data, raise_on_not_found=False):
323
326
  if type(json_data) is str:
324
327
  json_data = json_parse(json_data)
325
328
  if json_data: # if there is no data or is {} then don't create an object (since this could be caused by bad data being provided)
326
- return cls().deserialize_from_dict(json_data)
329
+ return cls().deserialize_from_dict(json_data,raise_on_not_found=raise_on_not_found)
327
330
  return None
328
331
 
329
332
  # todo: see if it is possible to add recursive protection to this logic
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v1.74.0
1
+ v1.75.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: osbot_utils
3
- Version: 1.74.0
3
+ Version: 1.75.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  Home-page: https://github.com/owasp-sbot/OSBot-Utils
6
6
  License: MIT
@@ -23,7 +23,7 @@ Description-Content-Type: text/markdown
23
23
 
24
24
  Powerful Python util methods and classes that simplify common apis and tasks.
25
25
 
26
- ![Current Release](https://img.shields.io/badge/release-v1.74.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v1.75.0-blue)
27
27
  [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
28
28
 
29
29
 
@@ -2,7 +2,7 @@ osbot_utils/__init__.py,sha256=DdJDmQc9zbQUlPVyTJOww6Ixrn9n4bD3ami5ItQfzJI,16
2
2
  osbot_utils/base_classes/Cache_Pickle.py,sha256=kPCwrgUbf_dEdxUz7vW1GuvIPwlNXxuRhb-H3AbSpII,5884
3
3
  osbot_utils/base_classes/Kwargs_To_Disk.py,sha256=HHoy05NC_w35WcT-OnSKoSIV_cLqaU9rdjH0_KNTM0E,1096
4
4
  osbot_utils/base_classes/Kwargs_To_Self.py,sha256=weFNsBfBNV9W_qBkN-IdBD4yYcJV_zgTxBRO-ZlcPS4,141
5
- osbot_utils/base_classes/Type_Safe.py,sha256=-sqoyhkBKmS9XbZLBn_v1Gp_G48Sj8pTAfeIsOjqhFY,20515
5
+ osbot_utils/base_classes/Type_Safe.py,sha256=HFCSsZzPaLWXsdHwbZnlSXiSQkgUz7-zlSKsZdz4rb8,20723
6
6
  osbot_utils/base_classes/Type_Safe__List.py,sha256=-80C9OhsK6iDR2dAG8yNLAZV0qg5x3faqvSUigFCMJw,517
7
7
  osbot_utils/base_classes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  osbot_utils/context_managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -306,8 +306,8 @@ osbot_utils/utils/Toml.py,sha256=-_Yv5T8ZhGGoDSSoNEdFhSsXiK_JPjGkPijm4JoeHSk,166
306
306
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
307
307
  osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
308
308
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
309
- osbot_utils/version,sha256=U_5lj1S74Cr9RVYfx-7VpgSw9ZMSTVue_xUCI93hd-E,8
310
- osbot_utils-1.74.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
311
- osbot_utils-1.74.0.dist-info/METADATA,sha256=zKgQ_eqEOpF2Ra_M9enHvLWHbLKB-TYwwdoROthafY4,1317
312
- osbot_utils-1.74.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
313
- osbot_utils-1.74.0.dist-info/RECORD,,
309
+ osbot_utils/version,sha256=IdfB-8biCzk5RZAMmx_BUJIAAXhvydx4RexwM746BAE,8
310
+ osbot_utils-1.75.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
311
+ osbot_utils-1.75.0.dist-info/METADATA,sha256=MQH_uvmVgPG2nnT7IBWOY_yFWL1daiz5chafrEiYqHk,1317
312
+ osbot_utils-1.75.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
313
+ osbot_utils-1.75.0.dist-info/RECORD,,