exonware-xwsystem 0.0.1.409__py3-none-any.whl → 0.0.1.411__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.
Files changed (260) hide show
  1. exonware/__init__.py +2 -2
  2. exonware/conf.py +10 -20
  3. exonware/xwsystem/__init__.py +6 -16
  4. exonware/xwsystem/caching/__init__.py +1 -1
  5. exonware/xwsystem/caching/base.py +16 -16
  6. exonware/xwsystem/caching/bloom_cache.py +5 -5
  7. exonware/xwsystem/caching/cache_manager.py +2 -2
  8. exonware/xwsystem/caching/conditional.py +4 -4
  9. exonware/xwsystem/caching/contracts.py +12 -12
  10. exonware/xwsystem/caching/decorators.py +2 -2
  11. exonware/xwsystem/caching/defs.py +1 -1
  12. exonware/xwsystem/caching/disk_cache.py +4 -4
  13. exonware/xwsystem/caching/distributed.py +1 -1
  14. exonware/xwsystem/caching/errors.py +1 -1
  15. exonware/xwsystem/caching/events.py +8 -8
  16. exonware/xwsystem/caching/eviction_strategies.py +9 -9
  17. exonware/xwsystem/caching/fluent.py +1 -1
  18. exonware/xwsystem/caching/integrity.py +1 -1
  19. exonware/xwsystem/caching/lfu_cache.py +24 -9
  20. exonware/xwsystem/caching/lfu_optimized.py +21 -21
  21. exonware/xwsystem/caching/lru_cache.py +14 -7
  22. exonware/xwsystem/caching/memory_bounded.py +8 -8
  23. exonware/xwsystem/caching/metrics_exporter.py +6 -6
  24. exonware/xwsystem/caching/observable_cache.py +1 -1
  25. exonware/xwsystem/caching/pluggable_cache.py +9 -9
  26. exonware/xwsystem/caching/rate_limiter.py +1 -1
  27. exonware/xwsystem/caching/read_through.py +6 -6
  28. exonware/xwsystem/caching/secure_cache.py +1 -1
  29. exonware/xwsystem/caching/serializable.py +3 -3
  30. exonware/xwsystem/caching/stats.py +7 -7
  31. exonware/xwsystem/caching/tagging.py +11 -11
  32. exonware/xwsystem/caching/ttl_cache.py +21 -6
  33. exonware/xwsystem/caching/two_tier_cache.py +5 -5
  34. exonware/xwsystem/caching/utils.py +3 -3
  35. exonware/xwsystem/caching/validation.py +1 -1
  36. exonware/xwsystem/caching/warming.py +9 -9
  37. exonware/xwsystem/caching/write_behind.py +5 -5
  38. exonware/xwsystem/cli/__init__.py +1 -1
  39. exonware/xwsystem/cli/args.py +10 -10
  40. exonware/xwsystem/cli/base.py +15 -15
  41. exonware/xwsystem/cli/colors.py +1 -1
  42. exonware/xwsystem/cli/console.py +1 -1
  43. exonware/xwsystem/cli/contracts.py +5 -5
  44. exonware/xwsystem/cli/defs.py +1 -1
  45. exonware/xwsystem/cli/errors.py +1 -1
  46. exonware/xwsystem/cli/progress.py +1 -1
  47. exonware/xwsystem/cli/prompts.py +1 -1
  48. exonware/xwsystem/cli/tables.py +7 -7
  49. exonware/xwsystem/config/__init__.py +1 -1
  50. exonware/xwsystem/config/base.py +14 -14
  51. exonware/xwsystem/config/contracts.py +22 -22
  52. exonware/xwsystem/config/defaults.py +2 -2
  53. exonware/xwsystem/config/defs.py +1 -1
  54. exonware/xwsystem/config/errors.py +2 -2
  55. exonware/xwsystem/config/logging.py +1 -1
  56. exonware/xwsystem/config/logging_setup.py +2 -2
  57. exonware/xwsystem/config/performance.py +7 -7
  58. exonware/xwsystem/config/performance_modes.py +20 -20
  59. exonware/xwsystem/config/version_manager.py +4 -4
  60. exonware/xwsystem/{http → http_client}/__init__.py +1 -1
  61. exonware/xwsystem/{http → http_client}/advanced_client.py +20 -20
  62. exonware/xwsystem/{http → http_client}/base.py +13 -13
  63. exonware/xwsystem/{http → http_client}/client.py +43 -43
  64. exonware/xwsystem/{http → http_client}/contracts.py +5 -5
  65. exonware/xwsystem/{http → http_client}/defs.py +2 -2
  66. exonware/xwsystem/{http → http_client}/errors.py +2 -2
  67. exonware/xwsystem/io/__init__.py +1 -1
  68. exonware/xwsystem/io/archive/__init__.py +1 -1
  69. exonware/xwsystem/io/archive/archive.py +5 -5
  70. exonware/xwsystem/io/archive/archive_files.py +8 -8
  71. exonware/xwsystem/io/archive/archivers.py +3 -3
  72. exonware/xwsystem/io/archive/base.py +17 -17
  73. exonware/xwsystem/io/archive/codec_integration.py +1 -1
  74. exonware/xwsystem/io/archive/compression.py +1 -1
  75. exonware/xwsystem/io/archive/formats/__init__.py +1 -1
  76. exonware/xwsystem/io/archive/formats/brotli_format.py +12 -9
  77. exonware/xwsystem/io/archive/formats/lz4_format.py +12 -9
  78. exonware/xwsystem/io/archive/formats/rar.py +12 -9
  79. exonware/xwsystem/io/archive/formats/sevenzip.py +12 -9
  80. exonware/xwsystem/io/archive/formats/squashfs_format.py +7 -7
  81. exonware/xwsystem/io/archive/formats/tar.py +8 -8
  82. exonware/xwsystem/io/archive/formats/wim_format.py +12 -9
  83. exonware/xwsystem/io/archive/formats/zip.py +8 -8
  84. exonware/xwsystem/io/archive/formats/zpaq_format.py +7 -7
  85. exonware/xwsystem/io/archive/formats/zstandard.py +12 -9
  86. exonware/xwsystem/io/base.py +17 -17
  87. exonware/xwsystem/io/codec/__init__.py +1 -1
  88. exonware/xwsystem/io/codec/base.py +261 -14
  89. exonware/xwsystem/io/codec/contracts.py +3 -6
  90. exonware/xwsystem/io/codec/registry.py +29 -29
  91. exonware/xwsystem/io/common/__init__.py +1 -1
  92. exonware/xwsystem/io/common/atomic.py +2 -2
  93. exonware/xwsystem/io/common/base.py +1 -1
  94. exonware/xwsystem/io/common/lock.py +1 -1
  95. exonware/xwsystem/io/common/watcher.py +4 -4
  96. exonware/xwsystem/io/contracts.py +34 -39
  97. exonware/xwsystem/io/data_operations.py +480 -0
  98. exonware/xwsystem/io/defs.py +2 -2
  99. exonware/xwsystem/io/errors.py +32 -3
  100. exonware/xwsystem/io/facade.py +4 -4
  101. exonware/xwsystem/io/file/__init__.py +1 -1
  102. exonware/xwsystem/io/file/base.py +2 -2
  103. exonware/xwsystem/io/file/conversion.py +1 -1
  104. exonware/xwsystem/io/file/file.py +10 -8
  105. exonware/xwsystem/io/file/paged_source.py +8 -1
  106. exonware/xwsystem/io/file/paging/__init__.py +1 -1
  107. exonware/xwsystem/io/file/paging/byte_paging.py +1 -1
  108. exonware/xwsystem/io/file/paging/line_paging.py +1 -1
  109. exonware/xwsystem/io/file/paging/record_paging.py +1 -1
  110. exonware/xwsystem/io/file/paging/registry.py +5 -5
  111. exonware/xwsystem/io/file/source.py +22 -11
  112. exonware/xwsystem/io/filesystem/__init__.py +1 -1
  113. exonware/xwsystem/io/filesystem/base.py +1 -1
  114. exonware/xwsystem/io/filesystem/local.py +9 -1
  115. exonware/xwsystem/io/folder/__init__.py +1 -1
  116. exonware/xwsystem/io/folder/base.py +2 -2
  117. exonware/xwsystem/io/folder/folder.py +6 -6
  118. exonware/xwsystem/io/serialization/__init__.py +1 -1
  119. exonware/xwsystem/io/serialization/auto_serializer.py +53 -40
  120. exonware/xwsystem/io/serialization/base.py +248 -35
  121. exonware/xwsystem/io/serialization/contracts.py +93 -4
  122. exonware/xwsystem/io/serialization/defs.py +1 -1
  123. exonware/xwsystem/io/serialization/errors.py +1 -1
  124. exonware/xwsystem/io/serialization/flyweight.py +22 -22
  125. exonware/xwsystem/io/serialization/format_detector.py +18 -15
  126. exonware/xwsystem/io/serialization/formats/__init__.py +1 -1
  127. exonware/xwsystem/io/serialization/formats/binary/bson.py +1 -1
  128. exonware/xwsystem/io/serialization/formats/binary/cbor.py +1 -1
  129. exonware/xwsystem/io/serialization/formats/binary/marshal.py +1 -1
  130. exonware/xwsystem/io/serialization/formats/binary/msgpack.py +1 -1
  131. exonware/xwsystem/io/serialization/formats/binary/pickle.py +1 -1
  132. exonware/xwsystem/io/serialization/formats/binary/plistlib.py +1 -1
  133. exonware/xwsystem/io/serialization/formats/database/dbm.py +53 -1
  134. exonware/xwsystem/io/serialization/formats/database/shelve.py +48 -1
  135. exonware/xwsystem/io/serialization/formats/database/sqlite3.py +85 -1
  136. exonware/xwsystem/io/serialization/formats/text/configparser.py +2 -2
  137. exonware/xwsystem/io/serialization/formats/text/csv.py +2 -2
  138. exonware/xwsystem/io/serialization/formats/text/formdata.py +2 -2
  139. exonware/xwsystem/io/serialization/formats/text/json.py +23 -5
  140. exonware/xwsystem/io/serialization/formats/text/json5.py +98 -13
  141. exonware/xwsystem/io/serialization/formats/text/jsonlines.py +230 -20
  142. exonware/xwsystem/io/serialization/formats/text/multipart.py +2 -2
  143. exonware/xwsystem/io/serialization/formats/text/toml.py +65 -4
  144. exonware/xwsystem/io/serialization/formats/text/xml.py +451 -69
  145. exonware/xwsystem/io/serialization/formats/text/yaml.py +52 -2
  146. exonware/xwsystem/io/serialization/registry.py +5 -5
  147. exonware/xwsystem/io/serialization/serializer.py +184 -12
  148. exonware/xwsystem/io/serialization/utils/__init__.py +1 -1
  149. exonware/xwsystem/io/serialization/utils/path_ops.py +3 -3
  150. exonware/xwsystem/io/stream/__init__.py +1 -1
  151. exonware/xwsystem/io/stream/async_operations.py +3 -3
  152. exonware/xwsystem/io/stream/base.py +3 -7
  153. exonware/xwsystem/io/stream/codec_io.py +4 -7
  154. exonware/xwsystem/ipc/async_fabric.py +7 -8
  155. exonware/xwsystem/ipc/base.py +9 -9
  156. exonware/xwsystem/ipc/contracts.py +5 -5
  157. exonware/xwsystem/ipc/defs.py +1 -1
  158. exonware/xwsystem/ipc/errors.py +2 -2
  159. exonware/xwsystem/ipc/message_queue.py +4 -6
  160. exonware/xwsystem/ipc/pipes.py +2 -2
  161. exonware/xwsystem/ipc/process_manager.py +7 -7
  162. exonware/xwsystem/ipc/process_pool.py +8 -8
  163. exonware/xwsystem/ipc/shared_memory.py +7 -7
  164. exonware/xwsystem/monitoring/base.py +33 -33
  165. exonware/xwsystem/monitoring/contracts.py +27 -27
  166. exonware/xwsystem/monitoring/defs.py +1 -1
  167. exonware/xwsystem/monitoring/error_recovery.py +16 -16
  168. exonware/xwsystem/monitoring/errors.py +2 -2
  169. exonware/xwsystem/monitoring/memory_monitor.py +12 -12
  170. exonware/xwsystem/monitoring/metrics.py +8 -8
  171. exonware/xwsystem/monitoring/performance_manager_generic.py +20 -20
  172. exonware/xwsystem/monitoring/performance_monitor.py +11 -11
  173. exonware/xwsystem/monitoring/performance_validator.py +21 -21
  174. exonware/xwsystem/monitoring/system_monitor.py +17 -17
  175. exonware/xwsystem/monitoring/tracing.py +20 -20
  176. exonware/xwsystem/monitoring/tracker.py +7 -7
  177. exonware/xwsystem/operations/__init__.py +5 -5
  178. exonware/xwsystem/operations/base.py +3 -3
  179. exonware/xwsystem/operations/contracts.py +3 -3
  180. exonware/xwsystem/operations/defs.py +5 -5
  181. exonware/xwsystem/operations/diff.py +5 -5
  182. exonware/xwsystem/operations/merge.py +2 -2
  183. exonware/xwsystem/operations/patch.py +5 -5
  184. exonware/xwsystem/patterns/base.py +4 -4
  185. exonware/xwsystem/patterns/context_manager.py +7 -7
  186. exonware/xwsystem/patterns/contracts.py +29 -31
  187. exonware/xwsystem/patterns/defs.py +1 -1
  188. exonware/xwsystem/patterns/dynamic_facade.py +9 -9
  189. exonware/xwsystem/patterns/errors.py +10 -10
  190. exonware/xwsystem/patterns/handler_factory.py +15 -14
  191. exonware/xwsystem/patterns/import_registry.py +22 -22
  192. exonware/xwsystem/patterns/object_pool.py +14 -13
  193. exonware/xwsystem/patterns/registry.py +45 -32
  194. exonware/xwsystem/plugins/__init__.py +1 -1
  195. exonware/xwsystem/plugins/base.py +25 -25
  196. exonware/xwsystem/plugins/contracts.py +28 -28
  197. exonware/xwsystem/plugins/defs.py +1 -1
  198. exonware/xwsystem/plugins/errors.py +9 -9
  199. exonware/xwsystem/runtime/__init__.py +1 -1
  200. exonware/xwsystem/runtime/base.py +42 -42
  201. exonware/xwsystem/runtime/contracts.py +9 -9
  202. exonware/xwsystem/runtime/defs.py +1 -1
  203. exonware/xwsystem/runtime/env.py +9 -9
  204. exonware/xwsystem/runtime/errors.py +1 -1
  205. exonware/xwsystem/runtime/reflection.py +15 -15
  206. exonware/xwsystem/security/auth.py +47 -15
  207. exonware/xwsystem/security/base.py +17 -17
  208. exonware/xwsystem/security/contracts.py +30 -30
  209. exonware/xwsystem/security/crypto.py +8 -8
  210. exonware/xwsystem/security/defs.py +1 -1
  211. exonware/xwsystem/security/errors.py +2 -2
  212. exonware/xwsystem/security/hazmat.py +7 -7
  213. exonware/xwsystem/security/path_validator.py +1 -1
  214. exonware/xwsystem/shared/__init__.py +1 -1
  215. exonware/xwsystem/shared/base.py +14 -14
  216. exonware/xwsystem/shared/contracts.py +6 -6
  217. exonware/xwsystem/shared/defs.py +1 -1
  218. exonware/xwsystem/shared/errors.py +1 -1
  219. exonware/xwsystem/structures/__init__.py +1 -1
  220. exonware/xwsystem/structures/base.py +29 -29
  221. exonware/xwsystem/structures/circular_detector.py +15 -15
  222. exonware/xwsystem/structures/contracts.py +9 -9
  223. exonware/xwsystem/structures/defs.py +1 -1
  224. exonware/xwsystem/structures/errors.py +2 -2
  225. exonware/xwsystem/structures/tree_walker.py +8 -8
  226. exonware/xwsystem/threading/async_primitives.py +7 -7
  227. exonware/xwsystem/threading/base.py +19 -19
  228. exonware/xwsystem/threading/contracts.py +13 -13
  229. exonware/xwsystem/threading/defs.py +1 -1
  230. exonware/xwsystem/threading/errors.py +2 -2
  231. exonware/xwsystem/threading/safe_factory.py +13 -12
  232. exonware/xwsystem/utils/base.py +34 -34
  233. exonware/xwsystem/utils/contracts.py +9 -9
  234. exonware/xwsystem/utils/dt/__init__.py +1 -1
  235. exonware/xwsystem/utils/dt/base.py +6 -6
  236. exonware/xwsystem/utils/dt/contracts.py +2 -2
  237. exonware/xwsystem/utils/dt/defs.py +1 -1
  238. exonware/xwsystem/utils/dt/errors.py +2 -2
  239. exonware/xwsystem/utils/dt/formatting.py +3 -3
  240. exonware/xwsystem/utils/dt/humanize.py +2 -2
  241. exonware/xwsystem/utils/dt/parsing.py +2 -2
  242. exonware/xwsystem/utils/dt/timezone_utils.py +5 -5
  243. exonware/xwsystem/utils/errors.py +2 -2
  244. exonware/xwsystem/utils/test_runner.py +6 -6
  245. exonware/xwsystem/utils/utils_contracts.py +1 -1
  246. exonware/xwsystem/validation/__init__.py +1 -1
  247. exonware/xwsystem/validation/base.py +48 -48
  248. exonware/xwsystem/validation/contracts.py +8 -8
  249. exonware/xwsystem/validation/data_validator.py +10 -0
  250. exonware/xwsystem/validation/declarative.py +15 -15
  251. exonware/xwsystem/validation/defs.py +1 -1
  252. exonware/xwsystem/validation/errors.py +2 -2
  253. exonware/xwsystem/validation/fluent_validator.py +10 -10
  254. exonware/xwsystem/version.py +2 -2
  255. {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/METADATA +9 -11
  256. exonware_xwsystem-0.0.1.411.dist-info/RECORD +274 -0
  257. {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/WHEEL +1 -1
  258. exonware/xwsystem/lazy_bootstrap.py +0 -79
  259. exonware_xwsystem-0.0.1.409.dist-info/RECORD +0 -274
  260. {exonware_xwsystem-0.0.1.409.dist-info → exonware_xwsystem-0.0.1.411.dist-info}/licenses/LICENSE +0 -0
@@ -4,7 +4,7 @@
4
4
  Company: eXonware.com
5
5
  Author: Eng. Muhammad AlShehri
6
6
  Email: connect@exonware.com
7
- Version: 0.0.1.409
7
+ Version: 0.0.1.411
8
8
  Generation Date: 07-Sep-2025
9
9
 
10
10
  Runtime types and enums for XWSystem.
@@ -2,7 +2,7 @@
2
2
  Company: eXonware.com
3
3
  Author: Eng. Muhammad AlShehri
4
4
  Email: connect@exonware.com
5
- Version: 0.0.1.409
5
+ Version: 0.0.1.411
6
6
  Generation Date: September 04, 2025
7
7
 
8
8
  Environment management utilities for runtime configuration and detection.
@@ -12,11 +12,11 @@ import os
12
12
  import platform
13
13
  import sys
14
14
  from pathlib import Path
15
- from typing import Any, Dict, List, Optional, Union
15
+ from typing import Any, Optional, Union
16
16
 
17
17
  from ..config.logging_setup import get_logger
18
18
 
19
- logger = get_logger("xsystem.runtime.env")
19
+ logger = get_logger("xwsystem.runtime.env")
20
20
 
21
21
 
22
22
  class EnvironmentManager:
@@ -27,11 +27,11 @@ class EnvironmentManager:
27
27
 
28
28
  def __init__(self) -> None:
29
29
  """Initialize environment manager."""
30
- self._cache: Dict[str, Any] = {}
31
- self._env_vars: Dict[str, str] = dict(os.environ)
30
+ self._cache: dict[str, Any] = {}
31
+ self._env_vars: dict[str, str] = dict(os.environ)
32
32
 
33
33
  @property
34
- def platform_info(self) -> Dict[str, str]:
34
+ def platform_info(self) -> dict[str, str]:
35
35
  """Get comprehensive platform information."""
36
36
  if 'platform_info' not in self._cache:
37
37
  self._cache['platform_info'] = {
@@ -68,7 +68,7 @@ class EnvironmentManager:
68
68
  return platform.architecture()[0] == '64bit'
69
69
 
70
70
  @property
71
- def python_info(self) -> Dict[str, Any]:
71
+ def python_info(self) -> dict[str, Any]:
72
72
  """Get Python runtime information."""
73
73
  if 'python_info' not in self._cache:
74
74
  self._cache['python_info'] = {
@@ -159,7 +159,7 @@ class EnvironmentManager:
159
159
  logger.warning(f"Invalid float value for {key}: {value}, using default: {default}")
160
160
  return default
161
161
 
162
- def get_env_list(self, key: str, separator: str = ',', default: Optional[List[str]] = None) -> List[str]:
162
+ def get_env_list(self, key: str, separator: str = ',', default: Optional[list[str]] = None) -> list[str]:
163
163
  """
164
164
  Get environment variable as list.
165
165
 
@@ -357,7 +357,7 @@ class EnvironmentManager:
357
357
  """Get number of CPU cores."""
358
358
  return os.cpu_count() or 1
359
359
 
360
- def get_environment_summary(self) -> Dict[str, Any]:
360
+ def get_environment_summary(self) -> dict[str, Any]:
361
361
  """Get comprehensive environment summary."""
362
362
  return {
363
363
  'platform': self.platform_info,
@@ -3,7 +3,7 @@
3
3
  Company: eXonware.com
4
4
  Author: Eng. Muhammad AlShehri
5
5
  Email: connect@exonware.com
6
- Version: 0.0.1.409
6
+ Version: 0.0.1.411
7
7
  Generation Date: September 04, 2025
8
8
 
9
9
  Runtime module errors - exception classes for runtime functionality.
@@ -2,7 +2,7 @@
2
2
  Company: eXonware.com
3
3
  Author: Eng. Muhammad AlShehri
4
4
  Email: connect@exonware.com
5
- Version: 0.0.1.409
5
+ Version: 0.0.1.411
6
6
  Generation Date: September 04, 2025
7
7
 
8
8
  Reflection utilities for dynamic code inspection and manipulation.
@@ -12,11 +12,11 @@ import importlib
12
12
  import inspect
13
13
  import sys
14
14
  from pathlib import Path
15
- from typing import Any, Callable, Dict, List, Optional, Type, Union
15
+ from typing import Any, Callable, Optional, Union
16
16
 
17
17
  from ..config.logging_setup import get_logger
18
18
 
19
- logger = get_logger("xsystem.runtime.reflection")
19
+ logger = get_logger("xwsystem.runtime.reflection")
20
20
 
21
21
 
22
22
  class ReflectionUtils:
@@ -26,7 +26,7 @@ class ReflectionUtils:
26
26
  """
27
27
 
28
28
  @staticmethod
29
- def get_class_info(cls: Type) -> Dict[str, Any]:
29
+ def get_class_info(cls: type) -> dict[str, Any]:
30
30
  """
31
31
  Get comprehensive information about a class.
32
32
 
@@ -53,7 +53,7 @@ class ReflectionUtils:
53
53
  }
54
54
 
55
55
  @staticmethod
56
- def get_function_info(func: Callable) -> Dict[str, Any]:
56
+ def get_function_info(func: Callable) -> dict[str, Any]:
57
57
  """
58
58
  Get comprehensive information about a function.
59
59
 
@@ -87,7 +87,7 @@ class ReflectionUtils:
87
87
  }
88
88
 
89
89
  @staticmethod
90
- def get_module_info(module: Any) -> Dict[str, Any]:
90
+ def get_module_info(module: Any) -> dict[str, Any]:
91
91
  """
92
92
  Get comprehensive information about a module.
93
93
 
@@ -113,7 +113,7 @@ class ReflectionUtils:
113
113
  }
114
114
 
115
115
  @staticmethod
116
- def _get_source_lines(obj: Any) -> Optional[Dict[str, Any]]:
116
+ def _get_source_lines(obj: Any) -> Optional[dict[str, Any]]:
117
117
  """Get source lines for an object."""
118
118
  try:
119
119
  source_lines, start_line = inspect.getsourcelines(obj)
@@ -164,7 +164,7 @@ class ReflectionUtils:
164
164
  raise
165
165
 
166
166
  @staticmethod
167
- def get_class_from_string(class_path: str) -> Type:
167
+ def get_class_from_string(class_path: str) -> type:
168
168
  """
169
169
  Get class from string path.
170
170
 
@@ -240,7 +240,7 @@ class ReflectionUtils:
240
240
  return func(*args, **kwargs)
241
241
 
242
242
  @staticmethod
243
- def find_classes_in_module(module: Any, base_class: Optional[Type] = None) -> List[Type]:
243
+ def find_classes_in_module(module: Any, base_class: Optional[type] = None) -> list[type]:
244
244
  """
245
245
  Find all classes in a module, optionally filtered by base class.
246
246
 
@@ -259,7 +259,7 @@ class ReflectionUtils:
259
259
  return classes
260
260
 
261
261
  @staticmethod
262
- def find_functions_in_module(module: Any, decorator: Optional[Any] = None) -> List[Callable]:
262
+ def find_functions_in_module(module: Any, decorator: Optional[Any] = None) -> list[Callable]:
263
263
  """
264
264
  Find all functions in a module, optionally filtered by decorator.
265
265
 
@@ -278,7 +278,7 @@ class ReflectionUtils:
278
278
  return functions
279
279
 
280
280
  @staticmethod
281
- def get_all_subclasses(cls: Type) -> List[Type]:
281
+ def get_all_subclasses(cls: type) -> list[type]:
282
282
  """
283
283
  Get all subclasses of a class recursively.
284
284
 
@@ -313,7 +313,7 @@ class ReflectionUtils:
313
313
  return False
314
314
 
315
315
  @staticmethod
316
- def get_method_resolution_order(cls: Type) -> List[str]:
316
+ def get_method_resolution_order(cls: type) -> list[str]:
317
317
  """
318
318
  Get method resolution order for a class.
319
319
 
@@ -339,7 +339,7 @@ class ReflectionUtils:
339
339
  return sys.getsizeof(obj)
340
340
 
341
341
  @staticmethod
342
- def get_module_dependencies(module_name: str) -> List[str]:
342
+ def get_module_dependencies(module_name: str) -> list[str]:
343
343
  """
344
344
  Get list of modules that a module depends on.
345
345
 
@@ -377,7 +377,7 @@ class ReflectionUtils:
377
377
  return dependencies
378
378
 
379
379
  @staticmethod
380
- def get_runtime_info() -> Dict[str, Any]:
380
+ def get_runtime_info() -> dict[str, Any]:
381
381
  """
382
382
  Get comprehensive runtime reflection information.
383
383
 
@@ -393,7 +393,7 @@ class ReflectionUtils:
393
393
  }
394
394
 
395
395
  @staticmethod
396
- def _get_current_frame_info() -> Dict[str, Any]:
396
+ def _get_current_frame_info() -> dict[str, Any]:
397
397
  """Get information about the current execution frame."""
398
398
  frame = inspect.currentframe()
399
399
  if frame and frame.f_back:
@@ -2,7 +2,7 @@
2
2
  Company: eXonware.com
3
3
  Author: Eng. Muhammad AlShehri
4
4
  Email: connect@exonware.com
5
- Version: 0.0.1.409
5
+ Version: 0.0.1.411
6
6
  Generation Date: September 04, 2025
7
7
 
8
8
  Advanced Authentication Providers for Enterprise Integration
@@ -20,17 +20,38 @@ import time
20
20
  import base64
21
21
  import hashlib
22
22
  import hmac
23
- from typing import Any, Dict, List, Optional, Union
23
+ from typing import Any, Optional, Union
24
24
  from urllib.parse import urlencode, parse_qs
25
25
  from .base import AAuthProvider, ATokenInfo, AUserInfo
26
26
  from .errors import AuthenticationError, AuthorizationError, TokenExpiredError
27
27
  from .defs import OAuth2GrantType
28
28
 
29
- import jwt
30
- import requests
31
-
32
29
  from ..config.logging_setup import get_logger
33
30
 
31
+ # Lazy imports to avoid import errors during test collection
32
+ # These are only imported when actually needed
33
+ def _get_jwt():
34
+ """Lazy import jwt module."""
35
+ try:
36
+ import jwt
37
+ return jwt
38
+ except ImportError:
39
+ raise ImportError(
40
+ "PyJWT is required for JWT authentication. "
41
+ "Install it with: pip install PyJWT"
42
+ )
43
+
44
+ def _get_requests():
45
+ """Lazy import requests module."""
46
+ try:
47
+ import requests
48
+ return requests
49
+ except ImportError:
50
+ raise ImportError(
51
+ "requests is required for OAuth2 authentication. "
52
+ "Install it with: pip install requests"
53
+ )
54
+
34
55
  logger = get_logger("xwsystem.security.auth")
35
56
 
36
57
 
@@ -44,7 +65,7 @@ class OAuth2Provider(AAuthProvider):
44
65
  authorization_url: str,
45
66
  token_url: str,
46
67
  userinfo_url: Optional[str] = None,
47
- scopes: Optional[List[str]] = None
68
+ scopes: Optional[list[str]] = None
48
69
  ):
49
70
  """
50
71
  Initialize OAuth2 provider.
@@ -80,7 +101,7 @@ class OAuth2Provider(AAuthProvider):
80
101
 
81
102
  return f"{self.authorization_url}?{urlencode(params)}"
82
103
 
83
- async def authenticate(self, credentials: Dict[str, Any]) -> ATokenInfo:
104
+ async def authenticate(self, credentials: dict[str, Any]) -> ATokenInfo:
84
105
  """Authenticate using OAuth2 flow."""
85
106
  import asyncio
86
107
 
@@ -98,8 +119,9 @@ class OAuth2Provider(AAuthProvider):
98
119
 
99
120
  return await asyncio.to_thread(_authenticate)
100
121
 
101
- def _authenticate_authorization_code(self, credentials: Dict[str, Any]) -> ATokenInfo:
122
+ def _authenticate_authorization_code(self, credentials: dict[str, Any]) -> ATokenInfo:
102
123
  """Authenticate using authorization code."""
124
+ requests = _get_requests()
103
125
  data = {
104
126
  'grant_type': OAuth2GrantType.AUTHORIZATION_CODE.value,
105
127
  'client_id': self.client_id,
@@ -124,6 +146,7 @@ class OAuth2Provider(AAuthProvider):
124
146
 
125
147
  def _authenticate_client_credentials(self) -> ATokenInfo:
126
148
  """Authenticate using client credentials."""
149
+ requests = _get_requests()
127
150
  data = {
128
151
  'grant_type': OAuth2GrantType.CLIENT_CREDENTIALS.value,
129
152
  'client_id': self.client_id,
@@ -144,8 +167,9 @@ class OAuth2Provider(AAuthProvider):
144
167
  scope=token_data.get('scope')
145
168
  )
146
169
 
147
- def _authenticate_resource_owner(self, credentials: Dict[str, Any]) -> ATokenInfo:
170
+ def _authenticate_resource_owner(self, credentials: dict[str, Any]) -> ATokenInfo:
148
171
  """Authenticate using resource owner credentials."""
172
+ requests = _get_requests()
149
173
  data = {
150
174
  'grant_type': OAuth2GrantType.RESOURCE_OWNER.value,
151
175
  'client_id': self.client_id,
@@ -177,6 +201,7 @@ class OAuth2Provider(AAuthProvider):
177
201
  import asyncio
178
202
 
179
203
  def _validate():
204
+ requests = _get_requests()
180
205
  headers = {'Authorization': f'Bearer {token}'}
181
206
  response = requests.get(self.userinfo_url, headers=headers)
182
207
 
@@ -200,6 +225,7 @@ class OAuth2Provider(AAuthProvider):
200
225
  import asyncio
201
226
 
202
227
  def _refresh():
228
+ requests = _get_requests()
203
229
  data = {
204
230
  'grant_type': OAuth2GrantType.REFRESH_TOKEN.value,
205
231
  'client_id': self.client_id,
@@ -253,11 +279,12 @@ class JWTProvider(AAuthProvider):
253
279
  self.audience = audience
254
280
  self.expiration_time = expiration_time
255
281
 
256
- async def authenticate(self, credentials: Dict[str, Any]) -> ATokenInfo:
282
+ async def authenticate(self, credentials: dict[str, Any]) -> ATokenInfo:
257
283
  """Create JWT token from user credentials."""
258
284
  import asyncio
259
285
 
260
286
  def _authenticate():
287
+ jwt = _get_jwt()
261
288
  # In a real implementation, you'd validate credentials against a database
262
289
  user_id = credentials.get('user_id')
263
290
  if not user_id:
@@ -291,6 +318,7 @@ class JWTProvider(AAuthProvider):
291
318
  import asyncio
292
319
 
293
320
  def _validate():
321
+ jwt = _get_jwt()
294
322
  try:
295
323
  payload = jwt.decode(
296
324
  token,
@@ -317,6 +345,7 @@ class JWTProvider(AAuthProvider):
317
345
 
318
346
  async def refresh_token(self, refresh_token: str) -> ATokenInfo:
319
347
  """Refresh JWT token (create new token from existing)."""
348
+ jwt = _get_jwt()
320
349
  try:
321
350
  # Validate existing token (ignore expiration for refresh)
322
351
  payload = jwt.decode(
@@ -341,8 +370,11 @@ class JWTProvider(AAuthProvider):
341
370
  expires_in=self.expiration_time
342
371
  )
343
372
 
344
- except jwt.InvalidTokenError as e:
345
- raise AuthenticationError(f"Invalid refresh token: {e}")
373
+ except Exception as e:
374
+ jwt_module = _get_jwt()
375
+ if isinstance(e, jwt_module.InvalidTokenError):
376
+ raise AuthenticationError(f"Invalid refresh token: {e}")
377
+ raise
346
378
 
347
379
 
348
380
  class SAMLProvider(AAuthProvider):
@@ -368,7 +400,7 @@ class SAMLProvider(AAuthProvider):
368
400
 
369
401
  logger.warning("SAML provider is a simplified implementation. Use a full SAML library for production.")
370
402
 
371
- async def authenticate(self, credentials: Dict[str, Any]) -> ATokenInfo:
403
+ async def authenticate(self, credentials: dict[str, Any]) -> ATokenInfo:
372
404
  """Authenticate using SAML (simplified)."""
373
405
  # This is a placeholder implementation
374
406
  # In practice, you'd use a library like python3-saml
@@ -424,7 +456,7 @@ class EnterpriseAuth:
424
456
 
425
457
  return self._providers[name]
426
458
 
427
- async def authenticate(self, credentials: Dict[str, Any], provider: Optional[str] = None) -> ATokenInfo:
459
+ async def authenticate(self, credentials: dict[str, Any], provider: Optional[str] = None) -> ATokenInfo:
428
460
  """Authenticate using specified or active provider."""
429
461
  provider_instance = self.get_provider(provider)
430
462
  return await provider_instance.authenticate(credentials)
@@ -439,7 +471,7 @@ class EnterpriseAuth:
439
471
  provider_instance = self.get_provider(provider)
440
472
  return await provider_instance.refresh_token(refresh_token)
441
473
 
442
- def list_providers(self) -> List[str]:
474
+ def list_providers(self) -> list[str]:
443
475
  """List available providers."""
444
476
  return list(self._providers.keys())
445
477
 
@@ -1,16 +1,16 @@
1
- #exonware/xsystem/security/base.py
1
+ #exonware/xwsystem/security/base.py
2
2
  """
3
3
  Company: eXonware.com
4
4
  Author: Eng. Muhammad AlShehri
5
5
  Email: connect@exonware.com
6
- Version: 0.0.1.409
6
+ Version: 0.0.1.411
7
7
  Generation Date: September 04, 2025
8
8
 
9
9
  Security module base classes - abstract classes for security functionality.
10
10
  """
11
11
 
12
12
  from abc import ABC, abstractmethod
13
- from typing import Any, Dict, List, Optional, Union, Tuple
13
+ from typing import Any, Optional, Union
14
14
  from .defs import HashAlgorithm, EncryptionAlgorithm, SecurityLevel
15
15
 
16
16
 
@@ -118,7 +118,7 @@ class AHashBase(ABC):
118
118
  pass
119
119
 
120
120
  @abstractmethod
121
- def hash_with_salt(self, data: Union[str, bytes]) -> Tuple[str, bytes]:
121
+ def hash_with_salt(self, data: Union[str, bytes]) -> tuple[str, bytes]:
122
122
  """Hash data with generated salt."""
123
123
  pass
124
124
 
@@ -189,8 +189,8 @@ class APathValidatorBase(ABC):
189
189
  security_level: Security level for validation
190
190
  """
191
191
  self.security_level = security_level
192
- self._allowed_paths: List[str] = []
193
- self._blocked_paths: List[str] = []
192
+ self._allowed_paths: list[str] = []
193
+ self._blocked_paths: list[str] = []
194
194
 
195
195
  @abstractmethod
196
196
  def validate_path(self, path: Union[str, bytes]) -> bool:
@@ -238,12 +238,12 @@ class APathValidatorBase(ABC):
238
238
  pass
239
239
 
240
240
  @abstractmethod
241
- def get_allowed_paths(self) -> List[str]:
241
+ def get_allowed_paths(self) -> list[str]:
242
242
  """Get allowed paths."""
243
243
  pass
244
244
 
245
245
  @abstractmethod
246
- def get_blocked_paths(self) -> List[str]:
246
+ def get_blocked_paths(self) -> list[str]:
247
247
  """Get blocked paths."""
248
248
  pass
249
249
 
@@ -253,8 +253,8 @@ class AResourceLimitsBase(ABC):
253
253
 
254
254
  def __init__(self):
255
255
  """Initialize resource limits."""
256
- self._limits: Dict[str, int] = {}
257
- self._current_usage: Dict[str, int] = {}
256
+ self._limits: dict[str, int] = {}
257
+ self._current_usage: dict[str, int] = {}
258
258
 
259
259
  @abstractmethod
260
260
  def set_limit(self, resource: str, limit: int) -> None:
@@ -297,12 +297,12 @@ class AResourceLimitsBase(ABC):
297
297
  pass
298
298
 
299
299
  @abstractmethod
300
- def get_all_limits(self) -> Dict[str, int]:
300
+ def get_all_limits(self) -> dict[str, int]:
301
301
  """Get all resource limits."""
302
302
  pass
303
303
 
304
304
  @abstractmethod
305
- def get_all_usage(self) -> Dict[str, int]:
305
+ def get_all_usage(self) -> dict[str, int]:
306
306
  """Get all resource usage."""
307
307
  pass
308
308
 
@@ -323,7 +323,7 @@ class ASecurityValidatorBase(ABC):
323
323
  security_level: Security level for validation
324
324
  """
325
325
  self.security_level = security_level
326
- self._validation_rules: Dict[str, callable] = {}
326
+ self._validation_rules: dict[str, callable] = {}
327
327
 
328
328
  @abstractmethod
329
329
  def validate_input(self, data: Any, input_type: str) -> bool:
@@ -351,7 +351,7 @@ class ASecurityValidatorBase(ABC):
351
351
  pass
352
352
 
353
353
  @abstractmethod
354
- def get_validation_errors(self) -> List[str]:
354
+ def get_validation_errors(self) -> list[str]:
355
355
  """Get validation errors."""
356
356
  pass
357
357
 
@@ -394,15 +394,15 @@ class AUserInfo:
394
394
  user_id: str
395
395
  username: Optional[str] = None
396
396
  email: Optional[str] = None
397
- roles: List[str] = field(default_factory=list)
398
- attributes: Dict[str, Any] = field(default_factory=dict)
397
+ roles: list[str] = field(default_factory=list)
398
+ attributes: dict[str, Any] = field(default_factory=dict)
399
399
 
400
400
 
401
401
  class AAuthProvider(ABC):
402
402
  """Abstract base class for authentication providers."""
403
403
 
404
404
  @abstractmethod
405
- async def authenticate(self, credentials: Dict[str, Any]) -> ATokenInfo:
405
+ async def authenticate(self, credentials: dict[str, Any]) -> ATokenInfo:
406
406
  """Authenticate user with credentials."""
407
407
  pass
408
408