osbot-utils 2.17.0__py3-none-any.whl → 2.19.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.
@@ -2,17 +2,17 @@ import asyncio
2
2
  import logging
3
3
  import typing
4
4
 
5
- from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
6
- from osbot_utils.type_safe.Type_Safe import Type_Safe
7
- from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_magenta, f_bold
8
- from osbot_utils.helpers.flows.models.Flow_Run__Config import Flow_Run__Config
9
- from osbot_utils.helpers.flows.Flow__Events import flow_events
10
- from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
11
- from osbot_utils.testing.Stdout import Stdout
12
- from osbot_utils.utils.Misc import random_id, lower, time_now
13
- from osbot_utils.utils.Python_Logger import Python_Logger
14
- from osbot_utils.utils.Str import ansis_to_texts
15
- from osbot_utils.utils.Threads import invoke_in_new_event_loop
5
+ from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
6
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
7
+ from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_magenta, f_bold
8
+ from osbot_utils.helpers.flows.models.Flow_Run__Config import Flow_Run__Config
9
+ from osbot_utils.helpers.flows.Flow__Events import flow_events
10
+ from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
11
+ from osbot_utils.testing.Stdout import Stdout
12
+ from osbot_utils.utils.Misc import random_id, lower, time_now
13
+ from osbot_utils.utils.Python_Logger import Python_Logger
14
+ from osbot_utils.utils.Str import ansis_to_texts
15
+ from osbot_utils.utils.Threads import invoke_in_new_event_loop
16
16
 
17
17
  FLOW__RANDOM_ID__PREFIX = 'flow_id__'
18
18
  FLOW__RANDOM_NAME__PREFIX = 'flow_name__'
@@ -20,7 +20,7 @@ FLOW__LOGGING__LOG_FORMAT = '%(asctime)s.%(msecs)03d | %(levelname)-8s | %(mess
20
20
  FLOW__LOGGING__DATE_FORMAT = '%H:%M:%S'
21
21
 
22
22
 
23
-
23
+ # todo: add flow duration
24
24
  class Flow(Type_Safe):
25
25
  captured_exec_logs : list
26
26
  data : dict # dict available to the tasks to add and collect data
@@ -1,18 +1,19 @@
1
- import asyncio
2
1
  import inspect
3
2
  import typing
4
3
 
5
- from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
6
- from osbot_utils.utils.Misc import random_id, lower
7
- from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
8
- from osbot_utils.helpers.flows.Flow__Events import flow_events
9
- from osbot_utils.testing.Stdout import Stdout
10
- from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_red, f_blue, f_bold
11
- from osbot_utils.type_safe.Type_Safe import Type_Safe
12
- from osbot_utils.helpers.flows.Flow import Flow
4
+ from osbot_utils.helpers.flows.models.Flow_Run__Event_Data import Flow_Run__Event_Data
5
+ from osbot_utils.utils.Misc import random_id, lower
6
+ from osbot_utils.helpers.Dependency_Manager import Dependency_Manager
7
+ from osbot_utils.helpers.flows.Flow__Events import flow_events
8
+ from osbot_utils.testing.Stdout import Stdout
9
+ from osbot_utils.helpers.CFormat import CFormat, f_dark_grey, f_red, f_blue, f_bold
10
+ from osbot_utils.type_safe.Type_Safe import Type_Safe
11
+ from osbot_utils.helpers.flows.Flow import Flow
13
12
 
14
13
  TASK__RANDOM_ID__PREFIX = 'task_id__'
15
14
 
15
+ # todo: add task duration
16
+
16
17
  class Task(Type_Safe):
17
18
  data : dict # dict available to the task to add and collect data
18
19
  task_id : str
@@ -58,11 +58,12 @@ class RSS__Feed__Parser:
58
58
  # Process channel image if present
59
59
  if 'image' in channel_data:
60
60
  img_data = channel_data['image']
61
- channel.image = RSS__Image( url = img_data.get('url' , '' ),
62
- title = img_data.get('title' , '' ),
63
- link = img_data.get('link' , '' ),
64
- width = int(img_data.get('width' , 0 )),
65
- height = int(img_data.get('height', 0 )))
61
+ if img_data:
62
+ channel.image = RSS__Image( url = img_data.get('url' , '' ),
63
+ title = img_data.get('title' , '' ),
64
+ link = img_data.get('link' , '' ),
65
+ width = int(img_data.get('width' , 0 )),
66
+ height = int(img_data.get('height', 0 )))
66
67
 
