osbot-utils 1.66.0__py3-none-any.whl → 1.68.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/base_classes/Type_Safe.py +1 -1
- osbot_utils/helpers/Random_Guid.py +0 -2
- osbot_utils/utils/Http.py +22 -3
- osbot_utils/utils/Objects.py +2 -0
- osbot_utils/utils/Toml.py +9 -3
- osbot_utils/version +1 -1
- {osbot_utils-1.66.0.dist-info → osbot_utils-1.68.0.dist-info}/METADATA +2 -2
- {osbot_utils-1.66.0.dist-info → osbot_utils-1.68.0.dist-info}/RECORD +10 -10
- {osbot_utils-1.66.0.dist-info → osbot_utils-1.68.0.dist-info}/LICENSE +0 -0
- {osbot_utils-1.66.0.dist-info → osbot_utils-1.68.0.dist-info}/WHEEL +0 -0
@@ -16,7 +16,7 @@ from osbot_utils.helpers.Timestamp_Now import Timestamp_Now
|
|
16
16
|
from osbot_utils.utils.Dev import pprint
|
17
17
|
from osbot_utils.utils.Json import json_parse
|
18
18
|
from osbot_utils.utils.Misc import list_set
|
19
|
-
from osbot_utils.utils.Objects
|
19
|
+
from osbot_utils.utils.Objects import default_value, value_type_matches_obj_annotation_for_attr, \
|
20
20
|
raise_exception_on_obj_type_annotation_mismatch, obj_is_attribute_annotation_of_type, enum_from_value, \
|
21
21
|
obj_is_type_union_compatible, value_type_matches_obj_annotation_for_union_attr, \
|
22
22
|
convert_dict_to_value_from_obj_annotation, dict_to_obj, convert_to_value_from_obj_annotation
|
osbot_utils/utils/Http.py
CHANGED
@@ -4,9 +4,10 @@ import re
|
|
4
4
|
import socket
|
5
5
|
import ssl
|
6
6
|
import unicodedata
|
7
|
-
from
|
8
|
-
from
|
9
|
-
from
|
7
|
+
from http.cookies import SimpleCookie
|
8
|
+
from time import sleep
|
9
|
+
from urllib.parse import quote, urljoin, urlparse, urlunparse
|
10
|
+
from urllib.request import Request, urlopen
|
10
11
|
|
11
12
|
from osbot_utils.utils.Str import html_decode
|
12
13
|
|
@@ -78,6 +79,24 @@ def http_request(url, data=None, headers=None, method='GET', encoding ='utf-8',
|
|
78
79
|
return result.decode(encoding)
|
79
80
|
return result
|
80
81
|
|
82
|
+
|
83
|
+
def parse_cookies(cookie_header, include_empty=True):
|
84
|
+
cookie = SimpleCookie()
|
85
|
+
cookie.load(cookie_header)
|
86
|
+
parsed_cookies = {}
|
87
|
+
for key, morsel in cookie.items():
|
88
|
+
cookie_attrs = {"value": morsel.value}
|
89
|
+
for attr, value in morsel.items():
|
90
|
+
if attr.lower() in ["secure", "httponly"]:
|
91
|
+
cookie_attrs[attr] = (value == True)
|
92
|
+
else:
|
93
|
+
if value or include_empty:
|
94
|
+
cookie_attrs[attr] = value.strip(', ') # we need to strip for the cases when there are multiple cookies split by , (as seen in FastAPI Test Client)
|
95
|
+
parsed_cookies[key] = cookie_attrs
|
96
|
+
|
97
|
+
return parsed_cookies
|
98
|
+
|
99
|
+
|
81
100
|
def port_is_not_open(port, host='0.0.0.0', timeout=1.0):
|
82
101
|
return port_is_open(port, host,timeout) is False
|
83
102
|
|
osbot_utils/utils/Objects.py
CHANGED
@@ -167,6 +167,8 @@ def obj_to_dict(target):
|
|
167
167
|
return target # Return non-object types as is
|
168
168
|
|
169
169
|
def str_to_obj(target):
|
170
|
+
if hasattr(target, 'json'):
|
171
|
+
return dict_to_obj(target.json())
|
170
172
|
return dict_to_obj(json.loads(target))
|
171
173
|
|
172
174
|
def enum_from_value(enum_type, value):
|
osbot_utils/utils/Toml.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import sys
|
2
|
-
|
3
|
-
from osbot_utils.utils.
|
2
|
+
from osbot_utils.utils.Files import file_create, file_contents
|
3
|
+
from osbot_utils.utils.Objects import dict_to_obj
|
4
4
|
|
5
5
|
if sys.version_info >= (3, 11):
|
6
6
|
import tomllib
|
@@ -43,5 +43,11 @@ def toml_to_dict(str_toml):
|
|
43
43
|
raise NotImplementedError("TOML parsing is not supported in Python versions earlier than 3.11")
|
44
44
|
return tomllib.loads(str_toml)
|
45
45
|
|
46
|
+
def toml_obj_from_file(toml_file):
|
47
|
+
data = toml_dict_from_file(toml_file)
|
48
|
+
return dict_to_obj(data)
|
49
|
+
|
46
50
|
json_load_file = toml_dict_from_file
|
47
|
-
toml_file_load = toml_dict_from_file
|
51
|
+
toml_file_load = toml_dict_from_file
|
52
|
+
toml_load = toml_dict_from_file
|
53
|
+
toml_load_obj = toml_obj_from_file
|
osbot_utils/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
v1.
|
1
|
+
v1.68.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: osbot_utils
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.68.0
|
4
4
|
Summary: OWASP Security Bot - Utils
|
5
5
|
Home-page: https://github.com/owasp-sbot/OSBot-Utils
|
6
6
|
License: MIT
|
@@ -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
|
|
@@ -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=
|
5
|
+
osbot_utils/base_classes/Type_Safe.py,sha256=7gB1vNKkM-CNXTlFV_BCqX-HACsu7Lu4vEgenKYPRMY,18806
|
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
|
@@ -65,7 +65,7 @@ osbot_utils/helpers/Local_Cache.py,sha256=0JZZX3fFImcwtbBvxAQl-EbBegSNJRhRMYF6ov
|
|
65
65
|
osbot_utils/helpers/Local_Caches.py,sha256=aQmi1HSM0TH6WQPedG2fbz4KCCJ3DQTU9d18rB1jR0M,1885
|
66
66
|
osbot_utils/helpers/Print_Table.py,sha256=LEXbyqGg_6WSraI4cob4bNNSu18ddqvALp1zGK7bPhs,19126
|
67
67
|
osbot_utils/helpers/Python_Audit.py,sha256=shpZlluJwqJBAlad6xN01FkgC1TsQ48RLvR5ZjmrKa4,1539
|
68
|
-
osbot_utils/helpers/Random_Guid.py,sha256=
|
68
|
+
osbot_utils/helpers/Random_Guid.py,sha256=hBBcjetZMYgdagWbkS1j7AYAQ5k6JFbDpbPBi9gTj1A,373
|
69
69
|
osbot_utils/helpers/Random_Guid_Short.py,sha256=YP_k5OLuYvXWGU2OEnQHk_OGViBQofTWKm3pUdQaJao,404
|
70
70
|
osbot_utils/helpers/Random_Seed.py,sha256=14btja8LDN9cMGWaz4fCNcMRU_eyx49gas-_PQvHgy4,634
|
71
71
|
osbot_utils/helpers/Timestamp_Now.py,sha256=Vmdsm-pgvxkkQ_Qj_9Watr8rXXSvc-aBxWMPFGQx8Z0,371
|
@@ -287,13 +287,13 @@ osbot_utils/utils/Env.py,sha256=XMwF5BrtpoPJdOraswAFPrcQ3tRTocjqvA8I61eOCJw,5741
|
|
287
287
|
osbot_utils/utils/Exceptions.py,sha256=KyOUHkXQ_6jDTq04Xm261dbEZuRidtsM4dgzNwSG8-8,389
|
288
288
|
osbot_utils/utils/Files.py,sha256=7fdqbfFyo6Ow5Repi_dZAzHqGb0XYh6tDALYAy42pBY,22522
|
289
289
|
osbot_utils/utils/Functions.py,sha256=0E6alPJ0fJpBiJgFOWooCOi265wSRyxxXAJ5CELBnso,3498
|
290
|
-
osbot_utils/utils/Http.py,sha256=
|
290
|
+
osbot_utils/utils/Http.py,sha256=Cm_-b2EgxKoQJ47ThZp-dgHCdeGv4UcCNLfTOH94-7s,7790
|
291
291
|
osbot_utils/utils/Int.py,sha256=PmlUdU4lSwf4gJdmTVdqclulkEp7KPCVUDO6AcISMF4,116
|
292
292
|
osbot_utils/utils/Json.py,sha256=yIT2hUI23gYd24Uf3LCjqPNV67zS46rYZftcCM3jw-Q,6492
|
293
293
|
osbot_utils/utils/Json_Cache.py,sha256=mLPkkDZN-3ZVJiDvV1KBJXILtKkTZ4OepzOsDoBPhWg,2006
|
294
294
|
osbot_utils/utils/Lists.py,sha256=tPz5x5s3sRO97WZ_nsxREBPC5cwaHrhgaYBhsrffTT8,5599
|
295
295
|
osbot_utils/utils/Misc.py,sha256=4MkG2BE1VzZfV4KPzYZ4jVAoUwoA3pTTVPi609ldLGA,16961
|
296
|
-
osbot_utils/utils/Objects.py,sha256=
|
296
|
+
osbot_utils/utils/Objects.py,sha256=6Gdph2A6cv1mVrADLjaCopDQIHxqZf8p1yfnXuDU6iQ,18798
|
297
297
|
osbot_utils/utils/Png.py,sha256=V1juGp6wkpPigMJ8HcxrPDIP4bSwu51oNkLI8YqP76Y,1172
|
298
298
|
osbot_utils/utils/Process.py,sha256=lr3CTiEkN3EiBx3ZmzYmTKlQoPdkgZBRjPulMxG-zdo,2357
|
299
299
|
osbot_utils/utils/Python_Logger.py,sha256=tx8N6wRKL3RDHboDRKZn8SirSJdSAE9cACyJkxrThZ8,12792
|
@@ -301,12 +301,12 @@ osbot_utils/utils/Regex.py,sha256=0ubgp8HKsS3PNe2H6XlzMIcUuV7jhga3VkQVDNOJWuA,86
|
|
301
301
|
osbot_utils/utils/Status.py,sha256=Yq4s0TelXgn0i2QjCP9V8mP30GabXp_UL-jjM6Iwiw4,4305
|
302
302
|
osbot_utils/utils/Str.py,sha256=kxdY8ROX4FdJtCaMTfOc8fK_xcDICprNkefHu2MMNU4,2585
|
303
303
|
osbot_utils/utils/Threads.py,sha256=lnh4doZWYUIoWBZRU_780QPeAIKGDh7INuqmU8Fzmdc,3042
|
304
|
-
osbot_utils/utils/Toml.py,sha256
|
304
|
+
osbot_utils/utils/Toml.py,sha256=-_Yv5T8ZhGGoDSSoNEdFhSsXiK_JPjGkPijm4JoeHSk,1669
|
305
305
|
osbot_utils/utils/Version.py,sha256=Ww6ChwTxqp1QAcxOnztkTicShlcx6fbNsWX5xausHrg,422
|
306
306
|
osbot_utils/utils/Zip.py,sha256=G6Hk_hDcm9yvWzhTKzhT0R_6f0NBIAchHqMxGb3kfh4,14037
|
307
307
|
osbot_utils/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
308
|
-
osbot_utils/version,sha256=
|
309
|
-
osbot_utils-1.
|
310
|
-
osbot_utils-1.
|
311
|
-
osbot_utils-1.
|
312
|
-
osbot_utils-1.
|
308
|
+
osbot_utils/version,sha256=lOa1cqmJZag742z9JQnsjouTwB_HoLgro5epV0jmwxk,8
|
309
|
+
osbot_utils-1.68.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
310
|
+
osbot_utils-1.68.0.dist-info/METADATA,sha256=oWpZsCTtpvZQb53NbpSnbBpxkfy2gLzH0uTqf5ES0N8,1317
|
311
|
+
osbot_utils-1.68.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
312
|
+
osbot_utils-1.68.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|