provide-foundation 0.0.0.dev0__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 (149) hide show
  1. provide/__init__.py +15 -0
  2. provide/foundation/__init__.py +155 -0
  3. provide/foundation/_version.py +58 -0
  4. provide/foundation/cli/__init__.py +67 -0
  5. provide/foundation/cli/commands/__init__.py +3 -0
  6. provide/foundation/cli/commands/deps.py +71 -0
  7. provide/foundation/cli/commands/logs/__init__.py +63 -0
  8. provide/foundation/cli/commands/logs/generate.py +357 -0
  9. provide/foundation/cli/commands/logs/generate_old.py +569 -0
  10. provide/foundation/cli/commands/logs/query.py +174 -0
  11. provide/foundation/cli/commands/logs/send.py +166 -0
  12. provide/foundation/cli/commands/logs/tail.py +112 -0
  13. provide/foundation/cli/decorators.py +262 -0
  14. provide/foundation/cli/main.py +65 -0
  15. provide/foundation/cli/testing.py +220 -0
  16. provide/foundation/cli/utils.py +210 -0
  17. provide/foundation/config/__init__.py +106 -0
  18. provide/foundation/config/base.py +295 -0
  19. provide/foundation/config/env.py +369 -0
  20. provide/foundation/config/loader.py +311 -0
  21. provide/foundation/config/manager.py +387 -0
  22. provide/foundation/config/schema.py +284 -0
  23. provide/foundation/config/sync.py +281 -0
  24. provide/foundation/config/types.py +78 -0
  25. provide/foundation/config/validators.py +80 -0
  26. provide/foundation/console/__init__.py +29 -0
  27. provide/foundation/console/input.py +364 -0
  28. provide/foundation/console/output.py +178 -0
  29. provide/foundation/context/__init__.py +12 -0
  30. provide/foundation/context/core.py +356 -0
  31. provide/foundation/core.py +20 -0
  32. provide/foundation/crypto/__init__.py +182 -0
  33. provide/foundation/crypto/algorithms.py +111 -0
  34. provide/foundation/crypto/certificates.py +896 -0
  35. provide/foundation/crypto/checksums.py +301 -0
  36. provide/foundation/crypto/constants.py +57 -0
  37. provide/foundation/crypto/hashing.py +265 -0
  38. provide/foundation/crypto/keys.py +188 -0
  39. provide/foundation/crypto/signatures.py +144 -0
  40. provide/foundation/crypto/utils.py +164 -0
  41. provide/foundation/errors/__init__.py +96 -0
  42. provide/foundation/errors/auth.py +73 -0
  43. provide/foundation/errors/base.py +81 -0
  44. provide/foundation/errors/config.py +103 -0
  45. provide/foundation/errors/context.py +299 -0
  46. provide/foundation/errors/decorators.py +484 -0
  47. provide/foundation/errors/handlers.py +360 -0
  48. provide/foundation/errors/integration.py +105 -0
  49. provide/foundation/errors/platform.py +37 -0
  50. provide/foundation/errors/process.py +140 -0
  51. provide/foundation/errors/resources.py +133 -0
  52. provide/foundation/errors/runtime.py +160 -0
  53. provide/foundation/errors/safe_decorators.py +133 -0
  54. provide/foundation/errors/types.py +276 -0
  55. provide/foundation/file/__init__.py +79 -0
  56. provide/foundation/file/atomic.py +157 -0
  57. provide/foundation/file/directory.py +134 -0
  58. provide/foundation/file/formats.py +236 -0
  59. provide/foundation/file/lock.py +175 -0
  60. provide/foundation/file/safe.py +179 -0
  61. provide/foundation/file/utils.py +170 -0
  62. provide/foundation/hub/__init__.py +88 -0
  63. provide/foundation/hub/click_builder.py +310 -0
  64. provide/foundation/hub/commands.py +42 -0
  65. provide/foundation/hub/components.py +640 -0
  66. provide/foundation/hub/decorators.py +244 -0
  67. provide/foundation/hub/info.py +32 -0
  68. provide/foundation/hub/manager.py +446 -0
  69. provide/foundation/hub/registry.py +279 -0
  70. provide/foundation/hub/type_mapping.py +54 -0
  71. provide/foundation/hub/types.py +28 -0
  72. provide/foundation/logger/__init__.py +41 -0
  73. provide/foundation/logger/base.py +22 -0
  74. provide/foundation/logger/config/__init__.py +16 -0
  75. provide/foundation/logger/config/base.py +40 -0
  76. provide/foundation/logger/config/logging.py +394 -0
  77. provide/foundation/logger/config/telemetry.py +188 -0
  78. provide/foundation/logger/core.py +239 -0
  79. provide/foundation/logger/custom_processors.py +172 -0
  80. provide/foundation/logger/emoji/__init__.py +44 -0
  81. provide/foundation/logger/emoji/matrix.py +209 -0
  82. provide/foundation/logger/emoji/sets.py +458 -0
  83. provide/foundation/logger/emoji/types.py +56 -0
  84. provide/foundation/logger/factories.py +56 -0
  85. provide/foundation/logger/processors/__init__.py +13 -0
  86. provide/foundation/logger/processors/main.py +254 -0
  87. provide/foundation/logger/processors/trace.py +113 -0
  88. provide/foundation/logger/ratelimit/__init__.py +31 -0
  89. provide/foundation/logger/ratelimit/limiters.py +294 -0
  90. provide/foundation/logger/ratelimit/processor.py +203 -0
  91. provide/foundation/logger/ratelimit/queue_limiter.py +305 -0
  92. provide/foundation/logger/setup/__init__.py +29 -0
  93. provide/foundation/logger/setup/coordinator.py +138 -0
  94. provide/foundation/logger/setup/emoji_resolver.py +64 -0
  95. provide/foundation/logger/setup/processors.py +85 -0
  96. provide/foundation/logger/setup/testing.py +39 -0
  97. provide/foundation/logger/trace.py +38 -0
  98. provide/foundation/metrics/__init__.py +119 -0
  99. provide/foundation/metrics/otel.py +122 -0
  100. provide/foundation/metrics/simple.py +165 -0
  101. provide/foundation/observability/__init__.py +53 -0
  102. provide/foundation/observability/openobserve/__init__.py +79 -0
  103. provide/foundation/observability/openobserve/auth.py +72 -0
  104. provide/foundation/observability/openobserve/client.py +307 -0
  105. provide/foundation/observability/openobserve/commands.py +357 -0
  106. provide/foundation/observability/openobserve/exceptions.py +41 -0
  107. provide/foundation/observability/openobserve/formatters.py +298 -0
  108. provide/foundation/observability/openobserve/models.py +134 -0
  109. provide/foundation/observability/openobserve/otlp.py +320 -0
  110. provide/foundation/observability/openobserve/search.py +222 -0
  111. provide/foundation/observability/openobserve/streaming.py +235 -0
  112. provide/foundation/platform/__init__.py +44 -0
  113. provide/foundation/platform/detection.py +193 -0
  114. provide/foundation/platform/info.py +157 -0
  115. provide/foundation/process/__init__.py +39 -0
  116. provide/foundation/process/async_runner.py +373 -0
  117. provide/foundation/process/lifecycle.py +406 -0
  118. provide/foundation/process/runner.py +390 -0
  119. provide/foundation/setup/__init__.py +101 -0
  120. provide/foundation/streams/__init__.py +44 -0
  121. provide/foundation/streams/console.py +57 -0
  122. provide/foundation/streams/core.py +65 -0
  123. provide/foundation/streams/file.py +104 -0
  124. provide/foundation/testing/__init__.py +166 -0
  125. provide/foundation/testing/cli.py +227 -0
  126. provide/foundation/testing/crypto.py +163 -0
  127. provide/foundation/testing/fixtures.py +49 -0
  128. provide/foundation/testing/hub.py +23 -0
  129. provide/foundation/testing/logger.py +106 -0
  130. provide/foundation/testing/streams.py +54 -0
  131. provide/foundation/tracer/__init__.py +49 -0
  132. provide/foundation/tracer/context.py +115 -0
  133. provide/foundation/tracer/otel.py +135 -0
  134. provide/foundation/tracer/spans.py +174 -0
  135. provide/foundation/types.py +32 -0
  136. provide/foundation/utils/__init__.py +97 -0
  137. provide/foundation/utils/deps.py +195 -0
  138. provide/foundation/utils/env.py +491 -0
  139. provide/foundation/utils/formatting.py +483 -0
  140. provide/foundation/utils/parsing.py +235 -0
  141. provide/foundation/utils/rate_limiting.py +112 -0
  142. provide/foundation/utils/streams.py +67 -0
  143. provide/foundation/utils/timing.py +93 -0
  144. provide_foundation-0.0.0.dev0.dist-info/METADATA +469 -0
  145. provide_foundation-0.0.0.dev0.dist-info/RECORD +149 -0
  146. provide_foundation-0.0.0.dev0.dist-info/WHEEL +5 -0
  147. provide_foundation-0.0.0.dev0.dist-info/entry_points.txt +2 -0
  148. provide_foundation-0.0.0.dev0.dist-info/licenses/LICENSE +201 -0
  149. provide_foundation-0.0.0.dev0.dist-info/top_level.txt +1 -0
