osbot-utils 2.26.0__py3-none-any.whl → 2.28.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.
@@ -11,6 +11,7 @@ from osbot_utils.helpers.flows.models.Flow_Run__Config import Flow_Run__Con
11
11
  from osbot_utils.helpers.flows.actions.Flow__Events import flow_events
12
12
  from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
13
13
  from osbot_utils.testing.Stdout import Stdout
14
+ from osbot_utils.utils.Dev import pprint
14
15
  from osbot_utils.utils.Misc import random_id, lower, time_now
15
16
  from osbot_utils.utils.Python_Logger import Python_Logger
16
17
  from osbot_utils.utils.Str import ansis_to_texts
@@ -280,3 +281,6 @@ class Flow(Type_Safe):
280
281
  def json(self) -> typing.Dict[str, typing.Any]: # Convert flow data to JSON
281
282
  return self.flow_data.json()
282
283
 
284
+ def print__flow_data(self):
285
+ pprint(self.flow_data.json())
286
+
@@ -1,4 +1,5 @@
1
1
  import inspect
2
+ import traceback
2
3
  import typing
3
4
 
4
5
  from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
@@ -49,8 +50,10 @@ class Task(Type_Safe):
49
50
  return self.execute__after()
50
51
 
51
52
  def execute__before(self):
52
- self.on_task_start()
53
- self.task_flow = self.find_flow()
53
+ flow_from_stack = self.find_flow()
54
+ if flow_from_stack:
55
+ self.task_flow = flow_from_stack
56
+
54
57
  if self.task_flow is None:
55
58
  raise Exception("No Flow found for Task")
56
59
 
@@ -60,6 +63,7 @@ class Task(Type_Safe):
60
63
  if not self.task_id:
61
64
  self.task_id = self.random_task_id()
62
65
 
66
+ self.on_task_start()
63
67
  flow_events.on__task__start(self.task_event_data())
64
68
 
65
69
  self.task_flow.executed_tasks.append(self)
@@ -87,6 +91,9 @@ class Task(Type_Safe):
87
91
  self.task_return_value = self.task_target(*self.resolved_args, **self.resolved_kwargs)
88
92
  except Exception as error:
89
93
  self.task_error = error
94
+ if self.task_flow.flow_config.print_error_stack_trace:
95
+ tb = traceback.format_exc()
96
+ print(f'{tb}')
90
97
  self.task_flow.log_captured_stdout(stdout)
91
98
 
92
99
  async def execute__task_target__async(self):
@@ -9,6 +9,7 @@ class Flow_Run__Config(Type_Safe):
9
9
  print_logs : bool = False
10
10
  print_none_return_value : bool = False
11
11
  print_finished_message : bool = False
12
+ print_error_stack_trace : bool = False
12
13
  raise_flow_error : bool = True
13
14
  flow_data__capture_events : bool = False
14
15
 
@@ -62,6 +62,10 @@ class Type_Safe:
62
62
  def json(self):
63
63
  return self.serialize_to_dict()
64
64
 
65
+ def json__compress(self): # todo: see if this is the best place to put these Type_Safe__Json_Compressor methods
66
+ from osbot_utils.type_safe.shared.Type_Safe__Json_Compressor import Type_Safe__Json_Compressor
67
+ return Type_Safe__Json_Compressor().compress(self)
68
+
65
69
  # todo: see if we still need this. now that Type_Safe handles base types, there should be no need for this
66
70
  def merge_with(self, target):
67
71
  original_attrs = {k: v for k, v in self.__dict__.items() if k not in target.__dict__} # Store the original attributes of self that should be retained.
@@ -93,7 +97,7 @@ class Type_Safe:
93
97
 
94
98
  return dict_to_obj(self.json())
95
99
 
96
- def serialize_to_dict(self): # todo: see if we need this method or if the .json() is enough
100
+ def serialize_to_dict(self): # todo: see if we need this method or if the .json() is enough
97
101
  return serialize_to_dict(self)
98
102
 
99
103
  def print(self):
@@ -106,4 +110,8 @@ class Type_Safe:
106
110
  from osbot_utils.type_safe.steps.Type_Safe__Step__From_Json import type_safe_step_from_json # circular dependency on Type_Safe
107
111
  return type_safe_step_from_json.from_json(cls, json_data, raise_on_not_found)
108
112
 
