osbot-utils 1.58.0__py3-none-any.whl → 1.59.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.
@@ -14,10 +14,10 @@ from osbot_utils.helpers.Random_Guid import Random_Guid
14
14
  from osbot_utils.utils.Dev import pprint
15
15
  from osbot_utils.utils.Json import json_parse
16
16
  from osbot_utils.utils.Misc import list_set
17
- from osbot_utils.utils.Objects import default_value, value_type_matches_obj_annotation_for_attr, \
17
+ from osbot_utils.utils.Objects import default_value, value_type_matches_obj_annotation_for_attr, \
18
18
  raise_exception_on_obj_type_annotation_mismatch, obj_is_attribute_annotation_of_type, enum_from_value, \
19
19
  obj_is_type_union_compatible, value_type_matches_obj_annotation_for_union_attr, \
20
- convert_dict_to_value_from_obj_annotation
20
+ convert_dict_to_value_from_obj_annotation, dict_to_obj
21
21
 
22
22
  # Backport implementations of get_origin and get_args for Python 3.7
23
23
  if sys.version_info < (3, 8): # pragma: no cover
@@ -272,6 +272,9 @@ class Type_Safe:
272
272
 
273
273
  return self
274
274
 
275
+ def obj(self):
276
+ return dict_to_obj(self.json())
277
+
275
278
  def serialize_to_dict(self): # todo: see if we need this method or if the .json() is enough
276
279
  return serialize_to_dict(self)
277
280
 
@@ -122,18 +122,21 @@ def dict_remove(data, target):
122
122
  del data[target]
123
123
  return data
124
124
 
125
+ class __(SimpleNamespace):
126
+ pass
125
127
 
126
- def dict_to_obj(target, class_name="_"):
127
- DynamicClass = type(class_name, (SimpleNamespace,), {})
128
+ def dict_to_obj(target):
128
129
  if isinstance(target, Mapping):
129
130
  new_dict = {}
130
131
  for key, value in target.items():
131
- new_dict[key] = dict_to_obj(value, class_name=class_name) # Recursively convert elements in the dict
132
- return DynamicClass(**new_dict)
132
+ new_dict[key] = dict_to_obj(value) # Recursively convert elements in the dict
133
+ return __(**new_dict)
133
134
  elif isinstance(target, list): # Recursively convert elements in the list
134
- return [dict_to_obj(item, class_name=class_name) for item in target]
135
+ return [dict_to_obj(item) for item in target]
135
136
  elif isinstance(target, tuple): # Recursively convert elements in the tuple
136
- return tuple(dict_to_obj(item, class_name=class_name) for item in target)
137
+ return tuple(dict_to_obj(item) for item in target)
138
+ # elif hasattr(target, 'json'): # todo: see if we need this. I don't like the idea of adding this extra hidden behaviour to this class
139
+ # return dict_to_obj(target.json())
137
140
 
138
141
  return target
139
142
 
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v1.58.0
1
+ v1.59.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: osbot_utils
3
- Version: 1.58.0
3
+ Version: 1.59.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  Home-page: https://github.com/owasp-sbot/OSBot-Utils
6
6
  License: MIT
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
22
22
 
23
23
  Powerful Python util methods and classes that simplify common apis and tasks.
24
24
 
25
- ![Current Release](https://img.shields.io/badge/release-v1.58.0-blue)
25
+ ![Current Release](https://img.shields.io/badge/release-v1.59.0-blue)
26
26
  [![codecov](https://codecov.io/gh/owasp-sbot/OSBot-Utils/graph/badge.svg?token=GNVW0COX1N)](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
27
27
 
28
28
 
@@ -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=xG3peP_hyuUYYi84zR6LhzmgoFYYLBbYwoIQb9XAmpQ,17905
5
+ osbot_utils/base_classes/Type_Safe.py,sha256=SwgDhPKeC2jUWNmihUXwvDoXFhnZPOSrrsu1YnCyyx0,17961
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
@@ -290,7 +290,7 @@ osbot_utils/utils/Json.py,sha256=7COxBlZRnpxtpNqpmzMPYkcKTnCok-s686nT27oiKEQ,648
290
290
  osbot_utils/utils/Json_Cache.py,sha256=mLPkkDZN-3ZVJiDvV1KBJXILtKkTZ4OepzOsDoBPhWg,2006
291
291
  osbot_utils/utils/Lists.py,sha256=tPz5x5s3sRO97WZ_nsxREBPC5cwaHrhgaYBhsrffTT8,5599
292
292
  osbot_utils/utils/Misc.py,sha256=nODZT6p44B4xYiIiqfEeKYEErQiKR9SGthhGtZWGhkI,16804
293
- osbot_utils/utils/Objects.py,sha256=60OFmwQZgqyfmOGS_WtD59-b0lB7rGhqWoh0tgkBKOc,17367
293
+ osbot_utils/utils/Objects.py,sha256=0XKssf_aGarfWI-2Gl-XXUb2tYglTfCBkiKa5zTF0O4,17498
294
294
  osbot_utils/utils/Png.py,sha256=V1juGp6wkpPigMJ8HcxrPDIP4bSwu51oNkLI8YqP76Y,1172
295
295
  osbot_utils/utils/Process.py,sha256=lr3CTiEkN3EiBx3ZmzYmTKlQoPdkgZBRjPulMxG-zdo,2357
296
296
  osbot_utils/utils/Python_Logger.py,sha256=tx8N6wRKL3RDHboDRKZn8SirSJdSAE9cACyJkxrThZ8,12792
@@ -302,8 +302,8 @@ osbot_utils/utils/Toml.py,sha256=SD6IA4-mrtoBXcI0dIGKV9POMQNd6WYKvmDQq7GQ6ZQ,143
302
302
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
303
303
  osbot_utils/utils/Zip.py,sha256=G6Hk_hDcm9yvWzhTKzhT0R_6f0NBIAchHqMxGb3kfh4,14037
304
304
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
305
- osbot_utils/version,sha256=3zcuCY19oU6Xohxuk7cSp-mCBuuGU7OwYkdC8RVRMgw,8
306
- osbot_utils-1.58.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
307
- osbot_utils-1.58.0.dist-info/METADATA,sha256=jOtdSqjuFy3-p5D93fRccvYUYdAyQuM3irMTOpltDhw,1266
308
- osbot_utils-1.58.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
309
- osbot_utils-1.58.0.dist-info/RECORD,,
305
+ osbot_utils/version,sha256=EhXG92o5KIntEa30a4LpsRMDYwjYTabNawYRJaxsOiI,8
306
+ osbot_utils-1.59.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
307
+ osbot_utils-1.59.0.dist-info/METADATA,sha256=DdvKFldlZVnDRyR4XMvON5CIAjR_-MNMAKm2e4XeDHY,1266
308
+ osbot_utils-1.59.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
309
+ osbot_utils-1.59.0.dist-info/RECORD,,