provide/__init__.py ADDED
@@ -0,0 +1,15 @@
1
+ """
2
+ Provide Namespace Package.
3
+
4
+ Provides easy access to common foundation components:
5
+ - logger: Foundation logging system
6
+ - config: Foundation configuration system
7
+ """
8
+
9
+ # Core imports for convenience
10
+ from provide.foundation import config, logger
11
+
12
+ __all__ = [
13
+ "config",
14
+ "logger",
15
+ ]
@@ -0,0 +1,155 @@
1
+ #
2
+ # __init__.py
3
+ #
4
+ """
5
+ Foundation Telemetry Library (structlog-based).
6
+ Primary public interface for the library, re-exporting common components.
7
+ """
8
+
9
+ # Export config module for easy access
10
+ # New foundation components
11
+ # Make the errors module available for detailed imports
12
+ from provide.foundation import config, errors, platform, process
13
+ from provide.foundation._version import __version__
14
+
15
+ # Console I/O functions (always available - handles click dependency internally)
16
+ from provide.foundation.console import perr, pin, pout
17
+ from provide.foundation.context import Context
18
+
19
+ # Error handling exports - only the essentials
20
+ from provide.foundation.errors import (
21
+ # Base exception only
22
+ FoundationError,
23
+ # Most commonly used handlers
24
+ error_boundary,
25
+ retry_on_error,
26
+ # Most commonly used decorators
27
+ with_error_handling,
28
+ )
29
+
30
+ # Hub and Registry exports (public API)
31
+ from provide.foundation.hub.components import ComponentCategory, get_component_registry
32
+ from provide.foundation.hub.manager import Hub, clear_hub, get_hub
33
+ from provide.foundation.hub.registry import Registry, RegistryEntry
34
+ from provide.foundation.logger import (
35
+ LoggingConfig,
36
+ TelemetryConfig,
37
+ get_logger, # Factory function for creating loggers
38
+ setup_logger, # Setup function (consistent naming)
39
+ setup_logging, # Setup function (backward compatibility)
40
+ )
41
+
42
+ # Emoji exports
43
+ from provide.foundation.logger.emoji.matrix import (
44
+ PRIMARY_EMOJI,
45
+ SECONDARY_EMOJI,
46
+ TERTIARY_EMOJI,
47
+ show_emoji_matrix,
48
+ )
49
+ from provide.foundation.logger.emoji.types import (
50
+ EmojiSet,
51
+ EmojiSetConfig,
52
+ FieldToEmojiMapping,
53
+ )
54
+ from provide.foundation.setup import (
55
+ setup_telemetry,
56
+ shutdown_foundation_telemetry,
57
+ )
58
+
59
+ # New type exports for emoji mapping
60
+ from provide.foundation.types import (
61
+ ConsoleFormatterStr,
62
+ LogLevelStr,
63
+ )
64
+
65
+ # New utility exports
66
+ from provide.foundation.utils import (
67
+ TokenBucketRateLimiter,
68
+ check_optional_deps,
69
+ timed_block,
70
+ )
71
+
72
+
73
+ # Lazy loading support for optional modules
74
+ def __getattr__(name: str):
75
+ """Support lazy loading of optional modules."""
76
+ if name == "cli":
77
+ try:
78
+ import provide.foundation.cli as cli
79
+
80
+ return cli
81
+ except ImportError as e:
82
+ if "click" in str(e):
83
+ raise ImportError(
84
+ "CLI features require optional dependencies. Install with: "
85
+ "pip install 'provide-foundation[cli]'"
86
+ ) from e
87
+ raise
88
+ elif name == "metrics":
89
+ import provide.foundation.metrics as metrics
90
+
91
+ return metrics
92
+ raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
93
+
94
+
95
+ __all__ = [
96
+ # Core Emoji Dictionaries (available for direct use or reference)
97
+ "PRIMARY_EMOJI",
98
+ "SECONDARY_EMOJI",
99
+ "TERTIARY_EMOJI",
100
+ "ConsoleFormatterStr",
101
+ # New foundation modules
102
+ "Context",
103
+ # Emoji Mapping classes
104
+ "EmojiSet",
105
+ # Error handling essentials
106
+ "FoundationError",
107
+ # Type aliases
108
+ "LogLevelStr",
109
+ "LoggingConfig",
110
+ # Hub and Registry (public API)
111
+ "Registry",
112
+ "RegistryEntry",
113
+ "Hub",
114
+ "ComponentCategory",
115
+ "get_component_registry",
116
+ "get_hub",
117
+ "clear_hub",
118
+ "FieldToEmojiMapping",
119
+ "EmojiSetConfig",
120
+ # Configuration classes
121
+ "TelemetryConfig",
122
+ # Version
123
+ "__version__",
124
+ # Dependency checking utility
125
+ "check_optional_deps",
126
+ # Config module
127
+ "config",
128
+ "error_boundary",
129
+ "errors", # The errors module for detailed imports
130
+ "get_logger",
131
+ # Core setup and logger
132
+ "logger",
133
+ # Console functions (work with or without click)
134
+ "perr",
135
+ "pin",
136
+ "pout",
137
+ "platform",
138
+ "process",
139
+ "retry_on_error",
140
+ "setup_logging", # Backward compatibility
141
+ "setup_logger", # Consistent naming
142
+ "setup_telemetry",
143
+ # Utilities
144
+ "show_emoji_matrix",
145
+ "shutdown_foundation_telemetry",
146
+ "timed_block",
147
+ # Rate limiting utilities
148
+ "TokenBucketRateLimiter",
149
+ "with_error_handling",
150
+ ]
151
+
152
+ # Import the logger instance after all other imports to avoid module shadowing
153
+ from provide.foundation.logger import logger
154
+
155
+ # 🐍📝
@@ -0,0 +1,58 @@
1
+ #
2
+ # version.py
3
+ #
4
+ """
5
+ Version handling for provide-foundation.
6
+ Integrates VERSION logic from flavorpack with robust fallback mechanisms.
7
+ """
8
+
9
+ from pathlib import Path
10
+
11
+
12
+ def _find_project_root() -> Path | None:
13
+ """Find the project root directory by looking for VERSION file."""
14
+ current = Path(__file__).parent
15
+
16
+ # Walk up the directory tree looking for VERSION file
17
+ while current != current.parent: # Stop at filesystem root
18
+ version_file = current / "VERSION"
19
+ if version_file.exists():
20
+ return current
21
+ current = current.parent
22
+
23
+ return None
24
+
25
+
26
+ def get_version() -> str:
27
+ """Get the current provide-foundation version.
28
+
29
+ Reads from VERSION file if it exists, otherwise falls back to package metadata,
30
+ then to default development version.
31
+
32
+ Returns:
33
+ str: The current version string
34
+ """
35
+ # Try VERSION file first (single source of truth)
36
+ project_root = _find_project_root()
37
+ if project_root:
38
+ version_file = project_root / "VERSION"
39
+ if version_file.exists():
40
+ try:
41
+ return version_file.read_text().strip()
42
+ except OSError:
43
+ # Fall back to metadata if VERSION file can't be read
44
+ pass
45
+
46
+ # Fallback to package metadata
47
+ try:
48
+ from importlib.metadata import PackageNotFoundError, version
49
+
50
+ return version("provide-foundation")
51
+ except PackageNotFoundError:
52
+ pass
53
+
54
+ # Final fallback
55
+ return "0.0.0-dev"
56
+
57
+
58
+ __version__ = get_version()
@@ -0,0 +1,67 @@
1
+ """
2
+ Foundation CLI utilities for consistent command-line interfaces.
3
+
4
+ Provides standard decorators, utilities, and patterns for building
5
+ CLI tools in the provide-io ecosystem.
6
+ """
7
+
8
+ from provide.foundation.cli.decorators import (
9
+ config_options,
10
+ error_handler,
11
+ flexible_options,
12
+ logging_options,
13
+ output_options,
14
+ pass_context,
15
+ standard_options,
16
+ version_option,
17
+ )
18
+ from provide.foundation.cli.testing import (
19
+ CliTestCase,
20
+ MockContext,
21
+ create_test_cli,
22
+ isolated_cli_runner,
23
+ mock_logger,
24
+ temp_config_file,
25
+ )
26
+ from provide.foundation.cli.utils import (
27
+ CliTestRunner,
28
+ assert_cli_error,
29
+ assert_cli_success,
30
+ create_cli_context,
31
+ echo_error,
32
+ echo_info,
33
+ echo_json,
34
+ echo_success,
35
+ echo_warning,
36
+ setup_cli_logging,
37
+ )
38
+
39
+ __all__ = [
40
+ "CliTestCase",
41
+ # Testing
42
+ "CliTestRunner",
43
+ "MockContext",
44
+ "assert_cli_error",
45
+ "assert_cli_success",
46
+ "config_options",
47
+ "create_cli_context",
48
+ "create_test_cli",
49
+ "echo_error",
50
+ "echo_info",
51
+ # Utilities
52
+ "echo_json",
53
+ "echo_success",
54
+ "echo_warning",
55
+ "error_handler",
56
+ "flexible_options",
57
+ "isolated_cli_runner",
58
+ # Decorators
59
+ "logging_options",
60
+ "mock_logger",
61
+ "output_options",
62
+ "pass_context",
63
+ "setup_cli_logging",
64
+ "standard_options",
65
+ "temp_config_file",
66
+ "version_option",
67
+ ]
@@ -0,0 +1,3 @@
1
+ """Foundation CLI commands."""
2
+
3
+ # This module provides CLI commands for foundation utilities
@@ -0,0 +1,71 @@
1
+ """CLI command for checking optional dependencies."""
2
+
3
+ try:
4
+ import click
5
+
6
+ _HAS_CLICK = True
7
+ except ImportError:
8
+ click = None
9
+ _HAS_CLICK = False
10
+
11
+ from provide.foundation.utils.deps import check_optional_deps
12
+
13
+
14
+ def _require_click():
15
+ """Ensure click is available for CLI commands."""
16
+ if not _HAS_CLICK:
17
+ raise ImportError(
18
+ "CLI commands require optional dependencies. "
19
+ "Install with: pip install 'provide-foundation[cli]'"
20
+ )
21
+
22
+
23
+ def _deps_command_impl(quiet: bool, check: str | None) -> None:
24
+ """Implementation of deps command logic."""
25
+ if check:
26
+ from provide.foundation.utils.deps import has_dependency
27
+
28
+ available = has_dependency(check)
29
+ if not quiet:
30
+ status = "✅" if available else "❌"
31
+ print(f"{status} {check}: {'Available' if available else 'Missing'}")
32
+ if not available:
33
+ print(f"Install with: pip install 'provide-foundation[{check}]'")
34
+ exit(0 if available else 1)
35
+ else:
36
+ # Check all dependencies
37
+ deps = check_optional_deps(quiet=quiet, return_status=True)
38
+ available_count = sum(1 for dep in deps if dep.available)
39
+ total_count = len(deps)
40
+ exit(0 if available_count == total_count else 1)
41
+
42
+
43
+ if _HAS_CLICK:
44
+
45
+ @click.command("deps")
46
+ @click.option(
47
+ "--quiet", "-q", is_flag=True, help="Suppress output, just return exit code"
48
+ )
49
+ @click.option(
50
+ "--check", metavar="DEPENDENCY", help="Check specific dependency only"
51
+ )
52
+ def deps_command(quiet: bool, check: str | None) -> None:
53
+ """Check optional dependency status.
54
+
55
+ Shows which optional dependencies are available and provides
56
+ installation instructions for missing ones.
57
+
58
+ Exit codes:
59
+ - 0: All dependencies available (or specific one if --check used)
60
+ - 1: Some dependencies missing (or specific one missing if --check used)
61
+ """
62
+ _deps_command_impl(quiet, check)
63
+ else:
64
+ # Stub for when click is not available
65
+ def deps_command(*args, **kwargs):
66
+ """Deps command stub when click is not available."""
67
+ _require_click()
68
+
69
+
70
+ # Export the command
71
+ __all__ = ["deps_command"]
@@ -0,0 +1,63 @@
1
+ """
2
+ Logs command group for Foundation CLI.
3
+
4
+ Provides commands for sending and querying logs with OpenTelemetry integration.
5
+ """
6
+
7
+ try:
8
+ import click
9
+
10
+ _HAS_CLICK = True
11
+ except ImportError:
12
+ click = None
13
+ _HAS_CLICK = False
14
+
15
+ from provide.foundation.logger import get_logger
16
+
17
+ log = get_logger(__name__)
18
+
19
+
20
+ if _HAS_CLICK:
21
+
22
+ @click.group("logs", help="Send and query logs with OpenTelemetry integration")
23
+ @click.pass_context
24
+ def logs_group(ctx):
25
+ """Logs management commands with OTEL correlation."""
26
+ # Store shared context
27
+ ctx.ensure_object(dict)
28
+
29
+ # Try to get OpenObserve client if available
30
+ try:
31
+ from provide.foundation.observability.openobserve import OpenObserveClient
32
+
33
+ ctx.obj["client"] = OpenObserveClient.from_config()
34
+ except Exception as e:
35
+ log.debug(f"OpenObserve client not available: {e}")
36
+ ctx.obj["client"] = None
37
+
38
+ # Import subcommands
39
+ from provide.foundation.cli.commands.logs.generate import (
40
+ generate_logs_command as generate_command,
41
+ )
42
+ from provide.foundation.cli.commands.logs.query import query_command
43
+ from provide.foundation.cli.commands.logs.send import send_command
44
+ from provide.foundation.cli.commands.logs.tail import tail_command
45
+
46
+ # Register subcommands
47
+ logs_group.add_command(send_command)
48
+ logs_group.add_command(query_command)
49
+ logs_group.add_command(tail_command)
50
+ logs_group.add_command(generate_command)
51
+
52
+ __all__ = ["logs_group"]
53
+
54
+ else:
55
+ # Stub when click is not available
56
+ def logs_group(*args, **kwargs):
57
+ """Logs command stub when click is not available."""
58
+ raise ImportError(
59
+ "CLI commands require optional dependencies. "
60
+ "Install with: pip install 'provide-foundation[cli]'"
61
+ )
62
+
63
+ __all__ = []