orionis 0.245.0__py3-none-any.whl → 0.247.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.
Files changed (108) hide show
  1. orionis/framework.py +1 -1
  2. orionis/luminate/config/app/__init__.py +10 -0
  3. orionis/luminate/config/app/entities/app.py +205 -0
  4. orionis/luminate/config/app/enums/ciphers.py +34 -0
  5. orionis/luminate/config/app/enums/environments.py +15 -0
  6. orionis/luminate/config/auth/__init__.py +7 -0
  7. orionis/luminate/config/auth/entities/auth.py +11 -0
  8. orionis/luminate/config/cache/__init__.py +9 -0
  9. orionis/luminate/config/cache/entities/cache.py +58 -0
  10. orionis/luminate/config/cache/entities/file.py +29 -0
  11. orionis/luminate/config/cache/entities/stores.py +35 -0
  12. orionis/luminate/config/cache/enums/drivers.py +12 -0
  13. orionis/luminate/config/contracts/config.py +27 -0
  14. orionis/luminate/config/entities/testing.py +215 -0
  15. orionis/luminate/config/exceptions/integrity_exception.py +30 -0
  16. orionis/luminate/console/dumper/dump_die.py +418 -0
  17. orionis/luminate/contracts/facades/commands/scheduler_facade.py +1 -1
  18. orionis/luminate/facades/files/path_facade.py +1 -1
  19. orionis/luminate/patterns/__init__.py +4 -0
  20. orionis/luminate/patterns/singleton/__init__.py +10 -0
  21. orionis/luminate/patterns/singleton/meta_class.py +56 -0
  22. orionis/luminate/providers/commands/reactor_commands_service_provider.py +3 -3
  23. orionis/luminate/providers/commands/scheduler_provider.py +1 -1
  24. orionis/luminate/providers/config/config_service_provider.py +1 -1
  25. orionis/luminate/providers/environment/environment__service_provider.py +2 -2
  26. orionis/luminate/providers/files/paths_provider.py +1 -1
  27. orionis/luminate/providers/log/log_service_provider.py +2 -2
  28. orionis/luminate/services/environment/__init__.py +10 -0
  29. orionis/luminate/services/environment/contracts/__init__.py +5 -0
  30. orionis/luminate/services/environment/contracts/env.py +93 -0
  31. orionis/luminate/services/environment/dot_env.py +293 -0
  32. orionis/luminate/services/environment/env.py +77 -0
  33. orionis/luminate/services/paths/__init__.py +9 -0
  34. orionis/luminate/services/paths/contracts/__init__.py +0 -0
  35. orionis/luminate/services/paths/contracts/resolver.py +67 -0
  36. orionis/luminate/services/paths/resolver.py +83 -0
  37. orionis/luminate/services/workers/__init__.py +10 -0
  38. orionis/luminate/services/workers/maximum_workers.py +36 -0
  39. orionis/luminate/services_/__init__.py +0 -0
  40. orionis/luminate/services_/commands/__init__.py +0 -0
  41. orionis/luminate/services_/config/__init__.py +0 -0
  42. orionis/luminate/services_/log/__init__.py +0 -0
  43. orionis/luminate/support/introspection/abstracts/entities/__init__.py +0 -0
  44. orionis/luminate/support/introspection/abstracts/entities/abstract_class_attributes.py +11 -0
  45. orionis/luminate/support/introspection/abstracts/reflect_abstract.py +154 -16
  46. orionis/luminate/support/introspection/instances/reflection_instance.py +2 -2
  47. orionis/luminate/test/__init__.py +11 -1
  48. orionis/luminate/test/cases/test_async.py +1 -10
  49. orionis/luminate/test/cases/test_case.py +8 -3
  50. orionis/luminate/test/cases/test_sync.py +1 -0
  51. orionis/luminate/test/core/contracts/test_suite.py +19 -31
  52. orionis/luminate/test/core/contracts/test_unit.py +103 -59
  53. orionis/luminate/test/core/test_suite.py +50 -42
  54. orionis/luminate/test/core/test_unit.py +756 -196
  55. orionis/luminate/test/entities/test_result.py +19 -18
  56. orionis/luminate/test/enums/test_mode.py +16 -0
  57. orionis/luminate/test/exceptions/test_config_exception.py +28 -0
  58. orionis/luminate/test/exceptions/test_exception.py +41 -34
  59. orionis/luminate/test/output/contracts/test_std_out.py +22 -11
  60. orionis/luminate/test/output/test_std_out.py +79 -48
  61. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/METADATA +4 -1
  62. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/RECORD +98 -61
  63. tests/config/__init__.py +0 -0
  64. tests/config/test_app.py +122 -0
  65. tests/config/test_auth.py +21 -0
  66. tests/config/test_cache.py +20 -0
  67. tests/patterns/__init__.py +0 -0
  68. tests/patterns/singleton/__init__.py +0 -0
  69. tests/patterns/singleton/test_singleton.py +18 -0
  70. tests/services/__init__.py +0 -0
  71. tests/services/environment/__init__.py +0 -0
  72. tests/services/environment/test_env.py +33 -0
  73. tests/support/inspection/fakes/fake_reflect_abstract.py +61 -5
  74. tests/support/inspection/test_reflect_abstract.py +62 -1
  75. tests/support/inspection/test_reflect_instance.py +0 -1
  76. orionis/luminate/config/app.py +0 -47
  77. orionis/luminate/config/auth.py +0 -15
  78. orionis/luminate/config/cache.py +0 -51
  79. orionis/luminate/support/environment/contracts/env.py +0 -68
  80. orionis/luminate/support/environment/env.py +0 -138
  81. orionis/luminate/support/environment/functions.py +0 -49
  82. orionis/luminate/support/environment/helper.py +0 -26
  83. orionis/luminate/support/patterns/singleton.py +0 -44
  84. tests/support/environment/test_env.py +0 -91
  85. tests/support/patterns/test_singleton.py +0 -18
  86. /orionis/luminate/{services/commands → config/app/entities}/__init__.py +0 -0
  87. /orionis/luminate/{services/config → config/app/enums}/__init__.py +0 -0
  88. /orionis/luminate/{services/log → config/auth/entities}/__init__.py +0 -0
  89. /orionis/luminate/{support/environment → config/cache/entities}/__init__.py +0 -0
  90. /orionis/luminate/{support/environment/contracts → config/cache/enums}/__init__.py +0 -0
  91. /orionis/luminate/{support/patterns → config/contracts}/__init__.py +0 -0
  92. /orionis/luminate/config/{cors.py → entities/cors.py} +0 -0
  93. /orionis/luminate/config/{database.py → entities/database.py} +0 -0
  94. /orionis/luminate/config/{filesystems.py → entities/filesystems.py} +0 -0
  95. /orionis/luminate/config/{logging.py → entities/logging.py} +0 -0
  96. /orionis/luminate/config/{mail.py → entities/mail.py} +0 -0
  97. /orionis/luminate/config/{queue.py → entities/queue.py} +0 -0
  98. /orionis/luminate/config/{session.py → entities/session.py} +0 -0
  99. {tests/support/environment → orionis/luminate/config/exceptions}/__init__.py +0 -0
  100. {tests/support/patterns → orionis/luminate/console/dumper}/__init__.py +0 -0
  101. /orionis/luminate/{services → services_}/commands/reactor_commands_service.py +0 -0
  102. /orionis/luminate/{services → services_}/commands/scheduler_service.py +0 -0
  103. /orionis/luminate/{services → services_}/config/config_service.py +0 -0
  104. /orionis/luminate/{services → services_}/log/log_service.py +0 -0
  105. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/LICENCE +0 -0
  106. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/WHEEL +0 -0
  107. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/entry_points.txt +0 -0
  108. {orionis-0.245.0.dist-info → orionis-0.247.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,215 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Any, List
3
+ from orionis.luminate.config.exceptions.integrity_exception import OrionisIntegrityException
4
+ from orionis.luminate.services.workers.maximum_workers import MaximumWorkers
5
+
6
+ def defaultExecutionMode() -> Any:
7
+ """
8
+ This function is a placeholder for the ExecutionMode enumeration.
9
+ In a real-world scenario, this would be replaced with the actual import statement.
10
+ """
11
+ from orionis.luminate.test.enums.test_mode import ExecutionMode
12
+ return ExecutionMode.SEQUENTIAL
13
+
14
+ @dataclass(frozen=True, kw_only=True, slots=True)
15
+ class Testing:
16
+ """
17
+ Testing is a dataclass that holds configuration options for running tests.
18
+
19
+ Attributes:
20
+ verbosity (int): The verbosity level of the test output. Default is 2.
21
+ - 0: Silent
22
+ - 1: Minimal output
23
+ - 2: Detailed output (default)
24
+ execution_mode (ExecutionMode): The mode of test execution. Default is ExecutionMode.SEQUENTIAL.
25
+ - ExecutionMode.SEQUENTIAL: Tests are executed one after another.
26
+ - ExecutionMode.PARALLEL: Tests are executed in parallel.
27
+ max_workers (int): The maximum number of worker threads/processes to use when running tests in parallel. Default is 4.
28
+ fail_fast (bool): Whether to stop execution after the first test failure. Default is False.
29
+ print_result (bool): Whether to print the test results to the console. Default is True.
30
+ throw_exception (bool): Whether to throw an exception if a test fails. Default is False.
31
+ base_path (str): The base directory where tests are located. Default is 'tests'.
32
+ folder_path (str): The folder path pattern to search for tests. Default is '*'.
33
+ pattern (str): The filename pattern to identify test files. Default is 'test_*.py'.
34
+ test_name_pattern (str | None): A pattern to match specific test names. Default is None.
35
+ tags (List[str] | None): A list of tags to filter tests. Default is None.
36
+ """
37
+ verbosity: int = field(
38
+ default=2,
39
+ metadata={
40
+ "description": "The verbosity level of the test output. Default is 2.",
41
+ "required": True,
42
+ "default": 2
43
+ }
44
+ )
45
+
46
+ execution_mode : Any = field(
47
+ default_factory=lambda: defaultExecutionMode(),
48
+ metadata={
49
+ "description": "The mode of test execution. Default is ExecutionMode.SEQUENTIAL.",
50
+ "required": True,
51
+ "default": "ExecutionMode.SEQUENTIAL"
52
+ }
53
+ )
54
+
55
+ max_workers: int = field(
56
+ default_factory=lambda : MaximumWorkers().calculate(),
57
+ metadata={
58
+ "description": "The maximum number of worker threads/processes to use when running tests in parallel. Default is 4.",
59
+ "required": True,
60
+ "default": "MaximumWorkers.calculate()"
61
+ }
62
+ )
63
+
64
+ fail_fast: bool = field(
65
+ default=False,
66
+ metadata={
67
+ "description": "Whether to stop execution after the first test failure. Default is False.",
68
+ "required": True,
69
+ "default": False
70
+ }
71
+ )
72
+
73
+ print_result: bool = field(
74
+ default=True,
75
+ metadata={
76
+ "description": "Whether to print the test results to the console. Default is True.",
77
+ "required": True,
78
+ "default": True
79
+ }
80
+ )
81
+
82
+ throw_exception: bool = field(
83
+ default=False,
84
+ metadata={
85
+ "description": "Whether to throw an exception if a test fails. Default is False.",
86
+ "required": True,
87
+ "default": False
88
+ }
89
+ )
90
+
91
+ base_path: str = field(
92
+ default='tests',
93
+ metadata={
94
+ "description": "The base directory where tests are located. Default is 'tests'.",
95
+ "required": True,
96
+ "default": 'tests'
97
+ }
98
+ )
99
+
100
+ folder_path: str | list = field(
101
+ default='*',
102
+ metadata={
103
+ "description": "The folder path pattern to search for tests. Default is '*'.",
104
+ "required": True,
105
+ "default": '*'
106
+ }
107
+ )
108
+
109
+ pattern: str = field(
110
+ default='test_*.py',
111
+ metadata={
112
+ "description": "The filename pattern to identify test files. Default is 'test_*.py'.",
113
+ "required": True,
114
+ "default": 'test_*.py'
115
+ }
116
+ )
117
+
118
+ test_name_pattern: str | None = field(
119
+ default=None,
120
+ metadata={
121
+ "description": "A pattern to match specific test names. Default is None.",
122
+ "required": False,
123
+ "default": None
124
+ }
125
+ )
126
+
127
+ tags: List[str] | None = field(
128
+ default_factory=lambda:[],
129
+ metadata={
130
+ "description": "A list of tags to filter tests. Default is an empty list.",
131
+ "required": False,
132
+ "default": []
133
+ }
134
+ )
135
+
136
+ def __post_init__(self):
137
+ """
138
+ Post-initialization validation for the testing configuration entity.
139
+ This method performs type and value checks on the instance attributes to ensure they meet the expected constraints:
140
+ - `verbosity` must be an integer between 0 and 2 (inclusive).
141
+ - `execution_mode` must not be None.
142
+ - `max_workers` must be a positive integer.
143
+ - `fail_fast`, `print_result`, and `throw_exception` must be booleans.
144
+ - `base_path`, `folder_path`, and `pattern` must be strings.
145
+ - `test_name_pattern` must be either a string or None.
146
+ - `tags` must be either None or a list of strings.
147
+ Raises:
148
+ OrionisIntegrityException: If any of the attributes do not meet the specified constraints.
149
+ """
150
+ if not isinstance(self.verbosity, int) or self.verbosity < 0 or self.verbosity > 2:
151
+ raise OrionisIntegrityException(
152
+ f"Invalid value for 'verbosity': {self.verbosity}. It must be an integer between 0 (silent) and 2 (detailed output)."
153
+ )
154
+
155
+ if self.execution_mode is None:
156
+ raise OrionisIntegrityException(
157
+ "'execution_mode' cannot be None. Please provide a valid ExecutionMode value."
158
+ )
159
+
160
+ if not isinstance(self.max_workers, int) or self.max_workers < 1:
161
+ raise OrionisIntegrityException(
162
+ f"Invalid value for 'max_workers': {self.max_workers}. It must be a positive integer greater than 0."
163
+ )
164
+
165
+ if not isinstance(self.fail_fast, bool):
166
+ raise OrionisIntegrityException(
167
+ f"Invalid type for 'fail_fast': {type(self.fail_fast).__name__}. It must be a boolean (True or False)."
168
+ )
169
+
170
+ if not isinstance(self.print_result, bool):
171
+ raise OrionisIntegrityException(
172
+ f"Invalid type for 'print_result': {type(self.print_result).__name__}. It must be a boolean (True or False)."
173
+ )
174
+
175
+ if not isinstance(self.throw_exception, bool):
176
+ raise OrionisIntegrityException(
177
+ f"Invalid type for 'throw_exception': {type(self.throw_exception).__name__}. It must be a boolean (True or False)."
178
+ )
179
+
180
+ if not isinstance(self.base_path, str):
181
+ raise OrionisIntegrityException(
182
+ f"Invalid type for 'base_path': {type(self.base_path).__name__}. It must be a string representing the base directory for tests."
183
+ )
184
+
185
+ if not (isinstance(self.folder_path, str) or isinstance(self.folder_path, list)):
186
+ raise OrionisIntegrityException(
187
+ f"Invalid type for 'folder_path': {type(self.folder_path).__name__}. It must be a string or a list of strings representing the folder path pattern."
188
+ )
189
+ if isinstance(self.folder_path, list):
190
+ for i, folder in enumerate(self.folder_path):
191
+ if not isinstance(folder, str):
192
+ raise OrionisIntegrityException(
193
+ f"Invalid type for folder at index {i} in 'folder_path': {type(folder).__name__}. Each folder path must be a string."
194
+ )
195
+
196
+ if not isinstance(self.pattern, str):
197
+ raise OrionisIntegrityException(
198
+ f"Invalid type for 'pattern': {type(self.pattern).__name__}. It must be a string representing the filename pattern for test files."
199
+ )
200
+
201
+ if self.test_name_pattern is not None and not isinstance(self.test_name_pattern, str):
202
+ raise OrionisIntegrityException(
203
+ f"Invalid type for 'test_name_pattern': {type(self.test_name_pattern).__name__}. It must be a string or None."
204
+ )
205
+
206
+ if self.tags is not None:
207
+ if not isinstance(self.tags, list):
208
+ raise OrionisIntegrityException(
209
+ f"Invalid type for 'tags': {type(self.tags).__name__}. It must be a list of strings or None."
210
+ )
211
+ for i, tag in enumerate(self.tags):
212
+ if not isinstance(tag, str):
213
+ raise OrionisIntegrityException(
214
+ f"Invalid type for tag at index {i} in 'tags': {type(tag).__name__}. Each tag must be a string."
215
+ )
@@ -0,0 +1,30 @@
1
+ class OrionisIntegrityException(Exception):
2
+ """
3
+ Exception raised for integrity-related errors within the Orionis framework configuration.
4
+ This exception is intended to signal issues or inconsistencies detected in the test configuration,
5
+ helping developers quickly identify and resolve configuration problems. It provides a clear,
6
+ contextual error message to facilitate debugging and maintain the integrity of the framework's setup.
7
+ Attributes:
8
+ msg (str): Human-readable description of the integrity error.
9
+ Example:
10
+ raise OrionisIntegrityException("Duplicate test case identifier found in configuration.")
11
+ msg (str): Detailed explanation of the integrity violation encountered.
12
+ """
13
+
14
+ def __init__(self, msg: str):
15
+ """
16
+ Initializes the exception with a custom error message.
17
+
18
+ Args:
19
+ msg (str): The error message describing the exception.
20
+ """
21
+ super().__init__(msg)
22
+
23
+ def __str__(self) -> str:
24
+ """
25
+ Return a string representation of the exception, including the class name and the first argument.
26
+
27
+ Returns:
28
+ str: A string in the format '<ClassName>: <first argument>'.
29
+ """
30
+ return f"{self.__class__.__name__}: {self.args[0]}"
@@ -0,0 +1,418 @@
1
+ import os
2
+ import sys
3
+ import inspect
4
+ import json
5
+ from typing import Any
6
+ from datetime import datetime
7
+ from dataclasses import is_dataclass
8
+ from rich.console import Console
9
+ from rich.panel import Panel
10
+ from rich.table import Table
11
+ from rich.syntax import Syntax
12
+ from rich.traceback import install
13
+
14
+ class Debug:
15
+ """
16
+ Debugging utility class for enhanced output and inspection of Python objects.
17
+ This class provides methods for dumping and inspecting data in various formats,
18
+ including plain text, JSON, and tabular representations. It also supports
19
+ rendering nested structures with recursion handling and customizable indentation.
20
+ """
21
+
22
+ def __init__(self, line:str = None) -> None:
23
+ """
24
+ Initializes the class instance.
25
+
26
+ This constructor sets up the necessary components for the class, including:
27
+ - Installing required dependencies or configurations.
28
+ - Initializing a console for output handling.
29
+ - Setting the default indentation size for formatting.
30
+ - Creating a set to guard against recursion during operations.
31
+ """
32
+ install()
33
+ self.console = Console()
34
+ self.indent_size = 4
35
+ self._recursion_guard = set()
36
+ self.line_tcbk = line
37
+
38
+ def dd(self, *args: Any) -> None:
39
+ """
40
+ Dumps the provided arguments to the output and exits the program.
41
+
42
+ Args:
43
+ *args (Any): Variable length argument list to be processed and output.
44
+
45
+ Returns:
46
+ None
47
+ """
48
+ self.__processOutput(*args, exit_after=True)
49
+
50
+ def dump(self, *args: Any) -> None:
51
+ """
52
+ Dumps the provided arguments for debugging or logging purposes.
53
+
54
+ Args:
55
+ *args (Any): Variable length argument list to be processed and output.
56
+
57
+ Returns:
58
+ None
59
+ """
60
+ self.__processOutput(*args, exit_after=False)
61
+
62
+ def __processOutput(self, *args: Any, exit_after: bool) -> None:
63
+ """
64
+ Processes the output based on the provided arguments and determines the appropriate
65
+ format for displaying the data (tabular, JSON, or raw dump). Handles exceptions
66
+ during processing and optionally exits the program.
67
+
68
+ Args:
69
+ *args (Any): Variable-length arguments representing the data to be processed.
70
+ exit_after (bool): If True, the program will exit after processing the output.
71
+
72
+ Raises:
73
+ Exception: Catches and logs any exception that occurs during processing. If
74
+ `exit_after` is True, the program will terminate with an exit code of 1.
75
+ """
76
+ try:
77
+ if not args:
78
+ raise ValueError("No arguments were provided, or the arguments are null or invalid")
79
+ elif len(args) == 1:
80
+ arg = args[0]
81
+ if self.__isJsonSerializable(arg) and self.__isTabular(arg) and isinstance(arg, (list)):
82
+ self.__printTable(arg)
83
+ elif self.__isJsonSerializable(arg):
84
+ self.__printJson(arg)
85
+ else:
86
+ self.__printDump(args)
87
+ else:
88
+ self.__printDump(args)
89
+ except Exception as e:
90
+ self.__printStandardPanel(
91
+ f"[bold red]An error occurred while processing the debug output: {str(e)}[/]",
92
+ border_style="red",
93
+ )
94
+ finally:
95
+ if exit_after:
96
+ os._exit(1)
97
+
98
+ def __printDump(self, args: tuple) -> None:
99
+ """
100
+ Prints a formatted dump of the provided arguments to the console and optionally exits the program.
101
+ Args:
102
+ args (tuple): A tuple containing the objects to be dumped and displayed.
103
+ Returns:
104
+ None
105
+ """
106
+ content = []
107
+ for arg in args:
108
+ self._recursion_guard.clear()
109
+ content.append(self.__render(arg))
110
+
111
+ self.__printStandardPanel(
112
+ Syntax(
113
+ "\n".join(content),
114
+ "python",
115
+ line_numbers=False,
116
+ background_color="default",
117
+ word_wrap=True
118
+ ),
119
+ border_style="cyan bold",
120
+ )
121
+
122
+ def __printJson(self, data: Any) -> None:
123
+ """
124
+ Prints a JSON representation of the given data to the console using a styled panel.
125
+ Args:
126
+ data (Any): The data to be serialized and displayed as JSON.
127
+ Raises:
128
+ TypeError: If the data cannot be serialized to JSON, falls back to a generic dump method.
129
+ Notes:
130
+ - Uses the `rich` library to format and display the JSON output with syntax highlighting.
131
+ - Retrieves and displays the caller's line information for context.
132
+ - Handles non-serializable objects using a custom JSON serializer.
133
+ """
134
+ try:
135
+ if not isinstance(data, (dict, list)):
136
+ raise TypeError("Data must be a dictionary or a list for JSON serialization.")
137
+
138
+ json_str = json.dumps(data, ensure_ascii=False, indent=2, default=self.__jsonSerializer)
139
+ self.__printStandardPanel(
140
+ Syntax(
141
+ json_str,
142
+ "json",
143
+ line_numbers=True,
144
+ background_color="default",
145
+ word_wrap=True
146
+ ),
147
+ border_style="green",
148
+ )
149
+ except TypeError as e:
150
+ self.__printDump((data,))
151
+
152
+ def __printTable(self, data: Any) -> None:
153
+ """
154
+ Prints a formatted table representation of the given data using the `rich` library.
155
+ Args:
156
+ data (Any): The data to be displayed in the table. It can be a list, dictionary,
157
+ or an object with attributes.
158
+ Behavior:
159
+ - If `data` is a list:
160
+ - If the list is empty, prints a message indicating an empty list.
161
+ - If the list contains dictionaries, uses the dictionary keys as column headers.
162
+ - If the list contains objects with attributes, uses the attribute names as column headers.
163
+ - Otherwise, displays the index and value of each item in the list.
164
+ - If `data` is a dictionary:
165
+ - Displays the keys and values as two columns.
166
+ - If an exception occurs during processing, calls `__printDump` to handle the error.
167
+ Note:
168
+ This method relies on the `rich.Table` class for rendering the table and assumes
169
+ the presence of a `console` object for output and a `__printStandardPanel` method
170
+ for displaying the table with a border.
171
+ """
172
+ try:
173
+ table = Table(
174
+ show_header=True,
175
+ header_style="bold white on blue",
176
+ min_width=(self.console.width // 4) * 3
177
+ )
178
+
179
+ if isinstance(data, list):
180
+ if not data:
181
+ self.console.print("[yellow]Empty list[/]")
182
+ return
183
+
184
+ first = data[0]
185
+ if isinstance(first, dict):
186
+ columns = list(first.keys())
187
+ elif hasattr(first, '__dict__'):
188
+ columns = list(vars(first).keys())
189
+ else:
190
+ columns = ["Index", "Value"]
191
+
192
+ for col in columns:
193
+ table.add_column(str(col))
194
+
195
+ for i, item in enumerate(data):
196
+ if isinstance(item, dict):
197
+ table.add_row(*[str(item.get(col, '')) for col in columns])
198
+ elif hasattr(item, '__dict__'):
199
+ item_dict = vars(item)
200
+ table.add_row(*[str(item_dict.get(col, '')) for col in columns])
201
+ else:
202
+ table.add_row(str(i), str(item))
203
+
204
+ elif isinstance(data, dict):
205
+ table.add_column("Key", style="magenta")
206
+ table.add_column("Value")
207
+
208
+ for k, v in data.items():
209
+ table.add_row(str(k), str(v))
210
+
211
+ self.__printStandardPanel(
212
+ table,
213
+ border_style="blue",
214
+ )
215
+ except Exception as e:
216
+ self.__printDump((data,))
217
+
218
+ def __printStandardPanel(self, renderable, border_style: str, padding=(0, 1)) -> None:
219
+ """
220
+ Renders a standard panel with the given content and styling options.
221
+ Args:
222
+ renderable: The content to be displayed inside the panel. This can be any renderable object.
223
+ border_style (str): The style of the border for the panel.
224
+ padding (tuple, optional): A tuple specifying the padding inside the panel as (vertical, horizontal). Defaults to (0, 0).
225
+ expand (bool, optional): Whether the panel should expand to fill available space. Defaults to False.
226
+ Returns:
227
+ None
228
+ """
229
+ if self.line_tcbk is None:
230
+ frame = inspect.currentframe()
231
+ caller_frame = frame.f_back.f_back if frame else None
232
+ line_info = f"[blue underline]{self.__getLineInfo(caller_frame) if caller_frame else 'Unknown location'}[/]"
233
+ else:
234
+ line_info = f"[blue underline]{self.line_tcbk}[/]"
235
+
236
+ subtitle = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
237
+
238
+ self.console.print()
239
+ self.console.print(Panel(
240
+ renderable,
241
+ title=f"Debugger - {line_info}",
242
+ title_align='left',
243
+ subtitle=subtitle,
244
+ subtitle_align='right',
245
+ border_style=border_style,
246
+ highlight=True,
247
+ padding=padding,
248
+ width=(self.console.width // 4) * 3,
249
+ ))
250
+ self.console.print()
251
+
252
+ def __isTabular(self, data: Any) -> bool:
253
+ """
254
+ Determines if the given data is in a tabular format.
255
+
256
+ A data structure is considered tabular if it is a list or a dictionary.
257
+ For lists, it further checks if the first element is either a dictionary
258
+ or an object with attributes (i.e., has a `__dict__` attribute).
259
+
260
+ Args:
261
+ data (Any): The data to be checked.
262
+
263
+ Returns:
264
+ bool: True if the data is tabular, False otherwise.
265
+ """
266
+
267
+ if isinstance(data, list):
268
+ if all(isinstance(item, dict) for item in data):
269
+ keys = set(data[0].keys())
270
+ return all(set(item.keys()) == keys for item in data)
271
+ if len(data) > 0 and hasattr(data[0], '__dict__'):
272
+ return True
273
+ elif isinstance(data, dict):
274
+ return True
275
+ return False
276
+
277
+ def __isJsonSerializable(self, data: Any) -> bool:
278
+ """
279
+ Determines if the given data is JSON serializable.
280
+
281
+ This method attempts to serialize the provided data into a JSON string
282
+ using a custom serializer. If the serialization succeeds, the data is
283
+ considered JSON serializable. Otherwise, it is not.
284
+
285
+ Args:
286
+ data (Any): The data to check for JSON serializability.
287
+
288
+ Returns:
289
+ bool: True if the data is JSON serializable, False otherwise.
290
+ """
291
+ try:
292
+ json.dumps(data, default=self.__jsonSerializer)
293
+ return True
294
+ except (TypeError, OverflowError):
295
+ return False
296
+
297
+ def __render(self, value: Any, indent: int = 0, key: Any = None, depth: int = 0) -> str:
298
+ """
299
+ Recursively renders a string representation of a given value with customizable indentation,
300
+ handling various data types, recursion, and depth limits.
301
+ Args:
302
+ value (Any): The value to render. Can be of any type, including dict, list, tuple, set,
303
+ dataclass, or objects with a `__dict__` attribute.
304
+ indent (int, optional): The current indentation level. Defaults to 0.
305
+ key (Any, optional): The key or index associated with the value, if applicable. Defaults to None.
306
+ depth (int, optional): The current recursion depth. Defaults to 0.
307
+ Returns:
308
+ str: A string representation of the value, formatted with indentation and type information.
309
+ Notes:
310
+ - Limits recursion depth to 10 to prevent infinite loops.
311
+ - Detects and handles recursive references to avoid infinite recursion.
312
+ - Supports rendering of common Python data structures, dataclasses, and objects with attributes.
313
+ - Formats datetime objects and callable objects with additional details.
314
+ """
315
+
316
+ if depth > 10:
317
+ return "... (max depth)"
318
+
319
+ obj_id = id(value)
320
+ if obj_id in self._recursion_guard:
321
+ return "... (recursive)"
322
+ self._recursion_guard.add(obj_id)
323
+
324
+ space = ' ' * indent
325
+ prefix = f"{space}"
326
+
327
+ if key is not None:
328
+ prefix += f"{self.__formatKey(key)} => "
329
+
330
+ if value is None:
331
+ result = f"{prefix}None"
332
+ elif isinstance(value, dict):
333
+ result = f"{prefix}dict({len(value)})"
334
+ for k, v in value.items():
335
+ result += "\n" + self.__render(v, indent + self.indent_size, k, depth + 1)
336
+ elif isinstance(value, (list, tuple, set)):
337
+ type_name = type(value).__name__
338
+ result = f"{prefix}{type_name}({len(value)})"
339
+ for i, item in enumerate(value):
340
+ result += "\n" + self.__render(
341
+ item,
342
+ indent + self.indent_size,
343
+ i if isinstance(value, (list, tuple)) else None,
344
+ depth + 1
345
+ )
346
+ elif is_dataclass(value):
347
+ result = f"{prefix}{value.__class__.__name__}"
348
+ for k, v in vars(value).items():
349
+ result += "\n" + self.__render(v, indent + self.indent_size, k, depth + 1)
350
+ elif hasattr(value, "__dict__"):
351
+ result = f"{prefix}{value.__class__.__name__}"
352
+ for k, v in vars(value).items():
353
+ result += "\n" + self.__render(v, indent + self.indent_size, k, depth + 1)
354
+ elif isinstance(value, datetime):
355
+ result = f"{prefix}datetime({value.isoformat()})"
356
+ elif callable(value):
357
+ result = f"{prefix}callable({value.__name__ if hasattr(value, '__name__') else repr(value)})"
358
+ else:
359
+ result = f"{prefix}{type(value).__name__}({repr(value)})"
360
+
361
+ self._recursion_guard.discard(obj_id)
362
+ return result
363
+
364
+ @staticmethod
365
+ def __jsonSerializer(obj):
366
+ """
367
+ Serialize an object into a JSON-compatible format.
368
+ Args:
369
+ obj: The object to serialize. Supported types include:
370
+ - datetime: Converted to ISO 8601 string format.
371
+ - Objects with a `__dict__` attribute: Converted to a dictionary of their attributes.
372
+ - set or tuple: Converted to a list.
373
+ Returns:
374
+ A JSON-serializable representation of the input object.
375
+ Raises:
376
+ TypeError: If the object type is not supported for JSON serialization.
377
+ """
378
+ if isinstance(obj, datetime):
379
+ return obj.isoformat()
380
+ elif hasattr(obj, '__dict__'):
381
+ return vars(obj)
382
+ elif isinstance(obj, (set, tuple)):
383
+ return list(obj)
384
+ raise TypeError(f"Object of type {obj.__class__.__name__} is not JSON serializable")
385
+
386
+ @staticmethod
387
+ def __formatKey(key: Any) -> str:
388
+ """
389
+ Formats a given key into a string representation.
390
+
391
+ Args:
392
+ key (Any): The key to be formatted. It can be of any type.
393
+
394
+ Returns:
395
+ str: A string representation of the key. If the key is a string, it is
396
+ enclosed in double quotes. Otherwise, the string representation of the
397
+ key is returned as-is.
398
+ """
399
+ if isinstance(key, str):
400
+ return f'"{key}"'
401
+ return str(key)
402
+
403
+ @staticmethod
404
+ def __getLineInfo(frame: inspect.FrameInfo) -> str:
405
+ """
406
+ Extracts and formats line information from a given frame.
407
+
408
+ Args:
409
+ frame (inspect.FrameInfo): The frame object containing code context.
410
+
411
+ Returns:
412
+ str: A string in the format "filename:line_no", where `filename` is the
413
+ name of the file (excluding the path) and `line_no` is the line number
414
+ in the file where the frame is located.
415
+ """
416
+ filename = frame.f_code.co_filename.split('/')[-1]
417
+ line_no = frame.f_lineno
418
+ return f"{filename}:{line_no}"
@@ -1,6 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from typing import Any
3
- from orionis.luminate.services.commands.scheduler_service import ScheduleService
3
+ from orionis.luminate.services_.commands.scheduler_service import ScheduleService
4
4
 
5
5
  class ISchedule(ABC):
6
6
 
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  from orionis.luminate.contracts.facades.files.path_facade import IPath
3
3
  from orionis.luminate.contracts.services.files.path_resolver_service import IPathResolverService
4
- from orionis.luminate.services.files.path_resolver_service import PathResolverService
4
+ from orionis.luminate.services_.files.path_resolver_service import PathResolverService
5
5
 
6
6
  class Path(IPath):
7
7
  """
@@ -0,0 +1,4 @@
1
+ __description__ = (
2
+ "Modules:\n"
3
+ " - singleton: Provides a singleton metaclass to ensure a class has only one instance.\n"
4
+ )