67
68
  known_channel_fields = {'title', 'link', 'description', 'language', # Move non-standard channel elements to extensions
68
69
  'lastBuildDate', 'image', 'item', 'updateFrequency', 'updatePeriod'}
@@ -29,4 +29,9 @@ class Type_Safe__Set(Type_Safe__Base, set):
29
29
  result.append({k: v.json() if isinstance(v, Type_Safe) else v for k, v in item.items()})
30
30
  else:
31
31
  result.append(item)
32
- return result
32
+ return result
33
+
34
+ def __eq__(self, other): # todo: see if this is needed
35
+ if isinstance(other, (set, Type_Safe__Set)):
36
+ return set(self) == set(other)
37
+ return False
@@ -2,6 +2,7 @@ import sys
2
2
  import types
3
3
  from decimal import Decimal
4
4
  from enum import EnumMeta
5
+ from osbot_utils.helpers.Obj_Id import Obj_Id
5
6
  from osbot_utils.type_safe.Type_Safe import Type_Safe
6
7
  from osbot_utils.type_safe.Type_Safe__List import Type_Safe__List
7
8
  from osbot_utils.helpers.Random_Guid import Random_Guid
@@ -100,8 +101,10 @@ class Type_Safe__Step__From_Json:
100
101
  value = Random_Guid(value)
101
102
  elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Random_Guid_Short): # handle Random_Guid_Short
102
103
  value = Random_Guid_Short(value)
103
- elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Timestamp_Now): # handle Timestamp_Now
104
+ elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Timestamp_Now ): # handle Timestamp_Now
104
105
  value = Timestamp_Now(value)
106
+ elif type_safe_annotations.obj_is_attribute_annotation_of_type(_self, key, Obj_Id ): # handle Obj_Id
107
+ value = Obj_Id(value)
105
108
 
106
109
  setattr(_self, key, value) # Direct assignment for primitive types and other structures
107
110
 
osbot_utils/utils/Json.py CHANGED
@@ -1,3 +1,5 @@
1
+ from typing import Any
2
+
1
3
 
2
4
  def bytes_to_json_loads(data):
3
5
  import json
