osbot-utils 2.86.0__py3-none-any.whl → 2.87.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.
- osbot_utils/type_safe/Type_Safe.py +2 -2
- osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid_Short.py +3 -3
- osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Dict.py +41 -18
- osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Set.py +1 -1
- osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__From_Json.py +2 -2
- osbot_utils/version +1 -1
- {osbot_utils-2.86.0.dist-info → osbot_utils-2.87.0.dist-info}/METADATA +2 -2
- {osbot_utils-2.86.0.dist-info → osbot_utils-2.87.0.dist-info}/RECORD +10 -10
- {osbot_utils-2.86.0.dist-info → osbot_utils-2.87.0.dist-info}/LICENSE +0 -0
- {osbot_utils-2.86.0.dist-info → osbot_utils-2.87.0.dist-info}/WHEEL +0 -0
@@ -1,8 +1,8 @@
|
|
1
1
|
# todo: find a way to add these documentations strings to a separate location so that
|
2
2
|
# the data is available in IDE's code complete
|
3
|
-
from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Validation
|
3
|
+
from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Validation import type_safe_validation
|
4
4
|
from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Class_Kwargs import type_safe_step_class_kwargs
|
5
|
-
from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Default_Kwargs
|
5
|
+
from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Default_Kwargs import type_safe_step_default_kwargs
|
6
6
|
from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Default_Value import type_safe_step_default_value
|
7
7
|
from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Init import type_safe_step_init
|
8
8
|
from osbot_utils.type_safe.type_safe_core.steps.Type_Safe__Step__Set_Attr import type_safe_step_set_attr
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
from osbot_utils.utils.Misc
|
1
|
+
from osbot_utils.type_safe.Type_Safe__Primitive import Type_Safe__Primitive
|
2
|
+
from osbot_utils.utils.Misc import random_guid_short
|
3
3
|
|
4
4
|
|
5
|
-
class Random_Guid_Short(str):
|
5
|
+
class Random_Guid_Short(Type_Safe__Primitive, str):
|
6
6
|
def __new__(cls, value=None):
|
7
7
|
if value is None:
|
8
8
|
value = random_guid_short()
|
@@ -1,7 +1,9 @@
|
|
1
1
|
from typing import Type
|
2
|
+
from osbot_utils.testing.__ import __
|
2
3
|
from osbot_utils.type_safe.Type_Safe__Base import Type_Safe__Base
|
3
|
-
from osbot_utils.type_safe.Type_Safe__Primitive
|
4
|
+
from osbot_utils.type_safe.Type_Safe__Primitive import Type_Safe__Primitive
|
4
5
|
from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__List import Type_Safe__List
|
6
|
+
from osbot_utils.utils.Objects import dict_to_obj
|
5
7
|
|
6
8
|
|
7
9
|
class Type_Safe__Dict(Type_Safe__Base, dict):
|
@@ -28,33 +30,54 @@ class Type_Safe__Dict(Type_Safe__Base, dict):
|
|
28
30
|
def __enter__(self): return self
|
29
31
|
def __exit__ (self, type, value, traceback): pass
|
30
32
|
|
31
|
-
def json(self):
|
32
|
-
from osbot_utils.type_safe.Type_Safe import Type_Safe
|
33
|
+
def json(self):
|
34
|
+
from osbot_utils.type_safe.Type_Safe import Type_Safe
|
35
|
+
|
36
|
+
def serialize_value(v):
|
37
|
+
"""Recursively serialize values, handling nested structures"""
|
38
|
+
if isinstance(v, Type_Safe):
|
39
|
+
return v.json()
|
40
|
+
elif isinstance(v, Type_Safe__Primitive):
|
41
|
+
return v.__to_primitive__()
|
42
|
+
elif isinstance(v, dict):
|
43
|
+
# Recursively handle nested dictionaries
|
44
|
+
return {k2: serialize_value(v2) for k2, v2 in v.items()}
|
45
|
+
elif isinstance(v, (list, tuple, set)):
|
46
|
+
# Recursively handle sequences
|
47
|
+
serialized = [serialize_value(item) for item in v]
|
48
|
+
if isinstance(v, list):
|
49
|
+
return serialized
|
50
|
+
elif isinstance(v, tuple):
|
51
|
+
return tuple(serialized)
|
52
|
+
else: # set
|
53
|
+
return set(serialized)
|
54
|
+
else:
|
55
|
+
return v
|
33
56
|
|
34
57
|
result = {}
|
35
58
|
for key, value in self.items():
|
36
|
-
|
37
|
-
if isinstance(key, (type, Type)):
|
59
|
+
# Handle Type objects as keys
|
60
|
+
if isinstance(key, (type, Type)):
|
38
61
|
key = f"{key.__module__}.{key.__name__}"
|
39
62
|
elif isinstance(key, Type_Safe__Primitive):
|
40
63
|
key = key.__to_primitive__()
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
for item in value]
|
46
|
-
elif isinstance(value, dict): # Handle nested dictionaries that might contain Type_Safe objects
|
47
|
-
result[key] = {k: v.json() if isinstance(v, Type_Safe) else v
|
48
|
-
for k, v in value.items()}
|
49
|
-
else:
|
50
|
-
if isinstance(value, Type_Safe__Primitive):
|
51
|
-
result[key] = value.__to_primitive__()
|
52
|
-
else:
|
53
|
-
result[key] = value
|
64
|
+
|
65
|
+
# Use recursive serialization for values
|
66
|
+
result[key] = serialize_value(value)
|
67
|
+
|
54
68
|
return result
|
55
69
|
|
70
|
+
def get(self, key, default=None): # this makes it consistent with the modified behaviour of __get__item
|
71
|
+
try:
|
72
|
+
return self[key] # Use __getitem__ with conversion
|
73
|
+
except KeyError:
|
74
|
+
return default # Return default instead of raising
|
75
|
+
|
56
76
|
def keys(self) -> Type_Safe__List:
|
57
77
|
return Type_Safe__List(self.expected_key_type, super().keys())
|
58
78
|
|
79
|
+
def obj(self) -> __:
|
80
|
+
return dict_to_obj(self.json())
|
81
|
+
|
59
82
|
def values(self) -> Type_Safe__List:
|
60
83
|
return Type_Safe__List(self.expected_value_type, super().values())
|
@@ -5,7 +5,7 @@ from enum
|
|
5
5
|
from osbot_utils.helpers.Obj_Id import Obj_Id
|
6
6
|
from osbot_utils.type_safe.Type_Safe import Type_Safe
|
7
7
|
from osbot_utils.type_safe.primitives.safe_str.identifiers.Random_Guid import Random_Guid
|
8
|
-
from osbot_utils.type_safe.primitives.safe_str.identifiers.Random_Guid_Short
|
8
|
+
from osbot_utils.type_safe.primitives.safe_str.identifiers.Random_Guid_Short import Random_Guid_Short
|
9
9
|
from osbot_utils.type_safe.primitives.safe_str.cryptography.hashes.Safe_Str__Hash import Safe_Str__Hash
|
10
10
|
from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__Dict import Type_Safe__Dict
|
11
11
|
from osbot_utils.type_safe.type_safe_core.collections.Type_Safe__List import Type_Safe__List
|
@@ -16,7 +16,7 @@ from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Cache
|
|
16
16
|
from osbot_utils.type_safe.type_safe_core.shared.Type_Safe__Convert import type_safe_convert
|
17
17
|
from osbot_utils.utils.Objects import enum_from_value
|
18
18
|
from osbot_utils.type_safe.primitives.safe_str.identifiers.Safe_Id import Safe_Id
|
19
|
-
from osbot_utils.type_safe.primitives.safe_int.Timestamp_Now
|
19
|
+
from osbot_utils.type_safe.primitives.safe_int.Timestamp_Now import Timestamp_Now
|
20
20
|
|
21
21
|
# todo; refactor all this python compatibility into the python_3_8 class
|
22
22
|
if sys.version_info < (3, 8): # pragma: no cover
|
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v2.
|
1
|
+
v2.87.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.87.0
|
4
4
|
Summary: OWASP Security Bot - Utils
|
5
5
|
License: MIT
|
6
6
|
Author: Dinis Cruz
|
@@ -21,7 +21,7 @@ Description-Content-Type: text/markdown
|
|
21
21
|
|
22
22
|
# OSBot-Utils
|
23
23
|
|
24
|
-

