osbot-utils 1.67.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.
@@ -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 import default_value, value_type_matches_obj_annotation_for_attr, \
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 time import sleep
8
- from urllib.parse import quote, urljoin, urlparse, urlunparse
9
- from urllib.request import Request, urlopen
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/Toml.py CHANGED
@@ -1,6 +1,6 @@
1
1
  import sys
2
-
3
- from osbot_utils.utils.Files import file_create, file_contents
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.67.0
1
+ v1.68.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: osbot_utils
3
- Version: 1.67.0
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
- ![Current Release](https://img.shields.io/badge/release-v1.67.0-blue)
26
+ ![Current Release](https://img.shields.io/badge/release-v1.68.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
 
@@ -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=N1RMyDEA9YFI5MciixobxM0ZjbEQpPtj8XzmzTrPTls,18789
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
@@ -287,7 +287,7 @@ 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=vFvD-xLkkXLTJvmYGourMLoUOfkZx_KBSLmo1RX73jM,7043
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
@@ -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=SD6IA4-mrtoBXcI0dIGKV9POMQNd6WYKvmDQq7GQ6ZQ,1438
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=zEYoXcLqYMMeBwLqI0fFRz3qocsd0oEVjcyEHe-v6Hs,8
309
- osbot_utils-1.67.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
310
- osbot_utils-1.67.0.dist-info/METADATA,sha256=vuHI4ctcabSC0_5MA-3_NoSvc8Bd8TNXRoZoutsRYCk,1317
311
- osbot_utils-1.67.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
312
- osbot_utils-1.67.0.dist-info/RECORD,,
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,,