@@ -21,6 +23,38 @@ def json_dumps(python_object, indent=4, pretty=True, sort_keys=False, default=st
21
23
  def json_dumps_to_bytes(*args, **kwargs):
22
24
  return json_dumps(*args, **kwargs).encode()
23
25
 
26
+ def json__type_key(obj: Any) -> tuple:
27
+ if obj is None : return (0, None)
28
+ if isinstance(obj, bool) : return (1, obj)
29
+ if isinstance(obj, int) : return (2, obj)
30
+ if isinstance(obj, float) : return (3, obj)
31
+ if isinstance(obj, str) : return (4, obj)
32
+ if isinstance(obj, (list, set, tuple)): return (5, tuple(sorted(json__type_key(x) for x in obj)))
33
+ if isinstance(obj, dict) : return (6, tuple(sorted((k, json__type_key(v)) for k,v in obj.items())))
34
+ return (7, str(obj)) # Fallback for unknown types
35
+
36
+ def json__equals__list_and_set(value_1: Any, value_2: Any) -> bool:
37
+ if isinstance(value_1, (list, set)) or isinstance(value_2, (list, set)):
38
+ list_1 = list(value_1)
39
+ list_2 = list(value_2)
40
+
41
+ if len(list_1) != len(list_2): # Quick length check
42
+ return False
43
+
44
+ sorted_1 = sorted(list_1, key=json__type_key)
45
+ sorted_2 = sorted(list_2, key=json__type_key)
46
+
47
+ return all(json__equals__list_and_set(a, b)
48
+ for a, b in zip(sorted_1, sorted_2))
49
+
50
+ if isinstance(value_1, dict) and isinstance(value_2, dict):
51
+ if value_1.keys() != value_2.keys(): # Check keys match
52
+ return False
53
+ return all(json__equals__list_and_set(value_1[key], value_2[key]) # Recursively compare values
54
+ for key in value_1.keys())
55
+
56
+ return value_1 == value_2
57
+
24
58
  def json_lines_file_load(target_path):
25
59
  from osbot_utils.utils.Files import file_lines
26
60
 
osbot_utils/version CHANGED
@@ -1 +1 @@
1
- v2.17.0
1
+ v2.19.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: osbot_utils
3
- Version: 2.17.0
3
+ Version: 2.19.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.17.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v2.19.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,9 +136,9 @@ 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=V4yVmnXB4oFwq3UtGF_7SPU5PmvNlowcQnqwAArP828,10962
139
+ osbot_utils/helpers/flows/Flow.py,sha256=75Ld9rYHpKIPGFpAexg3oKdBslonkjf9KlUGwyJuzgQ,11059
140
140
  osbot_utils/helpers/flows/Flow__Events.py,sha256=g7KBafFeA7tV-v31v_m3MT__cZEX63gh8CehnZwRYU0,2840
141
- osbot_utils/helpers/flows/Task.py,sha256=tnO1q4nNnWYmcb66tMcKCOIgipAV-TCNO4xEtrnGDBc,5333
141
+ osbot_utils/helpers/flows/Task.py,sha256=VUDTz8zy5fSMSWdwAJXpuE0ewdhYSNMAgFyEKXpTIpI,5461
142
142
  osbot_utils/helpers/flows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
143
143
  osbot_utils/helpers/flows/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
144
144
  osbot_utils/helpers/flows/decorators/flow.py,sha256=7wj5TtUO_ffbACnagZtZ6LfFgclmbQSfn2lKkMMrnJI,670
@@ -253,7 +253,7 @@ osbot_utils/helpers/xml/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
253
253
  osbot_utils/helpers/xml/rss/RSS__Channel.py,sha256=BpkP4OMV_H6usvXhdQ8ahJFxYbtwfkRuoP37_gcIP-A,605
254
254
  osbot_utils/helpers/xml/rss/RSS__Enclosure.py,sha256=9lUsIVJ4TkR_mBFDc6-ISMg7fPXe8FiKFSWjpnlWIMY,139
255
255
  osbot_utils/helpers/xml/rss/RSS__Feed.py,sha256=W4T2rmJoZr4kfOPSkZXkkKPnOk5bPlZfLzOf7pah9LQ,422
256
- osbot_utils/helpers/xml/rss/RSS__Feed__Parser.py,sha256=7sub6zcWqGz8FORXFYRyopTswboUkCU5uGEXAZ6BZDw,5380
256
+ osbot_utils/helpers/xml/rss/RSS__Feed__Parser.py,sha256=1pFzZeN50bUNW-w7p9cDXiwezkqVyx9BvSS2bGXfnVc,5425
257
257
  osbot_utils/helpers/xml/rss/RSS__Image.py,sha256=13k8K03VTZbP0efeDL07oZF7Lg0CQccXBd1Qk965mHY,168
258
258
  osbot_utils/helpers/xml/rss/RSS__Item.py,sha256=K6YF3EVUu6E-_ISke98QXgnJlfOI5YAIO4pBzUZq7gE,608
259
259
  osbot_utils/testing/Catch.py,sha256=HdNoKnrPBjvVj87XYN-Wa1zpo5z3oByURT6TKbd5QpQ,2229
@@ -288,7 +288,7 @@ osbot_utils/type_safe/Type_Safe__Base.py,sha256=Bzrh8TxFglB0FEUAQTlgovlnFHnBN4lO
288
288
  osbot_utils/type_safe/Type_Safe__Dict.py,sha256=vE_Ut7MabBjOq5Hpr3vdFO5RNf-M-cL83S76CvxD-9g,2488
289
289
  osbot_utils/type_safe/Type_Safe__List.py,sha256=SzSIBkwSOAEpW_V2qh4-f0YHzmgB0T8PczBLbDgZGvg,1340
290
290
  osbot_utils/type_safe/Type_Safe__Method.py,sha256=LOG2sqQyKBNNEiJxk_jngH6IWvpyVueouAzNTlj-_pY,12676
291
- osbot_utils/type_safe/Type_Safe__Set.py,sha256=hNpAokK9nldwAXVDarJ3DXdf8sDrxog7GOMwciPLxg0,1216
291
+ osbot_utils/type_safe/Type_Safe__Set.py,sha256=j12fc8cbd9-s_a13ysaz723rNEW4Dt6hObCd0S-AjIg,1432
292
292
  osbot_utils/type_safe/Type_Safe__Tuple.py,sha256=A7CuAy_Hz1iUMSojumReOG-OwPQqEO7MSiCHL2sJRKU,1709
293
293
  osbot_utils/type_safe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
294
294
  osbot_utils/type_safe/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -306,7 +306,7 @@ osbot_utils/type_safe/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
306
306
  osbot_utils/type_safe/steps/Type_Safe__Step__Class_Kwargs.py,sha256=snoyJKvZ1crgF2fp0zexwNPnV_E63RfyRIsMAZdrKNY,6995
307
307
  osbot_utils/type_safe/steps/Type_Safe__Step__Default_Kwargs.py,sha256=tzKXDUc0HVP5QvCWsmcPuuZodNvQZ9FeMDNI2x00Ngw,1943
308
308
  osbot_utils/type_safe/steps/Type_Safe__Step__Default_Value.py,sha256=K_tkVQyLUbbWYzDnzoPLCgDBAFYyUjAG4VdLsvjzL1g,4485
309
- osbot_utils/type_safe/steps/Type_Safe__Step__From_Json.py,sha256=BO1WNfudAP9PqyXQZkRDTldeL2InxHhgU_6q_27MH3M,11890
309
+ osbot_utils/type_safe/steps/Type_Safe__Step__From_Json.py,sha256=VAIZNqsmkBFta-mW8JzhKJpxG0i1G1boj3cZlbKToms,12154
310
310
  osbot_utils/type_safe/steps/Type_Safe__Step__Init.py,sha256=v4FD7zxQiOFLiOF1Ma8wZMP8aLgRlXwJZnsIfBu2zeg,1266
311
311
  osbot_utils/type_safe/steps/Type_Safe__Step__Set_Attr.py,sha256=VuKHH9QEYlbAL9R4zwQ5dwexx2sFY6wMx52QmF7eqcg,5219
312
312
  osbot_utils/type_safe/steps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -326,7 +326,7 @@ osbot_utils/utils/Files.py,sha256=yxteAcyhDcUy1_r9Eihx80V16lV_UAE6cvoOe2Dc7DU,23
326
326
  osbot_utils/utils/Functions.py,sha256=0E6alPJ0fJpBiJgFOWooCOi265wSRyxxXAJ5CELBnso,3498
327
327
  osbot_utils/utils/Http.py,sha256=Cm_-b2EgxKoQJ47ThZp-dgHCdeGv4UcCNLfTOH94-7s,7790
328
328
  osbot_utils/utils/Int.py,sha256=PmlUdU4lSwf4gJdmTVdqclulkEp7KPCVUDO6AcISMF4,116
329
- osbot_utils/utils/Json.py,sha256=Ux9lXFAjr51etPpzG3J4phlTnY78_4iA-l0uphWTCEY,7183
329
+ osbot_utils/utils/Json.py,sha256=TvfDoXwOkWzWH-9KMnme5C7iFsMZOleAeue92qmkH6g,8831
330
330
  osbot_utils/utils/Json_Cache.py,sha256=mLPkkDZN-3ZVJiDvV1KBJXILtKkTZ4OepzOsDoBPhWg,2006
331
331
  osbot_utils/utils/Lists.py,sha256=tPz5x5s3sRO97WZ_nsxREBPC5cwaHrhgaYBhsrffTT8,5599
332
332
  osbot_utils/utils/Misc.py,sha256=H_xexJgiTxB3jDeDiW8efGQbO0Zuy8MM0iQ7qXC92JI,17363
@@ -342,8 +342,8 @@ osbot_utils/utils/Toml.py,sha256=Rxl8gx7mni5CvBAK-Ai02EKw-GwtJdd3yeHT2kMloik,166
342
342
  osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
343
343
  osbot_utils/utils/Zip.py,sha256=pR6sKliUY0KZXmqNzKY2frfW-YVQEVbLKiyqQX_lc-8,14052
344
344
  osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
345
- osbot_utils/version,sha256=ZHBqd_qW1PoBoW3OWG9plgM2aZqI6Nk0w_6jIgeVD8k,8
346
- osbot_utils-2.17.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
347
- osbot_utils-2.17.0.dist-info/METADATA,sha256=tErQvlAQMNNnFWmAWdtStwvyVOhF2kNJveDfuEPTWsI,1329
348
- osbot_utils-2.17.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
349
- osbot_utils-2.17.0.dist-info/RECORD,,
345
+ osbot_utils/version,sha256=hbeqtbi8RIMokGpKAmMqNAICgvpA3Y-S_xwhTeV3xe4,8
346
+ osbot_utils-2.19.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
347
+ osbot_utils-2.19.0.dist-info/METADATA,sha256=WYQTD91KhagCwgDDzjbB32ljZa4yP_UIZDz2UIthUZ4,1329
348
+ osbot_utils-2.19.0.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
349
+ osbot_utils-2.19.0.dist-info/RECORD,,