|
25
25
|

|
26
26
|

|
27
27
|

|
@@ -349,7 +349,7 @@ osbot_utils/testing/performance/models/Model__Performance_Measure__Result.py,sha
|
|
349
349
|
osbot_utils/testing/performance/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
350
350
|
osbot_utils/testing/test_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
351
351
|
osbot_utils/testing/test_data/const__test__data__html.py,sha256=_DmA7OoCwvl1xxxn2aS8mfvf3Ct4bOt1KTUyTDqtwaQ,1718
|
352
|
-
osbot_utils/type_safe/Type_Safe.py,sha256=
|
352
|
+
osbot_utils/type_safe/Type_Safe.py,sha256=WrsGJgD4iEoKN8z-ZU6RB78QcloLVxck-CB83f44yJw,6398
|
353
353
|
osbot_utils/type_safe/Type_Safe__Base.py,sha256=cui8fIzUGaPsb-fnANj8nw9cYrVikdx1XZ8in3Y_-QU,9174
|
354
354
|
osbot_utils/type_safe/Type_Safe__Primitive.py,sha256=Eufm1CSenInqW8gAgULhUAXV_lMmA4UY4A5U9v8qmnU,4135
|
355
355
|
osbot_utils/type_safe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -394,7 +394,7 @@ osbot_utils/type_safe/primitives/safe_str/http/Safe_Str__Http__Text.py,sha256=mi
|
|
394
394
|
osbot_utils/type_safe/primitives/safe_str/http/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
395
395
|
osbot_utils/type_safe/primitives/safe_str/identifiers/Guid.py,sha256=-WeQzrNj98ay-8rWCBuM-FnhccmygDzZKW1LZ0Frm3M,945
|
396
396
|
osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid.py,sha256=86xnlevsiitCzFB-VjjBmXXV14pbcKd67YWEDsYTCFk,483
|
397
|
-
osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid_Short.py,sha256=
|
397
|
+
osbot_utils/type_safe/primitives/safe_str/identifiers/Random_Guid_Short.py,sha256=cXye_Bo5cco24FOyXwyN0qotXHc-X4-eQ-ZgOaQrocE,496
|
398
398
|
osbot_utils/type_safe/primitives/safe_str/identifiers/Safe_Id.py,sha256=Mj66QVcEHqUKDFb0cdl7cbMOlQKxfFuRxnupmKo6UG8,696
|
399
399
|
osbot_utils/type_safe/primitives/safe_str/identifiers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
400
400
|
osbot_utils/type_safe/primitives/safe_str/text/Safe_Str__Text.py,sha256=95E4ALhah2AEfL-m5JB7XpUOkyxQ0lJQM139RPQJjv4,327
|
@@ -411,9 +411,9 @@ osbot_utils/type_safe/primitives/safe_uint/Safe_UInt__Percentage.py,sha256=MKD2A
|
|
411
411
|
osbot_utils/type_safe/primitives/safe_uint/Safe_UInt__Port.py,sha256=gcqi3UaWaFNSktqUTrfdgRKVI5JKWnqxcpi5FlX75J0,496
|
412
412
|
osbot_utils/type_safe/primitives/safe_uint/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
413
413
|
osbot_utils/type_safe/type_safe_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
414
|
-
osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Dict.py,sha256=
|
414
|
+
osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Dict.py,sha256=1heFE2F7kLUNOKFMZ2eG7DMidcogsaf6dDruHLFGOr4,3734
|
415
415
|
osbot_utils/type_safe/type_safe_core/collections/Type_Safe__List.py,sha256=os5dOU7iKnjKoWt00SLj0Wy_X1RL2iGEErsYvg04tto,2719
|
416
|
-
osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Set.py,sha256=
|
416
|
+
osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Set.py,sha256=jbKLz5Kqo527JWY5Xa4k1c7wqonNz8BYXw22b2O2ov4,2580
|
417
417
|
osbot_utils/type_safe/type_safe_core/collections/Type_Safe__Tuple.py,sha256=MEUHVwPDVqPmnZsvxwAhQAQY9JwFsMe2R42z4tWKRN4,3445
|
418
418
|
osbot_utils/type_safe/type_safe_core/collections/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
419
419
|
osbot_utils/type_safe/type_safe_core/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -434,7 +434,7 @@ osbot_utils/type_safe/type_safe_core/shared/__init__.py,sha256=47DEQpj8HBSa-_TIm
|
|
434
434
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Class_Kwargs.py,sha256=BbMPfCv5-RUZzh-TbyLBvykXZkdkR91jCGJoZ4R697g,8237
|
435
435
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Default_Kwargs.py,sha256=tzKXDUc0HVP5QvCWsmcPuuZodNvQZ9FeMDNI2x00Ngw,1943
|
436
436
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Default_Value.py,sha256=mRu0yV3w7Ch1H8SOfXMRqMBp3ooY95yR_oni7JafJBc,4603
|
437
|
-
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__From_Json.py,sha256=
|
437
|
+
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__From_Json.py,sha256=QDVf-cN7aK8_xYdkHS74seSrMYyhurd_MEzgTlUyStg,15712
|
438
438
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Init.py,sha256=lZpQCCTNt6JcqyWwDoj-9Zgrq10vHXIUBh9lx37vRkE,4990
|
439
439
|
osbot_utils/type_safe/type_safe_core/steps/Type_Safe__Step__Set_Attr.py,sha256=ywUYo97jcZkHZ7BJ7GTTuici2obz-Nwch4TcM6ilDcY,9237
|
440
440
|
osbot_utils/type_safe/type_safe_core/steps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -470,8 +470,8 @@ osbot_utils/utils/Toml.py,sha256=grjWkVPIMVkawJ499FVIJKxQp8FJ2wcsd0Z3YIR4drM,114
|
|
470
470
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
471
471
|
osbot_utils/utils/Zip.py,sha256=mG42lgTY0tnm14T3P1-DSAIZKkTiYoO3odZ1aOUdc1I,14394
|
472
472
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
473
|
-
osbot_utils/version,sha256=
|
474
|
-
osbot_utils-2.
|
475
|
-
osbot_utils-2.
|
476
|
-
osbot_utils-2.
|
477
|
-
osbot_utils-2.
|
473
|
+
osbot_utils/version,sha256=XwHyoJ_wFA2bjrNtuxOF4NM6cnDdMz3jajvwUly7V7w,8
|
474
|
+
osbot_utils-2.87.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
475
|
+
osbot_utils-2.87.0.dist-info/METADATA,sha256=f7H-pt4SZ5tPhp3S_3fP5LXkSbiQnibM-NL8NbIzcVw,7918
|
476
|
+
osbot_utils-2.87.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
477
|
+
osbot_utils-2.87.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|