exonware-xwlazy 0.1.0.11__py3-none-any.whl → 0.1.0.19__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 (96) hide show
  1. exonware/__init__.py +22 -0
  2. exonware/xwlazy/__init__.py +0 -0
  3. exonware/xwlazy/common/__init__.py +47 -0
  4. exonware/xwlazy/common/base.py +58 -0
  5. exonware/xwlazy/common/cache.py +506 -0
  6. exonware/xwlazy/common/logger.py +268 -0
  7. exonware/xwlazy/common/services/__init__.py +72 -0
  8. exonware/xwlazy/common/services/dependency_mapper.py +234 -0
  9. exonware/xwlazy/common/services/install_async_utils.py +169 -0
  10. exonware/xwlazy/common/services/install_cache_utils.py +257 -0
  11. exonware/xwlazy/common/services/keyword_detection.py +292 -0
  12. exonware/xwlazy/common/services/spec_cache.py +173 -0
  13. exonware/xwlazy/common/strategies/__init__.py +28 -0
  14. exonware/xwlazy/common/strategies/caching_dict.py +45 -0
  15. exonware/xwlazy/common/strategies/caching_installation.py +89 -0
  16. exonware/xwlazy/common/strategies/caching_lfu.py +67 -0
  17. exonware/xwlazy/common/strategies/caching_lru.py +64 -0
  18. exonware/xwlazy/common/strategies/caching_multitier.py +60 -0
  19. exonware/xwlazy/common/strategies/caching_ttl.py +60 -0
  20. {xwlazy/lazy → exonware/xwlazy}/config.py +52 -20
  21. exonware/xwlazy/contracts.py +1410 -0
  22. exonware/xwlazy/defs.py +397 -0
  23. xwlazy/lazy/lazy_errors.py → exonware/xwlazy/errors.py +21 -8
  24. exonware/xwlazy/facade.py +1049 -0
  25. exonware/xwlazy/module/__init__.py +18 -0
  26. exonware/xwlazy/module/base.py +569 -0
  27. exonware/xwlazy/module/data.py +17 -0
  28. exonware/xwlazy/module/facade.py +247 -0
  29. exonware/xwlazy/module/importer_engine.py +2161 -0
  30. exonware/xwlazy/module/strategies/__init__.py +22 -0
  31. exonware/xwlazy/module/strategies/module_helper_lazy.py +94 -0
  32. exonware/xwlazy/module/strategies/module_helper_simple.py +66 -0
  33. exonware/xwlazy/module/strategies/module_manager_advanced.py +112 -0
  34. exonware/xwlazy/module/strategies/module_manager_simple.py +96 -0
  35. exonware/xwlazy/package/__init__.py +18 -0
  36. exonware/xwlazy/package/base.py +807 -0
  37. xwlazy/lazy/host_conf.py → exonware/xwlazy/package/conf.py +62 -10
  38. exonware/xwlazy/package/data.py +17 -0
  39. exonware/xwlazy/package/facade.py +481 -0
  40. exonware/xwlazy/package/services/__init__.py +84 -0
  41. exonware/xwlazy/package/services/async_install_handle.py +89 -0
  42. exonware/xwlazy/package/services/config_manager.py +246 -0
  43. exonware/xwlazy/package/services/discovery.py +374 -0
  44. {xwlazy/lazy → exonware/xwlazy/package/services}/host_packages.py +43 -16
  45. exonware/xwlazy/package/services/install_async.py +278 -0
  46. exonware/xwlazy/package/services/install_cache.py +146 -0
  47. exonware/xwlazy/package/services/install_interactive.py +60 -0
  48. exonware/xwlazy/package/services/install_policy.py +158 -0
  49. exonware/xwlazy/package/services/install_registry.py +56 -0
  50. exonware/xwlazy/package/services/install_result.py +17 -0
  51. exonware/xwlazy/package/services/install_sbom.py +154 -0
  52. exonware/xwlazy/package/services/install_utils.py +83 -0
  53. exonware/xwlazy/package/services/installer_engine.py +408 -0
  54. exonware/xwlazy/package/services/lazy_installer.py +720 -0
  55. {xwlazy/lazy → exonware/xwlazy/package/services}/manifest.py +42 -25
  56. exonware/xwlazy/package/services/strategy_registry.py +188 -0
  57. exonware/xwlazy/package/strategies/__init__.py +57 -0
  58. exonware/xwlazy/package/strategies/package_discovery_file.py +130 -0
  59. exonware/xwlazy/package/strategies/package_discovery_hybrid.py +85 -0
  60. exonware/xwlazy/package/strategies/package_discovery_manifest.py +102 -0
  61. exonware/xwlazy/package/strategies/package_execution_async.py +114 -0
  62. exonware/xwlazy/package/strategies/package_execution_cached.py +91 -0
  63. exonware/xwlazy/package/strategies/package_execution_pip.py +100 -0
  64. exonware/xwlazy/package/strategies/package_execution_wheel.py +107 -0
  65. exonware/xwlazy/package/strategies/package_mapping_discovery_first.py +101 -0
  66. exonware/xwlazy/package/strategies/package_mapping_hybrid.py +106 -0
  67. exonware/xwlazy/package/strategies/package_mapping_manifest_first.py +101 -0
  68. exonware/xwlazy/package/strategies/package_policy_allow_list.py +58 -0
  69. exonware/xwlazy/package/strategies/package_policy_deny_list.py +58 -0
  70. exonware/xwlazy/package/strategies/package_policy_permissive.py +47 -0
  71. exonware/xwlazy/package/strategies/package_timing_clean.py +68 -0
  72. exonware/xwlazy/package/strategies/package_timing_full.py +67 -0
  73. exonware/xwlazy/package/strategies/package_timing_smart.py +69 -0
  74. exonware/xwlazy/package/strategies/package_timing_temporary.py +67 -0
  75. exonware/xwlazy/runtime/__init__.py +18 -0
  76. exonware/xwlazy/runtime/adaptive_learner.py +131 -0
  77. exonware/xwlazy/runtime/base.py +276 -0
  78. exonware/xwlazy/runtime/facade.py +95 -0
  79. exonware/xwlazy/runtime/intelligent_selector.py +173 -0
  80. exonware/xwlazy/runtime/metrics.py +64 -0
  81. exonware/xwlazy/runtime/performance.py +39 -0
  82. exonware/xwlazy/version.py +2 -2
  83. {exonware_xwlazy-0.1.0.11.dist-info → exonware_xwlazy-0.1.0.19.dist-info}/METADATA +86 -10
  84. exonware_xwlazy-0.1.0.19.dist-info/RECORD +87 -0
  85. exonware_xwlazy-0.1.0.11.dist-info/RECORD +0 -20
  86. xwlazy/__init__.py +0 -34
  87. xwlazy/lazy/__init__.py +0 -301
  88. xwlazy/lazy/bootstrap.py +0 -106
  89. xwlazy/lazy/lazy_base.py +0 -465
  90. xwlazy/lazy/lazy_contracts.py +0 -290
  91. xwlazy/lazy/lazy_core.py +0 -3727
  92. xwlazy/lazy/logging_utils.py +0 -194
  93. xwlazy/version.py +0 -77
  94. /xwlazy/lazy/lazy_state.py → /exonware/xwlazy/common/services/state_manager.py +0 -0
  95. {exonware_xwlazy-0.1.0.11.dist-info → exonware_xwlazy-0.1.0.19.dist-info}/WHEEL +0 -0
  96. {exonware_xwlazy-0.1.0.11.dist-info → exonware_xwlazy-0.1.0.19.dist-info}/licenses/LICENSE +0 -0
