orionis 0.1.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.
- orionis/__init__.py +0 -0
- orionis/cli_manager.py +48 -0
- orionis/framework.py +45 -0
- orionis/luminate/__init__.py +0 -0
- orionis/luminate/app.py +0 -0
- orionis/luminate/bootstrap/__init__.py +0 -0
- orionis/luminate/bootstrap/parser.py +49 -0
- orionis/luminate/bootstrap/register.py +95 -0
- orionis/luminate/cache/__init__.py +0 -0
- orionis/luminate/cache/app/__init__.py +0 -0
- orionis/luminate/cache/app/config.py +96 -0
- orionis/luminate/cache/console/__init__.py +0 -0
- orionis/luminate/cache/console/commands.py +98 -0
- orionis/luminate/config/__init__.py +0 -0
- orionis/luminate/config/dataclass/__init__.py +0 -0
- orionis/luminate/config/dataclass/app.py +50 -0
- orionis/luminate/config/dataclass/auth.py +17 -0
- orionis/luminate/config/dataclass/cache.py +51 -0
- orionis/luminate/config/dataclass/cors.py +58 -0
- orionis/luminate/config/dataclass/database.py +203 -0
- orionis/luminate/config/dataclass/filesystems.py +102 -0
- orionis/luminate/config/dataclass/logging.py +107 -0
- orionis/luminate/config/dataclass/mail.py +81 -0
- orionis/luminate/config/dataclass/queue.py +63 -0
- orionis/luminate/config/dataclass/session.py +59 -0
- orionis/luminate/config/environment.py +110 -0
- orionis/luminate/config/sections.py +37 -0
- orionis/luminate/console/__init__.py +0 -0
- orionis/luminate/console/base/__init__.py +0 -0
- orionis/luminate/console/base/command.py +427 -0
- orionis/luminate/console/cache.py +132 -0
- orionis/luminate/console/command.py +40 -0
- orionis/luminate/console/command_filter.py +40 -0
- orionis/luminate/console/commands/__init__.py +0 -0
- orionis/luminate/console/commands/cache_clear.py +56 -0
- orionis/luminate/console/commands/help.py +59 -0
- orionis/luminate/console/commands/schedule_work.py +50 -0
- orionis/luminate/console/commands/tests.py +40 -0
- orionis/luminate/console/commands/version.py +39 -0
- orionis/luminate/console/exceptions/__init__.py +0 -0
- orionis/luminate/console/exceptions/cli_exception.py +125 -0
- orionis/luminate/console/kernel.py +32 -0
- orionis/luminate/console/output/__init__.py +0 -0
- orionis/luminate/console/output/console.py +426 -0
- orionis/luminate/console/output/executor.py +90 -0
- orionis/luminate/console/output/progress_bar.py +100 -0
- orionis/luminate/console/output/styles.py +95 -0
- orionis/luminate/console/parser.py +159 -0
- orionis/luminate/console/register.py +98 -0
- orionis/luminate/console/runner.py +126 -0
- orionis/luminate/console/scripts/__init__.py +0 -0
- orionis/luminate/console/scripts/management.py +94 -0
- orionis/luminate/console/tasks/__init__.py +0 -0
- orionis/luminate/console/tasks/scheduler.py +616 -0
- orionis/luminate/contracts/__init__.py +0 -0
- orionis/luminate/contracts/bootstrap/parser_interface.py +46 -0
- orionis/luminate/contracts/cache/__init__.py +0 -0
- orionis/luminate/contracts/cache/cache_commands_interface.py +69 -0
- orionis/luminate/contracts/config/__init__.py +0 -0
- orionis/luminate/contracts/config/config_interface.py +27 -0
- orionis/luminate/contracts/config/environment_interface.py +64 -0
- orionis/luminate/contracts/console/__init__.py +0 -0
- orionis/luminate/contracts/console/base_command_interface.py +448 -0
- orionis/luminate/contracts/console/cli_cache_interface.py +34 -0
- orionis/luminate/contracts/console/command_filter_interface.py +32 -0
- orionis/luminate/contracts/console/command_interface.py +36 -0
- orionis/luminate/contracts/console/console_interface.py +305 -0
- orionis/luminate/contracts/console/executor_interface.py +51 -0
- orionis/luminate/contracts/console/kernel_interface.py +32 -0
- orionis/luminate/contracts/console/management_interface.py +63 -0
- orionis/luminate/contracts/console/parser_interface.py +76 -0
- orionis/luminate/contracts/console/progress_bar_interface.py +66 -0
- orionis/luminate/contracts/console/register_interface.py +32 -0
- orionis/luminate/contracts/console/runner_interface.py +50 -0
- orionis/luminate/contracts/console/schedule_interface.py +317 -0
- orionis/luminate/contracts/console/task_manager_interface.py +37 -0
- orionis/luminate/contracts/facades/__init__.py +0 -0
- orionis/luminate/contracts/facades/env_interface.py +64 -0
- orionis/luminate/contracts/facades/log_interface.py +48 -0
- orionis/luminate/contracts/facades/paths_interface.py +141 -0
- orionis/luminate/contracts/facades/tests_interface.py +33 -0
- orionis/luminate/contracts/files/__init__.py +0 -0
- orionis/luminate/contracts/files/paths_interface.py +29 -0
- orionis/luminate/contracts/installer/__init__.py +0 -0
- orionis/luminate/contracts/installer/output_interface.py +125 -0
- orionis/luminate/contracts/installer/setup_interface.py +29 -0
- orionis/luminate/contracts/installer/upgrade_interface.py +24 -0
- orionis/luminate/contracts/log/__init__.py +0 -0
- orionis/luminate/contracts/log/logger_interface.py +33 -0
- orionis/luminate/contracts/pipelines/cli_pipeline_interface.py +84 -0
- orionis/luminate/contracts/publisher/__init__.py +0 -0
- orionis/luminate/contracts/publisher/pypi_publisher_interface.py +36 -0
- orionis/luminate/contracts/test/__init__.py +0 -0
- orionis/luminate/contracts/test/unit_test_interface.py +51 -0
- orionis/luminate/contracts/tools/__init__.py +0 -0
- orionis/luminate/contracts/tools/reflection_interface.py +343 -0
- orionis/luminate/contracts/tools/std_interface.py +56 -0
- orionis/luminate/facades/__init__.py +0 -0
- orionis/luminate/facades/environment.py +81 -0
- orionis/luminate/facades/log.py +56 -0
- orionis/luminate/facades/paths.py +268 -0
- orionis/luminate/facades/tests.py +48 -0
- orionis/luminate/files/__init__.py +0 -0
- orionis/luminate/files/paths.py +56 -0
- orionis/luminate/installer/__init__.py +0 -0
- orionis/luminate/installer/icon.ascii +11 -0
- orionis/luminate/installer/info.ascii +13 -0
- orionis/luminate/installer/output.py +188 -0
- orionis/luminate/installer/setup.py +191 -0
- orionis/luminate/installer/upgrade.py +42 -0
- orionis/luminate/log/__init__.py +0 -0
- orionis/luminate/log/logger.py +116 -0
- orionis/luminate/pipelines/__init__.py +0 -0
- orionis/luminate/pipelines/cli_pipeline.py +116 -0
- orionis/luminate/publisher/__init__.py +0 -0
- orionis/luminate/publisher/pypi.py +206 -0
- orionis/luminate/static/logos/flaskavel.png +0 -0
- orionis/luminate/test/__init__.py +0 -0
- orionis/luminate/test/exception.py +48 -0
- orionis/luminate/test/unit_test.py +108 -0
- orionis/luminate/tools/__init__.py +0 -0
- orionis/luminate/tools/reflection.py +390 -0
- orionis/luminate/tools/std.py +53 -0
- orionis-0.1.0.dist-info/LICENCE +21 -0
- orionis-0.1.0.dist-info/METADATA +27 -0
- orionis-0.1.0.dist-info/RECORD +133 -0
- orionis-0.1.0.dist-info/WHEEL +5 -0
- orionis-0.1.0.dist-info/entry_points.txt +2 -0
- orionis-0.1.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/tools/__init__.py +0 -0
- tests/tools/class_example.py +50 -0
- tests/tools/test_reflection.py +128 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
class OrionisTestFailureException(Exception):
|
2
|
+
"""
|
3
|
+
Custom exception raised when test execution results in one or more failures.
|
4
|
+
|
5
|
+
This exception is used to indicate that a test suite run has encountered failures.
|
6
|
+
It stores a response message detailing the number of failed tests or other relevant
|
7
|
+
error information.
|
8
|
+
|
9
|
+
Parameters
|
10
|
+
----------
|
11
|
+
response : str
|
12
|
+
A message describing the reason for the test failure.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
response : str
|
17
|
+
Stores the response message describing the failure.
|
18
|
+
|
19
|
+
Methods
|
20
|
+
-------
|
21
|
+
__str__() -> str
|
22
|
+
Returns a string representation of the exception, including the response message.
|
23
|
+
"""
|
24
|
+
|
25
|
+
def __init__(self, response: str):
|
26
|
+
"""
|
27
|
+
Initializes the exception with a response message.
|
28
|
+
|
29
|
+
Parameters
|
30
|
+
----------
|
31
|
+
response : str
|
32
|
+
The message describing the test failure.
|
33
|
+
"""
|
34
|
+
self.response = response
|
35
|
+
|
36
|
+
# Ensures proper initialization of the Exception class
|
37
|
+
super().__init__(response)
|
38
|
+
|
39
|
+
def __str__(self) -> str:
|
40
|
+
"""
|
41
|
+
Returns a human-readable string representation of the exception.
|
42
|
+
|
43
|
+
Returns
|
44
|
+
-------
|
45
|
+
str
|
46
|
+
A formatted string containing the exception name and response message.
|
47
|
+
"""
|
48
|
+
return f"OrionisTestFailureException: {self.response}"
|
@@ -0,0 +1,108 @@
|
|
1
|
+
import io
|
2
|
+
import re
|
3
|
+
import unittest
|
4
|
+
from contextlib import redirect_stdout
|
5
|
+
from orionis.luminate.console.output.console import Console
|
6
|
+
from orionis.luminate.contracts.test.unit_test_interface import IUnitTest
|
7
|
+
|
8
|
+
class UnitTest(IUnitTest):
|
9
|
+
"""
|
10
|
+
A testing framework for discovering and running unit tests in a structured way.
|
11
|
+
|
12
|
+
Attributes
|
13
|
+
----------
|
14
|
+
loader : unittest.TestLoader
|
15
|
+
A test loader instance used to discover tests.
|
16
|
+
suite : unittest.TestSuite
|
17
|
+
A test suite that holds all discovered tests.
|
18
|
+
|
19
|
+
Methods
|
20
|
+
-------
|
21
|
+
add_folder_tests(folder_path: str, pattern: str = 'test_*.py') -> None
|
22
|
+
Adds test cases from a specified folder to the test suite.
|
23
|
+
run_tests() -> None
|
24
|
+
Executes all tests in the test suite and raises an exception if any fail.
|
25
|
+
"""
|
26
|
+
|
27
|
+
def __init__(self) -> None:
|
28
|
+
"""
|
29
|
+
Initializes the TestOrionisFramework class, setting up the test loader and suite.
|
30
|
+
"""
|
31
|
+
self.loader = unittest.TestLoader()
|
32
|
+
self.suite = unittest.TestSuite()
|
33
|
+
|
34
|
+
def addFolderTests(self, folder_path: str, pattern: str = "test_*.py") -> None:
|
35
|
+
"""
|
36
|
+
Adds all test cases from a specified folder to the test suite.
|
37
|
+
|
38
|
+
Parameters
|
39
|
+
----------
|
40
|
+
folder_path : str
|
41
|
+
The relative path to the folder containing test files.
|
42
|
+
pattern : str, optional
|
43
|
+
A pattern to match test files (default is 'test_*.py').
|
44
|
+
|
45
|
+
Raises
|
46
|
+
------
|
47
|
+
ValueError
|
48
|
+
If the folder path is invalid or no tests are found.
|
49
|
+
"""
|
50
|
+
self.loader.discover(f"tests", pattern=pattern)
|
51
|
+
|
52
|
+
try:
|
53
|
+
tests = self.loader.discover(f"tests/{folder_path}", pattern=pattern)
|
54
|
+
if not list(tests): # Check if tests were found
|
55
|
+
raise ValueError(f"No tests found in 'tests/{folder_path}' with pattern '{pattern}'.")
|
56
|
+
self.suite.addTests(tests)
|
57
|
+
except Exception as e:
|
58
|
+
raise ValueError(f"Error discovering tests in 'tests/{folder_path}': {e}")
|
59
|
+
|
60
|
+
def extract_error_file(self, traceback: str) -> str:
|
61
|
+
"""Extracts the file path from a traceback message."""
|
62
|
+
match = re.search(r'File "([^"]+)"', traceback)
|
63
|
+
return match.group(1) if match else None
|
64
|
+
|
65
|
+
def run(self) -> dict:
|
66
|
+
"""
|
67
|
+
Runs all tests added to the test suite.
|
68
|
+
|
69
|
+
Raises
|
70
|
+
------
|
71
|
+
OrionisTestFailureException
|
72
|
+
If one or more tests fail.
|
73
|
+
"""
|
74
|
+
Console.newLine()
|
75
|
+
Console.info("Running Tests... 🔍")
|
76
|
+
Console.newLine()
|
77
|
+
|
78
|
+
# Capture output safely
|
79
|
+
output_buffer = io.StringIO()
|
80
|
+
with redirect_stdout(output_buffer):
|
81
|
+
runner = unittest.TextTestRunner(stream=output_buffer, verbosity=2)
|
82
|
+
result = runner.run(self.suite)
|
83
|
+
|
84
|
+
# Display summary table
|
85
|
+
summary = {
|
86
|
+
"tests": result.testsRun,
|
87
|
+
"failures": len(result.failures),
|
88
|
+
"errors": len(result.errors)
|
89
|
+
}
|
90
|
+
Console.table(headers=summary.keys(), rows=[summary.values()])
|
91
|
+
Console.newLine()
|
92
|
+
|
93
|
+
# Display failure details
|
94
|
+
if result.failures:
|
95
|
+
for test_case, traceback in result.failures:
|
96
|
+
title = self.extract_error_file(traceback) or "Error in test"
|
97
|
+
Console.fail(title)
|
98
|
+
Console.write(traceback)
|
99
|
+
|
100
|
+
Console.error(f"{summary['Failures']} test(s) failed.")
|
101
|
+
Console.newLine()
|
102
|
+
|
103
|
+
else:
|
104
|
+
Console.success("All tests passed successfully.")
|
105
|
+
Console.newLine()
|
106
|
+
|
107
|
+
# Return summary
|
108
|
+
return summary
|
File without changes
|
@@ -0,0 +1,390 @@
|
|
1
|
+
import os
|
2
|
+
import inspect
|
3
|
+
import importlib
|
4
|
+
from enum import Enum
|
5
|
+
from typing import Any, List, Optional
|
6
|
+
from orionis.luminate.contracts.tools.reflection_interface import IReflection
|
7
|
+
|
8
|
+
class Reflection(IReflection):
|
9
|
+
"""
|
10
|
+
The Reflection class dynamically loads a class from a module and inspects its attributes,
|
11
|
+
methods, properties, and other properties at runtime. It supports checking the existence of
|
12
|
+
classes, methods, properties, constants, and can instantiate classes if they are not abstract.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
classname : str, optional
|
17
|
+
The name of the class to reflect upon. Default is None.
|
18
|
+
module_name : str, optional
|
19
|
+
The name of the module where the class is defined. Default is None.
|
20
|
+
cls : type, optional
|
21
|
+
The class object after it has been imported and assigned. Default is None.
|
22
|
+
"""
|
23
|
+
|
24
|
+
def __init__(self, target: Optional[Any] = None, module: Optional[str] = None):
|
25
|
+
"""
|
26
|
+
Initializes the Reflection instance with an optional class name, module name, or instance.
|
27
|
+
|
28
|
+
Parameters
|
29
|
+
----------
|
30
|
+
target : Any, optional
|
31
|
+
The class name as a string, the class type, or an instance of the class. Default is None.
|
32
|
+
module : str, optional
|
33
|
+
The name of the module where the class is defined. Default is None.
|
34
|
+
"""
|
35
|
+
self.classname = None
|
36
|
+
self.module_name = module
|
37
|
+
self.cls = None
|
38
|
+
|
39
|
+
if isinstance(target, str):
|
40
|
+
self.classname = target
|
41
|
+
elif isinstance(target, type):
|
42
|
+
self.cls = target
|
43
|
+
self.classname = target.__name__
|
44
|
+
elif target is not None:
|
45
|
+
self.cls = target.__class__
|
46
|
+
self.classname = self.cls.__name__
|
47
|
+
|
48
|
+
if self.module_name and not self.cls:
|
49
|
+
self.safeImport()
|
50
|
+
|
51
|
+
def safeImport(self):
|
52
|
+
"""
|
53
|
+
Safely imports the specified module and assigns the class object if a classname is provided.
|
54
|
+
|
55
|
+
This method raises a ValueError if the module cannot be imported or if the class does not exist
|
56
|
+
within the module.
|
57
|
+
|
58
|
+
Raises
|
59
|
+
------
|
60
|
+
ValueError
|
61
|
+
If the module cannot be imported or the class does not exist in the module.
|
62
|
+
"""
|
63
|
+
try:
|
64
|
+
module = importlib.import_module(self.module_name)
|
65
|
+
if self.classname:
|
66
|
+
self.cls = getattr(module, self.classname, None)
|
67
|
+
if self.cls is None:
|
68
|
+
raise ValueError(f"Class '{self.classname}' not found in module '{self.module_name}'.")
|
69
|
+
except ImportError as e:
|
70
|
+
raise ValueError(f"Error importing module '{self.module_name}': {e}")
|
71
|
+
|
72
|
+
def getFile(self) -> str:
|
73
|
+
"""
|
74
|
+
Retrieves the file path where the class is defined.
|
75
|
+
|
76
|
+
Returns
|
77
|
+
-------
|
78
|
+
str
|
79
|
+
The file path if the class is found, otherwise raises an error.
|
80
|
+
|
81
|
+
Raises
|
82
|
+
------
|
83
|
+
ValueError
|
84
|
+
If the class has not been loaded yet.
|
85
|
+
"""
|
86
|
+
if not self.cls:
|
87
|
+
raise ValueError("Class not loaded. Use 'safeImport()' first.")
|
88
|
+
return inspect.getfile(self.cls)
|
89
|
+
|
90
|
+
def hasClass(self) -> bool:
|
91
|
+
"""
|
92
|
+
Checks whether the class object is available.
|
93
|
+
|
94
|
+
Returns
|
95
|
+
-------
|
96
|
+
bool
|
97
|
+
True if the class is loaded, False otherwise.
|
98
|
+
"""
|
99
|
+
return self.cls is not None
|
100
|
+
|
101
|
+
def hasMethod(self, method_name: str) -> bool:
|
102
|
+
"""
|
103
|
+
Checks whether the specified method exists in the class.
|
104
|
+
|
105
|
+
Parameters
|
106
|
+
----------
|
107
|
+
method_name : str
|
108
|
+
The name of the method to check.
|
109
|
+
|
110
|
+
Returns
|
111
|
+
-------
|
112
|
+
bool
|
113
|
+
True if the method exists, False otherwise.
|
114
|
+
"""
|
115
|
+
return hasattr(self.cls, method_name) if self.cls else False
|
116
|
+
|
117
|
+
def hasProperty(self, prop: str) -> bool:
|
118
|
+
"""
|
119
|
+
Checks whether the specified property exists in the class.
|
120
|
+
|
121
|
+
Parameters
|
122
|
+
----------
|
123
|
+
prop : str
|
124
|
+
The name of the property to check.
|
125
|
+
|
126
|
+
Returns
|
127
|
+
-------
|
128
|
+
bool
|
129
|
+
True if the property exists, False otherwise.
|
130
|
+
"""
|
131
|
+
return hasattr(self.cls, prop) if self.cls else False
|
132
|
+
|
133
|
+
def hasConstant(self, constant: str) -> bool:
|
134
|
+
"""
|
135
|
+
Checks whether the specified constant exists in the class.
|
136
|
+
|
137
|
+
Parameters
|
138
|
+
----------
|
139
|
+
constant : str
|
140
|
+
The name of the constant to check.
|
141
|
+
|
142
|
+
Returns
|
143
|
+
-------
|
144
|
+
bool
|
145
|
+
True if the constant exists, False otherwise.
|
146
|
+
"""
|
147
|
+
return hasattr(self.cls, constant) if self.cls else False
|
148
|
+
|
149
|
+
def getAttributes(self) -> List[str]:
|
150
|
+
"""
|
151
|
+
Retrieves a list of all attributes (including methods and properties) of the class.
|
152
|
+
|
153
|
+
Returns
|
154
|
+
-------
|
155
|
+
list
|
156
|
+
A list of attribute names in the class.
|
157
|
+
"""
|
158
|
+
return dir(self.cls) if self.cls else []
|
159
|
+
|
160
|
+
def getConstructor(self):
|
161
|
+
"""
|
162
|
+
Retrieves the constructor (__init__) of the class.
|
163
|
+
|
164
|
+
Returns
|
165
|
+
-------
|
166
|
+
function or None
|
167
|
+
The constructor method if available, otherwise None.
|
168
|
+
"""
|
169
|
+
return self.cls.__init__ if self.cls else None
|
170
|
+
|
171
|
+
def getDocComment(self) -> Optional[str]:
|
172
|
+
"""
|
173
|
+
Retrieves the docstring of the class.
|
174
|
+
|
175
|
+
Returns
|
176
|
+
-------
|
177
|
+
str or None
|
178
|
+
The docstring of the class if available, otherwise None.
|
179
|
+
"""
|
180
|
+
if not self.cls:
|
181
|
+
raise ValueError("Class not loaded. Use 'safeImport()' first.")
|
182
|
+
return self.cls.__doc__
|
183
|
+
|
184
|
+
def getFileName(self, remove_extension: bool = False) -> str:
|
185
|
+
"""
|
186
|
+
Retrieves the file name where the class is defined, the same as `get_file()`.
|
187
|
+
|
188
|
+
Parameters
|
189
|
+
----------
|
190
|
+
remove_extension : bool, optional
|
191
|
+
If True, the file extension will be removed from the filename. Default is False.
|
192
|
+
|
193
|
+
Returns
|
194
|
+
-------
|
195
|
+
str
|
196
|
+
The file name of the class definition.
|
197
|
+
"""
|
198
|
+
file_name = os.path.basename(self.getFile())
|
199
|
+
if remove_extension:
|
200
|
+
file_name = os.path.splitext(file_name)[0]
|
201
|
+
return file_name
|
202
|
+
|
203
|
+
def getMethod(self, method_name: str):
|
204
|
+
"""
|
205
|
+
Retrieves the specified method from the class.
|
206
|
+
|
207
|
+
Parameters
|
208
|
+
----------
|
209
|
+
method_name : str
|
210
|
+
The name of the method to retrieve.
|
211
|
+
|
212
|
+
Returns
|
213
|
+
-------
|
214
|
+
function or None
|
215
|
+
The method if it exists, otherwise None.
|
216
|
+
"""
|
217
|
+
return getattr(self.cls, method_name, None) if self.cls else None
|
218
|
+
|
219
|
+
def getMethods(self) -> List[str]:
|
220
|
+
"""
|
221
|
+
Retrieves a list of all methods in the class.
|
222
|
+
|
223
|
+
Returns
|
224
|
+
-------
|
225
|
+
list
|
226
|
+
A list of method names in the class.
|
227
|
+
"""
|
228
|
+
return [method for method, _ in inspect.getmembers(self.cls, predicate=inspect.isfunction)] if self.cls else []
|
229
|
+
|
230
|
+
def getName(self) -> str:
|
231
|
+
"""
|
232
|
+
Retrieves the name of the class.
|
233
|
+
|
234
|
+
Returns
|
235
|
+
-------
|
236
|
+
str or None
|
237
|
+
The name of the class if available, otherwise None.
|
238
|
+
"""
|
239
|
+
return self.cls.__name__ if self.cls else None
|
240
|
+
|
241
|
+
def getParentClass(self) -> Optional[tuple]:
|
242
|
+
"""
|
243
|
+
Retrieves the parent classes (base classes) of the class.
|
244
|
+
|
245
|
+
Returns
|
246
|
+
-------
|
247
|
+
tuple or None
|
248
|
+
A tuple of base classes if available, otherwise None.
|
249
|
+
"""
|
250
|
+
return self.cls.__bases__ if self.cls else None
|
251
|
+
|
252
|
+
def getProperties(self) -> List[str]:
|
253
|
+
"""
|
254
|
+
Retrieves a list of all properties of the class.
|
255
|
+
|
256
|
+
Returns
|
257
|
+
-------
|
258
|
+
list
|
259
|
+
A list of property names in the class.
|
260
|
+
"""
|
261
|
+
return [name for name, value in inspect.getmembers(self.cls, lambda x: isinstance(x, property))] if self.cls else []
|
262
|
+
|
263
|
+
def getProperty(self, prop: str):
|
264
|
+
"""
|
265
|
+
Retrieves the specified property from the class.
|
266
|
+
|
267
|
+
Parameters
|
268
|
+
----------
|
269
|
+
prop : str
|
270
|
+
The name of the property to retrieve.
|
271
|
+
|
272
|
+
Returns
|
273
|
+
-------
|
274
|
+
property or None
|
275
|
+
The property if it exists, otherwise None.
|
276
|
+
"""
|
277
|
+
return getattr(self.cls, prop, None) if self.cls else None
|
278
|
+
|
279
|
+
def isAbstract(self) -> bool:
|
280
|
+
"""
|
281
|
+
Checks whether the class is abstract.
|
282
|
+
|
283
|
+
Returns
|
284
|
+
-------
|
285
|
+
bool
|
286
|
+
True if the class is abstract, False otherwise.
|
287
|
+
"""
|
288
|
+
return hasattr(self.cls, '__abstractmethods__') and bool(self.cls.__abstractmethods__) if self.cls else False
|
289
|
+
|
290
|
+
def isEnum(self) -> bool:
|
291
|
+
"""
|
292
|
+
Checks whether the class is an enumeration.
|
293
|
+
|
294
|
+
Returns
|
295
|
+
-------
|
296
|
+
bool
|
297
|
+
True if the class is a subclass of Enum, False otherwise.
|
298
|
+
"""
|
299
|
+
return self.cls is not None and isinstance(self.cls, type) and issubclass(self.cls, Enum)
|
300
|
+
|
301
|
+
def isSubclassOf(self, parent: type) -> bool:
|
302
|
+
"""
|
303
|
+
Checks whether the class is a subclass of the specified parent class.
|
304
|
+
|
305
|
+
Parameters
|
306
|
+
----------
|
307
|
+
parent : type
|
308
|
+
The parent class to check against.
|
309
|
+
|
310
|
+
Returns
|
311
|
+
-------
|
312
|
+
bool
|
313
|
+
True if the class is a subclass of the parent, False otherwise.
|
314
|
+
"""
|
315
|
+
return self.cls is not None and issubclass(self.cls, parent)
|
316
|
+
|
317
|
+
def isInstanceOf(self, instance: Any) -> bool:
|
318
|
+
"""
|
319
|
+
Checks whether the class is an instance of the specified class.
|
320
|
+
|
321
|
+
Parameters
|
322
|
+
----------
|
323
|
+
parent : type
|
324
|
+
The class to check against.
|
325
|
+
|
326
|
+
Returns
|
327
|
+
-------
|
328
|
+
bool
|
329
|
+
True if the class is a subclass of the parent, False otherwise.
|
330
|
+
"""
|
331
|
+
return self.cls is not None and isinstance(instance, self.cls)
|
332
|
+
|
333
|
+
def isIterable(self) -> bool:
|
334
|
+
"""
|
335
|
+
Checks whether the class is iterable.
|
336
|
+
|
337
|
+
Returns
|
338
|
+
-------
|
339
|
+
bool
|
340
|
+
True if the class is iterable, False otherwise.
|
341
|
+
"""
|
342
|
+
return hasattr(self.cls, '__iter__') if self.cls else False
|
343
|
+
|
344
|
+
def isInstantiable(self) -> bool:
|
345
|
+
"""
|
346
|
+
Checks whether the class can be instantiated.
|
347
|
+
|
348
|
+
Returns
|
349
|
+
-------
|
350
|
+
bool
|
351
|
+
True if the class is callable and not abstract, False otherwise.
|
352
|
+
"""
|
353
|
+
return self.cls is not None and callable(self.cls) and not self.isAbstract()
|
354
|
+
|
355
|
+
def newInstance(self, *args, **kwargs):
|
356
|
+
"""
|
357
|
+
Creates a new instance of the class if it is instantiable.
|
358
|
+
|
359
|
+
Parameters
|
360
|
+
----------
|
361
|
+
args : tuple
|
362
|
+
Arguments to pass to the class constructor.
|
363
|
+
kwargs : dict
|
364
|
+
Keyword arguments to pass to the class constructor.
|
365
|
+
|
366
|
+
Returns
|
367
|
+
-------
|
368
|
+
object
|
369
|
+
A new instance of the class.
|
370
|
+
|
371
|
+
Raises
|
372
|
+
------
|
373
|
+
TypeError
|
374
|
+
If the class is not instantiable.
|
375
|
+
"""
|
376
|
+
if self.isInstantiable():
|
377
|
+
return self.cls(*args, **kwargs)
|
378
|
+
raise TypeError(f"Cannot instantiate class '{self.classname}'. It may be abstract or not callable.")
|
379
|
+
|
380
|
+
def __str__(self) -> str:
|
381
|
+
"""
|
382
|
+
Returns a string representation of the Reflection instance.
|
383
|
+
|
384
|
+
Returns
|
385
|
+
-------
|
386
|
+
str
|
387
|
+
A string describing the class and module.
|
388
|
+
"""
|
389
|
+
status = "loaded" if self.cls else "not loaded"
|
390
|
+
return f"<Orionis Reflection class '{self.classname}' in module '{self.module_name}' ({status})>"
|
@@ -0,0 +1,53 @@
|
|
1
|
+
from orionis.luminate.contracts.tools.std_interface import IStdClass
|
2
|
+
|
3
|
+
class StdClass(IStdClass):
|
4
|
+
"""
|
5
|
+
A dynamic class that allows setting arbitrary attributes,
|
6
|
+
similar to PHP's stdClass.
|
7
|
+
"""
|
8
|
+
|
9
|
+
def __init__(self, **kwargs):
|
10
|
+
"""
|
11
|
+
Initializes the StdClass with optional keyword arguments.
|
12
|
+
|
13
|
+
Parameters
|
14
|
+
----------
|
15
|
+
kwargs : dict
|
16
|
+
Key-value pairs to set as attributes.
|
17
|
+
"""
|
18
|
+
for key, value in kwargs.items():
|
19
|
+
setattr(self, key, value)
|
20
|
+
|
21
|
+
def __repr__(self):
|
22
|
+
"""
|
23
|
+
Returns a string representation of the object.
|
24
|
+
|
25
|
+
Returns
|
26
|
+
-------
|
27
|
+
str
|
28
|
+
A formatted string showing the object's attributes.
|
29
|
+
"""
|
30
|
+
return f"{self.__class__.__name__}({self.__dict__})"
|
31
|
+
|
32
|
+
def toDict(self):
|
33
|
+
"""
|
34
|
+
Converts the object's attributes to a dictionary.
|
35
|
+
|
36
|
+
Returns
|
37
|
+
-------
|
38
|
+
dict
|
39
|
+
A dictionary representation of the object's attributes.
|
40
|
+
"""
|
41
|
+
return self.__dict__
|
42
|
+
|
43
|
+
def update(self, **kwargs):
|
44
|
+
"""
|
45
|
+
Updates the object's attributes dynamically.
|
46
|
+
|
47
|
+
Parameters
|
48
|
+
----------
|
49
|
+
kwargs : dict
|
50
|
+
Key-value pairs to update attributes.
|
51
|
+
"""
|
52
|
+
for key, value in kwargs.items():
|
53
|
+
setattr(self, key, value)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 - 2025 RAÚL MAURICIO UÑATE CASTRO
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: orionis
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Orionis Framework – Elegant, Fast, and Powerful.
|
5
|
+
Home-page: https://github.com/orionis-framework/framework
|
6
|
+
Author: Raul Mauricio Uñate Castro
|
7
|
+
Author-email: raulmauriciounate@gmail.com
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.12
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENCE
|
14
|
+
Requires-Dist: apscheduler>=3.11.0
|
15
|
+
Requires-Dist: python-dotenv>=1.0.1
|
16
|
+
Dynamic: author
|
17
|
+
Dynamic: author-email
|
18
|
+
Dynamic: classifier
|
19
|
+
Dynamic: description
|
20
|
+
Dynamic: description-content-type
|
21
|
+
Dynamic: home-page
|
22
|
+
Dynamic: requires-dist
|
23
|
+
Dynamic: requires-python
|
24
|
+
Dynamic: summary
|
25
|
+
|
26
|
+
# **Orionis Framework – An Opinionated Python Framework**
|
27
|
+
**⚡ Orionis Framework – Elegant, Fast, and Powerful 🚀**
|