109
-
113
+ @classmethod
114
+ def from_json__compressed(cls, json_data): # todo: see if this is the best place to put these Type_Safe__Json_Compressor methods
115
+ from osbot_utils.type_safe.shared.Type_Safe__Json_Compressor import Type_Safe__Json_Compressor
116
+ json_data__decompressed = Type_Safe__Json_Compressor().decompress(json_data)
117
+ return cls.from_json(json_data__decompressed)
@@ -10,12 +10,12 @@ class Type_Safe__Json_Compressor(Type_Safe__Base):
10
10
  def __init__(self):
11
11
  self.type_registry = Type_Safe__Json_Compressor__Type_Registry()
12
12
 
13
- def compress(self, data: dict) -> dict:
14
- if not data:
15
- return data
13
+ def compress(self, obj: Any) -> dict:
14
+ if not obj:
15
+ return obj
16
16
 
17
17
  self.type_registry.clear()
18
- compressed = self.compress_object(data)
18
+ compressed = self.compress_object(obj)
19
19
 
20
20
  if self.type_registry.registry:
21
21
  return { "_type_registry": self.type_registry.reverse,
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.26.0
1
+ v2.28.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: osbot_utils
3
- Version: 2.26.0
3
+ Version: 2.28.0
4
4
  Summary: OWASP Security Bot - Utils
5
5
  License: MIT
6
6
  Author: Dinis Cruz
@@ -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-v2.26.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v2.28.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
 
@@ -136,8 +136,8 @@ osbot_utils/helpers/cache_requests/Cache__Requests__Row.py,sha256=Sb7E_zDB-LPlWI
136
136
  osbot_utils/helpers/cache_requests/Cache__Requests__Table.py,sha256=BW7tXM0TFYma3Db4M-58IKpx0vevLuFsH7QQeiggPaI,388
137
137
  osbot_utils/helpers/cache_requests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
138
138
  osbot_utils/helpers/cache_requests/flows/flow__Cache__Requests.py,sha256=xgx_oExxkcvRwQN1UCobimECIMUKGoIX5oGdCmp8Nyw,243
139
- osbot_utils/helpers/flows/Flow.py,sha256=SjVh8eUjtEgzr7lSfxYzyUmgmRXEqeaT4tJjRiXMLps,13094
140
- osbot_utils/helpers/flows/Task.py,sha256=b9DvSBP2DfDRK7wQ2X0zGBUX6j7XmCMf_IL7_DdJ7GE,6371
139
+ osbot_utils/helpers/flows/Flow.py,sha256=eSqv_pY7vDC1XmX65RyW4swnhQNtMwZXkXnc4De2oc0,13239
140
+ osbot_utils/helpers/flows/Task.py,sha256=AQ69b97woemCZxxBxluV5pqOlBU0KW4OpculC5Ix4nw,6605
141
141
  osbot_utils/helpers/flows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
142
142
  osbot_utils/helpers/flows/actions/Flow__Data.py,sha256=h9h5yVFIK0ZdXukNFgfRVV1XW0YQartVMcJTakwVqKY,5155
143
143
  osbot_utils/helpers/flows/actions/Flow__Events.py,sha256=g7KBafFeA7tV-v31v_m3MT__cZEX63gh8CehnZwRYU0,2840
@@ -145,7 +145,7 @@ osbot_utils/helpers/flows/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
145
145
  osbot_utils/helpers/flows/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
146
146
  osbot_utils/helpers/flows/decorators/flow.py,sha256=7wj5TtUO_ffbACnagZtZ6LfFgclmbQSfn2lKkMMrnJI,670
147
147
  osbot_utils/helpers/flows/decorators/task.py,sha256=Z5GqoUirnm98HAyvRlVcoXLcmZNagXjOXon2kb5OHsY,755
148
- osbot_utils/helpers/flows/models/Flow_Run__Config.py,sha256=vwtUSXEpBd7q9b8KXX1-FDWk90bwnNE1xiLnP3evks0,543
148
+ osbot_utils/helpers/flows/models/Flow_Run__Config.py,sha256=eW7uYZngnmEv1PZOi3sMyJ3jaTlD6S7juzxaDkNO88Y,588
149
149
  osbot_utils/helpers/flows/models/Flow_Run__Event.py,sha256=2E-T6XXvsF2RnbIt5qq0rktOVBpembYvQudhoyM_6vc,589
150
150
  osbot_utils/helpers/flows/models/Flow_Run__Event_Data.py,sha256=zIAhfz1oUs0ocxbfCPmgj8tsXt2Ycjo0nFdeetKlnZ8,400
151
151
  osbot_utils/helpers/flows/models/Flow_Run__Event_Type.py,sha256=4wYRGAtztlhSV6XZa6DIfAAf7ZLp95KOIGU8G1EC4jc,373
@@ -294,7 +294,7 @@ osbot_utils/testing/performance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
294
294
  osbot_utils/testing/performance/models/Model__Performance_Measure__Measurement.py,sha256=xT_uKzbSYo9AGiJgNmCHSt3ApneNNyKh8vsMVN6IJQ0,1127
295
295
  osbot_utils/testing/performance/models/Model__Performance_Measure__Result.py,sha256=k9HJYNLmW6sjRVsfpduSxHFiVANc1zmYtO_Oz9azpW8,755
296
296
  osbot_utils/testing/performance/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
297
- osbot_utils/type_safe/Type_Safe.py,sha256=Yd6s60Ykgke8YuIone-69Ozc4uzEq2fGHu97HTmhydU,5514
297
+ osbot_utils/type_safe/Type_Safe.py,sha256=LOWRGOGpnRU2iTRLP47vUoyalK0vjFrWlnaghBIogWg,6267
298
298
  osbot_utils/type_safe/Type_Safe__Base.py,sha256=Bzrh8TxFglB0FEUAQTlgovlnFHnBN4lOX1Vu327r1Vc,5223
299
299
  osbot_utils/type_safe/Type_Safe__Dict.py,sha256=vE_Ut7MabBjOq5Hpr3vdFO5RNf-M-cL83S76CvxD-9g,2488
300
300
  osbot_utils/type_safe/Type_Safe__List.py,sha256=SzSIBkwSOAEpW_V2qh4-f0YHzmgB0T8PczBLbDgZGvg,1340
@@ -309,7 +309,7 @@ osbot_utils/type_safe/methods/type_safe_property.py,sha256=DcJkOIs6swJtkglsZVKLy
309
309
  osbot_utils/type_safe/shared/Type_Safe__Annotations.py,sha256=nmVqCbhk4kUYrw_mdYqugxQlv4gM3NUUH89FYTHUg-c,1133
310
310
  osbot_utils/type_safe/shared/Type_Safe__Cache.py,sha256=G03pmpds9sTwU5z5pNLssD_GTvVSIR11nGYbkV5KaiY,7913
311
311
  osbot_utils/type_safe/shared/Type_Safe__Convert.py,sha256=mS92_sKjKM_aNSB3ERMEgv-3DtkLVAS8AZF067G-JWM,2995
312
- osbot_utils/type_safe/shared/Type_Safe__Json_Compressor.py,sha256=uAtb2-wYUUsx_E67oqVHCKPaRUMZBRQFyd8xjqziOEA,5431
312
+ osbot_utils/type_safe/shared/Type_Safe__Json_Compressor.py,sha256=TDbot_NNzCPXBQv0l5mksWueJNfxlVFDBGxIH8Jf_XY,5426
313
313
  osbot_utils/type_safe/shared/Type_Safe__Json_Compressor__Type_Registry.py,sha256=wYOCg7F1nTrRn8HlnZvrs_8A8WL4gxRYRLnXZpGIiuk,1119
314
314
  osbot_utils/type_safe/shared/Type_Safe__Not_Cached.py,sha256=25FAl6SOLxdStco_rm9tgOYLfuKyBWheGdl7vVa56UU,800
315
315
  osbot_utils/type_safe/shared/Type_Safe__Raise_Exception.py,sha256=pbru8k8CTQMNUfmFBndiJhg2KkqEYzFvJAPcNZHeHfQ,829
@@ -355,8 +355,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
355
355
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
356
356
  osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
357
357
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
358
- osbot_utils/version,sha256=RZSaVXviZF3y9UfjXr3YrDmllry-euUcFHCuLsyhkPU,8
359
- osbot_utils-2.26.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
360
- osbot_utils-2.26.0.dist-info/METADATA,sha256=mfZ8WcLMiykJ8Sn7KstCiYQmPEw1JCGByBinJ1SQXAU,1329
361
- osbot_utils-2.26.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
362
- osbot_utils-2.26.0.dist-info/RECORD,,
358
+ osbot_utils/version,sha256=UbzDBZPY98UyBryCzA0kKO9CjEdrWfTme6oAH7T38yE,8
359
+ osbot_utils-2.28.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
360
+ osbot_utils-2.28.0.dist-info/METADATA,sha256=-RtnCiZmy4ROrr2I8Fvv2zBvHSLQd9xta4mSlXOb3ks,1329
361
+ osbot_utils-2.28.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
362
+ osbot_utils-2.28.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.0.1
2
+ Generator: poetry-core 2.1.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any