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,268 @@
|
|
1
|
+
import os
|
2
|
+
from orionis.luminate.files.paths import SkeletonPath
|
3
|
+
from orionis.luminate.contracts.facades.paths_interface import IPath
|
4
|
+
|
5
|
+
class Path(IPath):
|
6
|
+
|
7
|
+
@staticmethod
|
8
|
+
def _resolve_directory(directory: str, file: str = None):
|
9
|
+
"""
|
10
|
+
Internal helper function to resolve an absolute path for a given directory.
|
11
|
+
|
12
|
+
Parameters
|
13
|
+
----------
|
14
|
+
directory : str
|
15
|
+
The base directory to resolve the path from.
|
16
|
+
file : str, optional
|
17
|
+
The relative file path inside the directory (default is an empty string).
|
18
|
+
|
19
|
+
Returns
|
20
|
+
-------
|
21
|
+
SkeletonPath
|
22
|
+
The resolved absolute path wrapped in a SkeletonPath object.
|
23
|
+
"""
|
24
|
+
# Default to an empty string if None
|
25
|
+
file = file or ""
|
26
|
+
|
27
|
+
# Construct path safely
|
28
|
+
route = os.path.join(directory, file)
|
29
|
+
|
30
|
+
# Normalize path (removes redundant slashes)
|
31
|
+
route = os.path.normpath(route)
|
32
|
+
|
33
|
+
return SkeletonPath(route).resolve()
|
34
|
+
|
35
|
+
@staticmethod
|
36
|
+
def app(file: str = None):
|
37
|
+
"""
|
38
|
+
Returns the absolute path for a file inside the 'app' directory.
|
39
|
+
|
40
|
+
Parameters
|
41
|
+
----------
|
42
|
+
file : str, optional
|
43
|
+
The relative file path inside the 'app' directory.
|
44
|
+
|
45
|
+
Returns
|
46
|
+
-------
|
47
|
+
SkeletonPath
|
48
|
+
The resolved path wrapped in a SkeletonPath object.
|
49
|
+
"""
|
50
|
+
return Path._resolve_directory("app", file)
|
51
|
+
|
52
|
+
@staticmethod
|
53
|
+
def config(file: str = None):
|
54
|
+
"""
|
55
|
+
Returns the absolute path for a file inside the 'config' directory.
|
56
|
+
|
57
|
+
Parameters
|
58
|
+
----------
|
59
|
+
file : str, optional
|
60
|
+
The relative file path inside the 'config' directory.
|
61
|
+
|
62
|
+
Returns
|
63
|
+
-------
|
64
|
+
SkeletonPath
|
65
|
+
The resolved path wrapped in a SkeletonPath object.
|
66
|
+
"""
|
67
|
+
return Path._resolve_directory("config", file)
|
68
|
+
|
69
|
+
@staticmethod
|
70
|
+
def database(file: str = None):
|
71
|
+
"""
|
72
|
+
Returns the absolute path for a file inside the 'database' directory.
|
73
|
+
|
74
|
+
Parameters
|
75
|
+
----------
|
76
|
+
file : str, optional
|
77
|
+
The relative file path inside the 'database' directory.
|
78
|
+
|
79
|
+
Returns
|
80
|
+
-------
|
81
|
+
SkeletonPath
|
82
|
+
The resolved path wrapped in a SkeletonPath object.
|
83
|
+
"""
|
84
|
+
return Path._resolve_directory("database", file)
|
85
|
+
|
86
|
+
@staticmethod
|
87
|
+
def resource(file: str = None):
|
88
|
+
"""
|
89
|
+
Returns the absolute path for a file inside the 'resource' directory.
|
90
|
+
|
91
|
+
Parameters
|
92
|
+
----------
|
93
|
+
file : str, optional
|
94
|
+
The relative file path inside the 'resource' directory.
|
95
|
+
|
96
|
+
Returns
|
97
|
+
-------
|
98
|
+
SkeletonPath
|
99
|
+
The resolved path wrapped in a SkeletonPath object.
|
100
|
+
"""
|
101
|
+
return Path._resolve_directory("resource", file)
|
102
|
+
|
103
|
+
@staticmethod
|
104
|
+
def routes(file: str = None):
|
105
|
+
"""
|
106
|
+
Returns the absolute path for a file inside the 'routes' directory.
|
107
|
+
|
108
|
+
Parameters
|
109
|
+
----------
|
110
|
+
file : str, optional
|
111
|
+
The relative file path inside the 'routes' directory.
|
112
|
+
|
113
|
+
Returns
|
114
|
+
-------
|
115
|
+
SkeletonPath
|
116
|
+
The resolved path wrapped in a SkeletonPath object.
|
117
|
+
"""
|
118
|
+
return Path._resolve_directory("routes", file)
|
119
|
+
|
120
|
+
@staticmethod
|
121
|
+
def storage(file: str = None):
|
122
|
+
"""
|
123
|
+
Returns the absolute path for a file inside the 'storage' directory.
|
124
|
+
|
125
|
+
Parameters
|
126
|
+
----------
|
127
|
+
file : str, optional
|
128
|
+
The relative file path inside the 'storage' directory.
|
129
|
+
|
130
|
+
Returns
|
131
|
+
-------
|
132
|
+
SkeletonPath
|
133
|
+
The resolved path wrapped in a SkeletonPath object.
|
134
|
+
"""
|
135
|
+
return Path._resolve_directory("storage", file)
|
136
|
+
|
137
|
+
@staticmethod
|
138
|
+
def tests(file: str = None):
|
139
|
+
"""
|
140
|
+
Returns the absolute path for a file inside the 'tests' directory.
|
141
|
+
|
142
|
+
Parameters
|
143
|
+
----------
|
144
|
+
file : str, optional
|
145
|
+
The relative file path inside the 'tests' directory.
|
146
|
+
|
147
|
+
Returns
|
148
|
+
-------
|
149
|
+
SkeletonPath
|
150
|
+
The resolved path wrapped in a SkeletonPath object.
|
151
|
+
"""
|
152
|
+
return Path._resolve_directory("tests", file)
|
153
|
+
|
154
|
+
|
155
|
+
# -------------- Functions --------------
|
156
|
+
|
157
|
+
|
158
|
+
def app_path(file: str = None):
|
159
|
+
"""
|
160
|
+
Returns the absolute path for a file inside the 'app' directory.
|
161
|
+
|
162
|
+
Parameters
|
163
|
+
----------
|
164
|
+
file : str, optional
|
165
|
+
The relative file path inside the 'app' directory.
|
166
|
+
|
167
|
+
Returns
|
168
|
+
-------
|
169
|
+
SkeletonPath
|
170
|
+
The resolved path wrapped in a SkeletonPath object.
|
171
|
+
"""
|
172
|
+
return Path._resolve_directory("app", file)
|
173
|
+
|
174
|
+
def config_path(file: str = None):
|
175
|
+
"""
|
176
|
+
Returns the absolute path for a file inside the 'config' directory.
|
177
|
+
|
178
|
+
Parameters
|
179
|
+
----------
|
180
|
+
file : str, optional
|
181
|
+
The relative file path inside the 'config' directory.
|
182
|
+
|
183
|
+
Returns
|
184
|
+
-------
|
185
|
+
SkeletonPath
|
186
|
+
The resolved path wrapped in a SkeletonPath object.
|
187
|
+
"""
|
188
|
+
return Path._resolve_directory("config", file)
|
189
|
+
|
190
|
+
def database_path(file: str = None):
|
191
|
+
"""
|
192
|
+
Returns the absolute path for a file inside the 'database' directory.
|
193
|
+
|
194
|
+
Parameters
|
195
|
+
----------
|
196
|
+
file : str, optional
|
197
|
+
The relative file path inside the 'database' directory.
|
198
|
+
|
199
|
+
Returns
|
200
|
+
-------
|
201
|
+
SkeletonPath
|
202
|
+
The resolved path wrapped in a SkeletonPath object.
|
203
|
+
"""
|
204
|
+
return Path._resolve_directory("database", file)
|
205
|
+
|
206
|
+
def resource_path(file: str = None):
|
207
|
+
"""
|
208
|
+
Returns the absolute path for a file inside the 'resource' directory.
|
209
|
+
|
210
|
+
Parameters
|
211
|
+
----------
|
212
|
+
file : str, optional
|
213
|
+
The relative file path inside the 'resource' directory.
|
214
|
+
|
215
|
+
Returns
|
216
|
+
-------
|
217
|
+
SkeletonPath
|
218
|
+
The resolved path wrapped in a SkeletonPath object.
|
219
|
+
"""
|
220
|
+
return Path._resolve_directory("resource", file)
|
221
|
+
|
222
|
+
def routes_path(file: str = None):
|
223
|
+
"""
|
224
|
+
Returns the absolute path for a file inside the 'routes' directory.
|
225
|
+
|
226
|
+
Parameters
|
227
|
+
----------
|
228
|
+
file : str, optional
|
229
|
+
The relative file path inside the 'routes' directory.
|
230
|
+
|
231
|
+
Returns
|
232
|
+
-------
|
233
|
+
SkeletonPath
|
234
|
+
The resolved path wrapped in a SkeletonPath object.
|
235
|
+
"""
|
236
|
+
return Path._resolve_directory("routes", file)
|
237
|
+
|
238
|
+
def storage_path(file: str = None):
|
239
|
+
"""
|
240
|
+
Returns the absolute path for a file inside the 'storage' directory.
|
241
|
+
|
242
|
+
Parameters
|
243
|
+
----------
|
244
|
+
file : str, optional
|
245
|
+
The relative file path inside the 'storage' directory.
|
246
|
+
|
247
|
+
Returns
|
248
|
+
-------
|
249
|
+
SkeletonPath
|
250
|
+
The resolved path wrapped in a SkeletonPath object.
|
251
|
+
"""
|
252
|
+
return Path._resolve_directory("storage", file)
|
253
|
+
|
254
|
+
def tests_path(file: str = None):
|
255
|
+
"""
|
256
|
+
Returns the absolute path for a file inside the 'tests' directory.
|
257
|
+
|
258
|
+
Parameters
|
259
|
+
----------
|
260
|
+
file : str, optional
|
261
|
+
The relative file path inside the 'tests' directory.
|
262
|
+
|
263
|
+
Returns
|
264
|
+
-------
|
265
|
+
SkeletonPath
|
266
|
+
The resolved path wrapped in a SkeletonPath object.
|
267
|
+
"""
|
268
|
+
return Path._resolve_directory("tests", file)
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import os
|
2
|
+
from orionis.luminate.test.unit_test import UnitTest
|
3
|
+
from orionis.luminate.contracts.facades.tests_interface import IUnitTests
|
4
|
+
|
5
|
+
class UnitTests(IUnitTests):
|
6
|
+
"""
|
7
|
+
Concrete implementation of the IUnitTests interface.
|
8
|
+
|
9
|
+
This class provides the functionality to execute unit tests using a specified pattern
|
10
|
+
to filter test files within the 'tests' directory and its subdirectories.
|
11
|
+
|
12
|
+
Methods
|
13
|
+
-------
|
14
|
+
execute(pattern: str) -> dict
|
15
|
+
Executes unit tests by iterating over the 'tests' directory and its subdirectories,
|
16
|
+
matching test files based on the provided pattern.
|
17
|
+
"""
|
18
|
+
|
19
|
+
@staticmethod
|
20
|
+
def execute(pattern='test_*.py') -> dict:
|
21
|
+
"""
|
22
|
+
Executes the unit tests in the 'tests' directory and its subdirectories
|
23
|
+
by filtering test files based on a specified pattern.
|
24
|
+
|
25
|
+
Parameters
|
26
|
+
----------
|
27
|
+
pattern : str, optional
|
28
|
+
The pattern to filter test files (default is 'test_*.py').
|
29
|
+
|
30
|
+
Returns
|
31
|
+
-------
|
32
|
+
dict
|
33
|
+
A dictionary containing the results of the executed tests.
|
34
|
+
"""
|
35
|
+
|
36
|
+
# Initialize the test suite using the UnitTest framework
|
37
|
+
test_suite = UnitTest()
|
38
|
+
|
39
|
+
# Define the base directory for test files
|
40
|
+
tests_path = os.path.join(os.getcwd(), 'tests')
|
41
|
+
|
42
|
+
# Recursively walk through the 'tests' directory
|
43
|
+
for root, dirs, files in os.walk(tests_path):
|
44
|
+
for dir in dirs:
|
45
|
+
test_suite.addFolderTests(folder_path=dir, pattern=pattern)
|
46
|
+
|
47
|
+
# Execute the tests and return the results
|
48
|
+
return test_suite.run()
|
File without changes
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import os
|
2
|
+
from pathlib import Path as SysPath
|
3
|
+
from orionis.luminate.contracts.files.paths_interface import ISkeletonPath
|
4
|
+
|
5
|
+
class SkeletonPath(ISkeletonPath):
|
6
|
+
"""
|
7
|
+
Resolves the absolute path for a given relative directory based on the script's execution directory.
|
8
|
+
Ensures that the requested path is a valid directory.
|
9
|
+
|
10
|
+
Attributes
|
11
|
+
----------
|
12
|
+
route : str
|
13
|
+
The resolved absolute path to the directory.
|
14
|
+
|
15
|
+
Methods
|
16
|
+
-------
|
17
|
+
__str__():
|
18
|
+
Returns the absolute path as a string.
|
19
|
+
"""
|
20
|
+
|
21
|
+
def __init__(self, route: str):
|
22
|
+
"""
|
23
|
+
Initializes the Path class, resolving the absolute path for a given relative directory.
|
24
|
+
|
25
|
+
The path is resolved relative to the script's execution directory.
|
26
|
+
|
27
|
+
Parameters
|
28
|
+
----------
|
29
|
+
route : str
|
30
|
+
The relative directory path to be resolved.
|
31
|
+
|
32
|
+
Raises
|
33
|
+
------
|
34
|
+
ValueError
|
35
|
+
If the path does not exist or is not a directory.
|
36
|
+
"""
|
37
|
+
# Get the absolute path based on the script's execution directory
|
38
|
+
base_path = SysPath(os.getcwd()) # Get the directory where the script is executed
|
39
|
+
real_path = (base_path / route).resolve() # Combine base path with the relative route
|
40
|
+
|
41
|
+
# Validate that the path exists and is a directory
|
42
|
+
if not real_path.is_dir():
|
43
|
+
raise ValueError(f"The requested directory does not exist or is not a directory: {real_path}")
|
44
|
+
|
45
|
+
self.route = str(real_path)
|
46
|
+
|
47
|
+
def resolve(self) -> str:
|
48
|
+
"""
|
49
|
+
Returns the absolute path as a string.
|
50
|
+
|
51
|
+
Returns
|
52
|
+
-------
|
53
|
+
str
|
54
|
+
The absolute directory path.
|
55
|
+
"""
|
56
|
+
return self.route
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
-------------------------------------------
|
2
|
+
██████ ██████ ██ ██████ ███ ██ ██ ███████
|
3
|
+
██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██
|
4
|
+
██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ███████
|
5
|
+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
6
|
+
██████ ██ ██ ██ ██████ ██ ████ ██ ███████
|
7
|
+
{{message}}
|
8
|
+
-------------------------------------------
|
9
|
+
Orionis Team © 2023 - {{year}}
|
10
|
+
Version: {{version}}
|
11
|
+
Docs: {{docs}}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
-------------------------------------------
|
2
|
+
██████ ██████ ██ ██████ ███ ██ ██ ███████
|
3
|
+
██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██
|
4
|
+
██ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ███████
|
5
|
+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
6
|
+
██████ ██ ██ ██ ██████ ██ ████ ██ ███████
|
7
|
+
{{message}}
|
8
|
+
-------------------------------------------
|
9
|
+
{{commands}}
|
10
|
+
-------------------------------------------
|
11
|
+
Orionis Team © 2023 - {{year}}
|
12
|
+
Version: {{version}}
|
13
|
+
Docs: {{docs}}
|
@@ -0,0 +1,188 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
import datetime
|
4
|
+
from orionis.framework import NAME, VERSION, DOCS
|
5
|
+
from orionis.luminate.contracts.installer.output_interface import IOutput
|
6
|
+
|
7
|
+
class Output(IOutput):
|
8
|
+
"""
|
9
|
+
Class for displaying various types of messages to the console, including:
|
10
|
+
- Welcome messages
|
11
|
+
- Informational messages
|
12
|
+
- Failure messages
|
13
|
+
- Error messages
|
14
|
+
|
15
|
+
Methods
|
16
|
+
-------
|
17
|
+
welcome() -> None
|
18
|
+
Displays a welcome message to the framework.
|
19
|
+
finished() -> None
|
20
|
+
Displays a success message after initialization.
|
21
|
+
info(message: str) -> None
|
22
|
+
Displays an informational message to the console.
|
23
|
+
fail(message: str) -> None
|
24
|
+
Displays a failure message to the console.
|
25
|
+
error(message: str) -> None
|
26
|
+
Displays an error message to the console and terminates the program.
|
27
|
+
"""
|
28
|
+
|
29
|
+
@staticmethod
|
30
|
+
def _print(label: str, message: str, color_code: str):
|
31
|
+
"""
|
32
|
+
Prints messages to the console with specific formatting and colors.
|
33
|
+
|
34
|
+
Parameters
|
35
|
+
----------
|
36
|
+
label : str
|
37
|
+
The label for the message (e.g., INFO, FAIL, ERROR).
|
38
|
+
message : str
|
39
|
+
The message to display.
|
40
|
+
color_code : str
|
41
|
+
ANSI color code for the background of the message.
|
42
|
+
"""
|
43
|
+
# Get the current timestamp to display with the message
|
44
|
+
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
45
|
+
|
46
|
+
# Print the formatted message with the specified color and label
|
47
|
+
print(f'\u001b[{color_code}m\u001b[97m {label} \u001b[0m {timestamp} [Orionis Framework] - {message}\u001b[0m')
|
48
|
+
|
49
|
+
@staticmethod
|
50
|
+
def asciiIco():
|
51
|
+
"""
|
52
|
+
Displays a welcome message to the framework, including ASCII art.
|
53
|
+
|
54
|
+
Attempts to load an ASCII art file (art.ascii). If not found, defaults to displaying basic information.
|
55
|
+
|
56
|
+
If the ASCII art file is found, placeholders are replaced with dynamic content such as version, docs, and year.
|
57
|
+
"""
|
58
|
+
print("\n")
|
59
|
+
|
60
|
+
try:
|
61
|
+
# Try loading and printing ASCII art from the file
|
62
|
+
dir_path = os.path.dirname(__file__)
|
63
|
+
path = os.path.join(dir_path, 'icon.ascii')
|
64
|
+
with open(path, 'r', encoding='utf-8') as file:
|
65
|
+
content = file.read()
|
66
|
+
|
67
|
+
# Replace placeholders with dynamic content
|
68
|
+
year = datetime.datetime.now().year
|
69
|
+
message = "\u001b[32m{} \u001b[0m".format("Python isn't just powerful; it’s thrilling.")
|
70
|
+
output = content.replace('{{version}}', VERSION) \
|
71
|
+
.replace('{{docs}}', DOCS) \
|
72
|
+
.replace('{{year}}', str(year)) \
|
73
|
+
.replace('{{message}}', message)
|
74
|
+
print(output)
|
75
|
+
|
76
|
+
except FileNotFoundError:
|
77
|
+
# Fallback if ASCII art file is not found
|
78
|
+
print(str(NAME).upper())
|
79
|
+
print(f"Version: {VERSION}")
|
80
|
+
print(f"Docs: {DOCS}")
|
81
|
+
|
82
|
+
print("\n")
|
83
|
+
|
84
|
+
@staticmethod
|
85
|
+
def asciiInfo():
|
86
|
+
"""
|
87
|
+
Displays another type of welcome message to the framework, including different ASCII art.
|
88
|
+
|
89
|
+
Attempts to load an ASCII art file (info.ascii). If not found, defaults to displaying basic information.
|
90
|
+
|
91
|
+
Similar to `asciiIco()`, but with different ASCII art.
|
92
|
+
"""
|
93
|
+
print("\n")
|
94
|
+
|
95
|
+
try:
|
96
|
+
# Try loading and printing ASCII art from the file
|
97
|
+
dir_path = os.path.dirname(__file__)
|
98
|
+
path = os.path.join(dir_path, 'info.ascii')
|
99
|
+
with open(path, 'r', encoding='utf-8') as file:
|
100
|
+
content = file.read()
|
101
|
+
|
102
|
+
# Replace placeholders with dynamic content
|
103
|
+
year = datetime.datetime.now().year
|
104
|
+
message = "\033[92m{} \033[0m".format("The list of commands accepted by the Orionis interpreter are:")
|
105
|
+
commands = [
|
106
|
+
{'name':'orionis new <app_name>', 'description': 'Creates a new Orionis app with the specified name.'},
|
107
|
+
{'name':'orionis --version', 'description': 'Displays the current version of Orionis.'},
|
108
|
+
{'name':'orionis --upgrade', 'description': 'Upgrades Orionis to the latest version.'}
|
109
|
+
]
|
110
|
+
commands_array = []
|
111
|
+
for command in commands:
|
112
|
+
commands_array.append("\033[1m\033[93m- {} :\033[0m {}".format(command['name'],command['description']))
|
113
|
+
|
114
|
+
output = content.replace('{{version}}', VERSION) \
|
115
|
+
.replace('{{docs}}', DOCS) \
|
116
|
+
.replace('{{year}}', str(year))\
|
117
|
+
.replace('{{message}}', message)\
|
118
|
+
.replace('{{commands}}', str("\n").join(commands_array))
|
119
|
+
print(output)
|
120
|
+
|
121
|
+
except FileNotFoundError:
|
122
|
+
# Fallback if ASCII art file is not found
|
123
|
+
print(str(NAME).upper())
|
124
|
+
print(f"Version: {VERSION}")
|
125
|
+
print(f"Docs: {DOCS}")
|
126
|
+
|
127
|
+
print("\n")
|
128
|
+
|
129
|
+
@staticmethod
|
130
|
+
def startInstallation():
|
131
|
+
"""
|
132
|
+
Displays the starting message when the installation begins.
|
133
|
+
This includes a welcoming message and the ASCII art.
|
134
|
+
"""
|
135
|
+
Output.asciiIco()
|
136
|
+
print(f'\u001b[32m{NAME}\u001b[0m: Thank you for using the framework!')
|
137
|
+
|
138
|
+
@staticmethod
|
139
|
+
def endInstallation():
|
140
|
+
"""
|
141
|
+
Displays the ending message after the installation is complete.
|
142
|
+
Provides a message of encouragement to start using the framework.
|
143
|
+
"""
|
144
|
+
print(f'\u001b[32m{NAME}\u001b[0m: Welcome aboard, the journey starts now. Let your imagination soar!')
|
145
|
+
print("\n")
|
146
|
+
|
147
|
+
@staticmethod
|
148
|
+
def info(message: str = ''):
|
149
|
+
"""
|
150
|
+
Displays an informational message to the console.
|
151
|
+
|
152
|
+
Parameters
|
153
|
+
----------
|
154
|
+
message : str, optional
|
155
|
+
The message to display. Defaults to an empty string.
|
156
|
+
"""
|
157
|
+
Output._print("INFO", message, "44")
|
158
|
+
|
159
|
+
@staticmethod
|
160
|
+
def fail(message: str = ''):
|
161
|
+
"""
|
162
|
+
Displays a failure message to the console.
|
163
|
+
|
164
|
+
Parameters
|
165
|
+
----------
|
166
|
+
message : str, optional
|
167
|
+
The message to display. Defaults to an empty string.
|
168
|
+
"""
|
169
|
+
Output._print("FAIL", message, "43")
|
170
|
+
|
171
|
+
@staticmethod
|
172
|
+
def error(message: str = ''):
|
173
|
+
"""
|
174
|
+
Displays an error message to the console and terminates the program.
|
175
|
+
|
176
|
+
Parameters
|
177
|
+
----------
|
178
|
+
message : str, optional
|
179
|
+
The message to display. Defaults to an empty string.
|
180
|
+
|
181
|
+
Raises
|
182
|
+
------
|
183
|
+
SystemExit
|
184
|
+
Terminates the program with a non-zero exit code, indicating an error occurred.
|
185
|
+
"""
|
186
|
+
Output._print("ERROR", message, "41")
|
187
|
+
print("\n")
|
188
|
+
sys.exit(1)
|