@@ -1,194 +0,0 @@
1
- #exonware/xwlazy/src/exonware/xwlazy/lazy/logging_utils.py
2
- """
3
- Lightweight logging helper for the xwlazy lazy subsystem.
4
-
5
- Adds category-based filtering so noisy traces (hook/install/audit/etc.) can be
6
- turned on or off individually via configuration or environment variables.
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- import logging
12
- import os
13
- import sys
14
- from datetime import datetime
15
- from typing import Dict, Optional
16
-
17
- _configured = False
18
-
19
- _CATEGORY_DEFAULTS: Dict[str, bool] = {
20
- "install": True, # always show installs by default
21
- "hook": False,
22
- "enhance": False,
23
- "audit": False,
24
- "sbom": False,
25
- "config": False,
26
- "discovery": False,
27
- }
28
- _category_overrides: Dict[str, bool] = {}
29
-
30
-
31
- def _normalize_category(name: str) -> str:
32
- return name.strip().lower()
33
-
34
-
35
- def _load_env_overrides() -> None:
36
- for category in _CATEGORY_DEFAULTS:
37
- env_key = f"XWLAZY_LOG_{category.upper()}"
38
- env_val = os.getenv(env_key)
39
- if env_val is None:
40
- continue
41
- enabled = env_val.strip().lower() not in {"0", "false", "off", "no"}
42
- _category_overrides[_normalize_category(category)] = enabled
43
-
44
-
45
- class XWLazyFormatter(logging.Formatter):
46
- """Custom formatter for xwlazy that uses exonware.xwlazy [HH:MM:SS]: [FLAG] format."""
47
-
48
- # Map logging levels to flags
49
- LEVEL_FLAGS = {
50
- logging.DEBUG: "DEBUG",
51
- logging.INFO: "INFO",
52
- logging.WARNING: "WARN",
53
- logging.ERROR: "ERROR",
54
- logging.CRITICAL: "CRITICAL",
55
- }
56
-
57
- # Map flags to emojis
58
- EMOJI_MAP = {
59
- "WARN": "⚠️",
60
- "INFO": "ℹ️",
61
- "ACTION": "⚙️",
62
- "SUCCESS": "✅",
63
- "ERROR": "❌",
64
- "FAIL": "⛔",
65
- "DEBUG": "🔍",
66
- "CRITICAL": "🚨",
67
- }
68
-
69
- def format(self, record: logging.LogRecord) -> str:
70
- """Format log record with custom format."""
71
- # Get flag from level or use INFO as default
72
- flag = self.LEVEL_FLAGS.get(record.levelno, "INFO")
73
-
74
- # Get emoji for flag
75
- emoji = self.EMOJI_MAP.get(flag, "ℹ️")
76
-
77
- # Format time as HH:MM:SS
78
- time_str = datetime.now().strftime("%H:%M:%S")
79
-
80
- # Format message
81
- message = record.getMessage()
82
-
83
- # Return formatted: emoji exonware.xwlazy [HH:MM:SS]: [FLAG] message
84
- return f"{emoji} exonware.xwlazy [{time_str}]: [{flag}] {message}"
85
-
86
-
87
- def _ensure_basic_config() -> None:
88
- global _configured
89
- if _configured:
90
- return
91
-
92
- # Configure root logger with custom formatter
93
- root_logger = logging.getLogger()
94
- root_logger.setLevel(logging.INFO)
95
-
96
- # Remove existing handlers to avoid duplicates
97
- for handler in root_logger.handlers[:]:
98
- root_logger.removeHandler(handler)
99
-
100
- # Create console handler with custom formatter
101
- console_handler = logging.StreamHandler(sys.stdout)
102
- console_handler.setLevel(logging.INFO)
103
- console_handler.setFormatter(XWLazyFormatter())
104
- root_logger.addHandler(console_handler)
105
-
106
- _load_env_overrides()
107
- _configured = True
108
-
109
-
110
- def get_logger(name: Optional[str] = None) -> logging.Logger:
111
- """Return a logger configured for the lazy subsystem."""
112
- _ensure_basic_config()
113
- return logging.getLogger(name or "xwlazy.lazy")
114
-
115
-
116
- def is_log_category_enabled(category: str) -> bool:
117
- """Return True if the provided log category is enabled."""
118
- _ensure_basic_config()
119
- normalized = _normalize_category(category)
120
- if normalized in _category_overrides:
121
- return _category_overrides[normalized]
122
- return _CATEGORY_DEFAULTS.get(normalized, True)
123
-
124
-
125
- def set_log_category(category: str, enabled: bool) -> None:
126
- """Enable/disable an individual log category at runtime."""
127
- _category_overrides[_normalize_category(category)] = bool(enabled)
128
-
129
-
130
- def set_log_categories(overrides: Dict[str, bool]) -> None:
131
- """Bulk update multiple categories."""
132
- for category, enabled in overrides.items():
133
- set_log_category(category, enabled)
134
-
135
-
136
- def get_log_categories() -> Dict[str, bool]:
137
- """Return the effective state for each built-in log category."""
138
- _ensure_basic_config()
139
- result = {}
140
- for category, default_enabled in _CATEGORY_DEFAULTS.items():
141
- normalized = _normalize_category(category)
142
- result[category] = _category_overrides.get(normalized, default_enabled)
143
- return result
144
-
145
-
146
- def log_event(category: str, level_fn, msg: str, *args, **kwargs) -> None:
147
- """Emit a log for the given category if it is enabled."""
148
- if is_log_category_enabled(category):
149
- level_fn(msg, *args, **kwargs)
150
-
151
-
152
- def format_message(flag: str, message: str) -> str:
153
- """
154
- Format a message with exonware.xwlazy [HH:MM:SS]: [FLAG] format.
155
-
156
- Args:
157
- flag: Message flag (WARN, ACTION, SUCCESS, etc.)
158
- message: Message content
159
-
160
- Returns:
161
- Formatted message string
162
- """
163
- # Map flags to emojis
164
- emoji_map = {
165
- "WARN": "⚠️",
166
- "INFO": "ℹ️",
167
- "ACTION": "⚙️",
168
- "SUCCESS": "✅",
169
- "ERROR": "❌",
170
- "FAIL": "⛔",
171
- "DEBUG": "🔍",
172
- "CRITICAL": "🚨",
173
- }
174
- emoji = emoji_map.get(flag, "ℹ️")
175
- time_str = datetime.now().strftime("%H:%M:%S")
176
- return f"{emoji} exonware.xwlazy [{time_str}]: [{flag}] {message}"
177
-
178
-
179
- def print_formatted(flag: str, message: str, same_line: bool = False) -> None:
180
- """
181
- Print a formatted message with optional same-line support.
182
-
183
- Args:
184
- flag: Message flag (WARN, ACTION, SUCCESS, etc.)
185
- message: Message content
186
- same_line: If True, use \r to overwrite previous line
187
- """
188
- formatted = format_message(flag, message)
189
- if same_line:
190
- sys.stdout.write(f"\r{formatted}")
191
- sys.stdout.flush()
192
- else:
193
- print(formatted)
194
-
xwlazy/version.py DELETED
@@ -1,77 +0,0 @@
1
- """
2
- Centralized version management for eXonware projects.
3
-
4
- Company: eXonware.com
5
- Author: Eng. Muhammad AlShehri
6
- Email: connect@exonware.com
7
-
8
- This module provides centralized version management for the entire project.
9
- All version references should import from this module to ensure consistency.
10
- """
11
-
12
- # =============================================================================
13
- # VERSION CONFIGURATION
14
- # =============================================================================
15
-
16
- # Main version - update this to change version across entire project
17
- __version__ = "0.1.0.11"
18
-
19
- # Version components for programmatic access
20
- VERSION_MAJOR = 0
21
- VERSION_MINOR = 1
22
- VERSION_PATCH = 0
23
- VERSION_BUILD = 11 # Set to None for releases, or build number for dev builds
24
-
25
- # Version metadata
26
- VERSION_SUFFIX = "" # e.g., "dev", "alpha", "beta", "rc1"
27
- VERSION_STRING = __version__ + VERSION_SUFFIX
28
-
29
- # =============================================================================
30
- # VERSION UTILITIES
31
- # =============================================================================
32
-
33
- def get_version() -> str:
34
- """Get the current version string."""
35
- return VERSION_STRING
36
-
37
- def get_version_info() -> tuple:
38
- """Get version as a tuple (major, minor, patch, build)."""
39
- return (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, VERSION_BUILD)
40
-
41
- def get_version_dict() -> dict:
42
- """Get version information as a dictionary."""
43
- return {
44
- "version": VERSION_STRING,
45
- "major": VERSION_MAJOR,
46
- "minor": VERSION_MINOR,
47
- "patch": VERSION_PATCH,
48
- "build": VERSION_BUILD,
49
- "suffix": VERSION_SUFFIX
50
- }
51
-
52
- def is_dev_version() -> bool:
53
- """Check if this is a development version."""
54
- return VERSION_SUFFIX in ("dev", "alpha", "beta") or VERSION_BUILD is not None
55
-
56
- def is_release_version() -> bool:
57
- """Check if this is a release version."""
58
- return not is_dev_version()
59
-
60
- # =============================================================================
61
- # EXPORTS
62
- # =============================================================================
63
-
64
- __all__ = [
65
- "__version__",
66
- "VERSION_MAJOR",
67
- "VERSION_MINOR",
68
- "VERSION_PATCH",
69
- "VERSION_BUILD",
70
- "VERSION_SUFFIX",
71
- "VERSION_STRING",
72
- "get_version",
73
- "get_version_info",
74
- "get_version_dict",
75
- "is_dev_version",
76
- "is_release_version"
77
- ]