osbot-utils 2.18.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.
- osbot_utils/helpers/xml/rss/RSS__Feed__Parser.py +6 -5
- osbot_utils/type_safe/Type_Safe__Set.py +6 -1
- osbot_utils/utils/Json.py +34 -0
- osbot_utils/version +1 -1
- {osbot_utils-2.18.0.dist-info → osbot_utils-2.19.0.dist-info}/METADATA +2 -2
- {osbot_utils-2.18.0.dist-info → osbot_utils-2.19.0.dist-info}/RECORD +8 -8
- {osbot_utils-2.18.0.dist-info → osbot_utils-2.19.0.dist-info}/LICENSE +0 -0
- {osbot_utils-2.18.0.dist-info → osbot_utils-2.19.0.dist-info}/WHEEL +0 -0
@@ -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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
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.
|
1
|
+
v2.19.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 2.
|
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
|
-

|
27
27
|
[](https://codecov.io/gh/owasp-sbot/OSBot-Utils)
|
28
28
|
|
29
29
|
|
@@ -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=
|
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=
|
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
|
@@ -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=
|
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=
|
346
|
-
osbot_utils-2.
|
347
|
-
osbot_utils-2.
|
348
|
-
osbot_utils-2.
|
349
|
-
osbot_utils-2.
|
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,,
|
File without changes
|
File without changes
|