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
orionis/__init__.py
ADDED
File without changes
|
orionis/cli_manager.py
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
import argparse
|
2
|
+
from orionis.luminate.console.scripts.management import Management
|
3
|
+
|
4
|
+
def main():
|
5
|
+
"""
|
6
|
+
Main entry point for the Orionis CLI tool.
|
7
|
+
"""
|
8
|
+
|
9
|
+
# Create the argument parser for CLI commands
|
10
|
+
parser = argparse.ArgumentParser(description="Orionis Command Line Tool")
|
11
|
+
|
12
|
+
# Optional argument for displaying the current Orionis version
|
13
|
+
parser.add_argument('--version', action='store_true', help="Show Orionis version.")
|
14
|
+
|
15
|
+
# Optional argument for upgrading Orionis to the latest version
|
16
|
+
parser.add_argument('--upgrade', action='store_true', help="Upgrade Orionis to the latest version.")
|
17
|
+
|
18
|
+
# Command to create a new Orionis app (requires an app name)
|
19
|
+
parser.add_argument('command', nargs='?', choices=['new'], help="Available command: 'new'.")
|
20
|
+
|
21
|
+
# Name of the application to be created (defaults to 'example-app')
|
22
|
+
parser.add_argument('name', nargs='?', help="The name of the Orionis application to create.", default="example-app")
|
23
|
+
|
24
|
+
# Parse the provided arguments
|
25
|
+
args = parser.parse_args()
|
26
|
+
|
27
|
+
# Initialize the Orionis tools for handling operations
|
28
|
+
cli_manager = Management()
|
29
|
+
|
30
|
+
# Handle the version command
|
31
|
+
if args.version:
|
32
|
+
cli_manager.displayVersion()
|
33
|
+
|
34
|
+
# Handle the upgrade command
|
35
|
+
elif args.upgrade:
|
36
|
+
cli_manager.executeUpgrade()
|
37
|
+
|
38
|
+
# Handle the 'new' command to create a new app
|
39
|
+
elif args.command == 'new':
|
40
|
+
cli_manager.createNewApp(args.name or 'example-app')
|
41
|
+
|
42
|
+
# If no valid command is provided, show the help message
|
43
|
+
else:
|
44
|
+
cli_manager.displayInfo()
|
45
|
+
|
46
|
+
# Execute the main function if the script is run directly
|
47
|
+
if __name__ == "__main__":
|
48
|
+
main()
|
orionis/framework.py
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#--------------------------------------------------------------------------
|
2
|
+
# Name of the project or framework
|
3
|
+
#--------------------------------------------------------------------------
|
4
|
+
NAME = "orionis"
|
5
|
+
|
6
|
+
#--------------------------------------------------------------------------
|
7
|
+
# Current version of the project or framework
|
8
|
+
#--------------------------------------------------------------------------
|
9
|
+
VERSION = "0.1.0"
|
10
|
+
|
11
|
+
#--------------------------------------------------------------------------
|
12
|
+
# Full name of the author or maintainer of the project
|
13
|
+
#--------------------------------------------------------------------------
|
14
|
+
AUTHOR = "Raul Mauricio Uñate Castro"
|
15
|
+
|
16
|
+
#--------------------------------------------------------------------------
|
17
|
+
# Email address of the author or maintainer for contact purposes
|
18
|
+
#--------------------------------------------------------------------------
|
19
|
+
AUTHOR_EMAIL = "raulmauriciounate@gmail.com"
|
20
|
+
|
21
|
+
#--------------------------------------------------------------------------
|
22
|
+
# Short description of the project or framework
|
23
|
+
#--------------------------------------------------------------------------
|
24
|
+
DESCRIPTION = "Orionis Framework – Elegant, Fast, and Powerful."
|
25
|
+
|
26
|
+
#--------------------------------------------------------------------------
|
27
|
+
# URL to the project's skeleton or template repository
|
28
|
+
# This is typically used for initial project setup
|
29
|
+
#--------------------------------------------------------------------------
|
30
|
+
SKELETON = "https://github.com/orionis-framework/skeleton"
|
31
|
+
|
32
|
+
#--------------------------------------------------------------------------
|
33
|
+
# URL to the project's framework repository
|
34
|
+
#--------------------------------------------------------------------------
|
35
|
+
FRAMEWORK = "https://github.com/orionis-framework/framework"
|
36
|
+
|
37
|
+
#--------------------------------------------------------------------------
|
38
|
+
# URL to the project's documentation
|
39
|
+
#--------------------------------------------------------------------------
|
40
|
+
DOCS = "https://github.com/orionis-framework/docs"
|
41
|
+
|
42
|
+
#--------------------------------------------------------------------------
|
43
|
+
# Minimum Python version required to run the project
|
44
|
+
#--------------------------------------------------------------------------
|
45
|
+
PYTHON_REQUIRES = ">=3.12"
|
File without changes
|
orionis/luminate/app.py
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from dataclasses import asdict
|
3
|
+
from orionis.luminate.contracts.bootstrap.parser_interface import IParser
|
4
|
+
|
5
|
+
class Parser(IParser):
|
6
|
+
"""
|
7
|
+
A class responsible for parsing configuration objects into dictionaries.
|
8
|
+
|
9
|
+
This class implements the `IParser` interface and provides a method
|
10
|
+
to convert configuration instances into a dictionary format.
|
11
|
+
|
12
|
+
Methods
|
13
|
+
-------
|
14
|
+
toDict(instance: Any) -> dict
|
15
|
+
Converts the `config` attribute of an instance into a dictionary.
|
16
|
+
"""
|
17
|
+
|
18
|
+
@staticmethod
|
19
|
+
def toDict(instance: Any) -> dict:
|
20
|
+
"""
|
21
|
+
Converts the `config` attribute of a given instance into a dictionary.
|
22
|
+
|
23
|
+
This method uses `asdict()` to transform a dataclass-based configuration
|
24
|
+
into a dictionary, ensuring that all attributes are properly serialized.
|
25
|
+
|
26
|
+
Parameters
|
27
|
+
----------
|
28
|
+
instance : Any
|
29
|
+
The object containing a `config` attribute to be converted.
|
30
|
+
|
31
|
+
Returns
|
32
|
+
-------
|
33
|
+
dict
|
34
|
+
A dictionary representation of the `config` attribute.
|
35
|
+
|
36
|
+
Raises
|
37
|
+
------
|
38
|
+
AttributeError
|
39
|
+
If the provided instance does not have a `config` attribute.
|
40
|
+
TypeError
|
41
|
+
If the `config` attribute cannot be converted to a dictionary.
|
42
|
+
"""
|
43
|
+
try:
|
44
|
+
# Convert dataclass using asdict()
|
45
|
+
return asdict(instance.config)
|
46
|
+
except AttributeError as e:
|
47
|
+
raise AttributeError("The provided instance does not have a 'config' attribute.") from e
|
48
|
+
except TypeError as e:
|
49
|
+
raise TypeError(f"Error: The 'config' attribute could not be converted to a dictionary. {str(e)}")
|
@@ -0,0 +1,95 @@
|
|
1
|
+
from orionis.luminate.bootstrap.parser import Parser
|
2
|
+
from orionis.luminate.config.sections import SECTIONS
|
3
|
+
from orionis.luminate.tools.reflection import Reflection
|
4
|
+
from orionis.luminate.cache.app.config import CacheConfig
|
5
|
+
from orionis.luminate.contracts.config.config_interface import IConfig
|
6
|
+
|
7
|
+
class Register:
|
8
|
+
"""
|
9
|
+
Handles the registration of configuration classes within the application.
|
10
|
+
|
11
|
+
This class ensures that only valid configuration classes are registered
|
12
|
+
while enforcing structure and type safety.
|
13
|
+
|
14
|
+
Attributes
|
15
|
+
----------
|
16
|
+
cache_config : CacheConfig
|
17
|
+
An instance of `CacheConfig` used to store registered configurations.
|
18
|
+
|
19
|
+
Methods
|
20
|
+
-------
|
21
|
+
config(config_class: type) -> type
|
22
|
+
Registers a configuration class and ensures it meets the necessary criteria.
|
23
|
+
"""
|
24
|
+
|
25
|
+
def __init__(self, cache: CacheConfig = None):
|
26
|
+
"""
|
27
|
+
Initializes the Register instance with a cache configuration.
|
28
|
+
|
29
|
+
Parameters
|
30
|
+
----------
|
31
|
+
cache : CacheConfig, optional
|
32
|
+
The cache configuration instance to be used (default is a new instance of `CacheConfig`).
|
33
|
+
"""
|
34
|
+
self.cache_config = cache or CacheConfig()
|
35
|
+
|
36
|
+
def config(self, config_class: type) -> type:
|
37
|
+
"""
|
38
|
+
Registers a configuration class and ensures it meets the required structure.
|
39
|
+
|
40
|
+
This method performs multiple validation steps, including checking if the input
|
41
|
+
is a class, verifying the existence of a `config` attribute, and confirming
|
42
|
+
inheritance from `IConfig`.
|
43
|
+
|
44
|
+
Parameters
|
45
|
+
----------
|
46
|
+
config_class : type
|
47
|
+
The class to be registered as a configuration.
|
48
|
+
|
49
|
+
Returns
|
50
|
+
-------
|
51
|
+
type
|
52
|
+
The same class passed as an argument, if registration is successful.
|
53
|
+
|
54
|
+
Raises
|
55
|
+
------
|
56
|
+
TypeError
|
57
|
+
If `config_class` is not a class or does not inherit from `IConfig`.
|
58
|
+
ValueError
|
59
|
+
If `config_class` does not have a `config` attribute or is already registered.
|
60
|
+
"""
|
61
|
+
|
62
|
+
if not isinstance(config_class, type):
|
63
|
+
raise TypeError(f"Expected a class, but got {type(config_class).__name__}.")
|
64
|
+
|
65
|
+
if not hasattr(config_class, 'config'):
|
66
|
+
raise ValueError(f"Class {config_class.__name__} must have a 'config' attribute.")
|
67
|
+
|
68
|
+
# Extract module name
|
69
|
+
section = Reflection(config_class).getFileName(remove_extension=True)
|
70
|
+
|
71
|
+
# Validate section
|
72
|
+
if section not in SECTIONS:
|
73
|
+
raise ValueError(
|
74
|
+
f"Invalid configuration section '{section}'. Allowed sections: {SECTIONS}"
|
75
|
+
)
|
76
|
+
|
77
|
+
# Validate inheritance
|
78
|
+
if not issubclass(config_class, IConfig):
|
79
|
+
raise TypeError(f"Class {config_class.__name__} must inherit from 'IConfig'.")
|
80
|
+
|
81
|
+
# Check if section is already registered
|
82
|
+
if section in self.cache_config.config:
|
83
|
+
raise ValueError(f"Configuration section '{section}' is already registered.")
|
84
|
+
|
85
|
+
# Register configuration
|
86
|
+
self.cache_config.register(
|
87
|
+
section=section,
|
88
|
+
data=Parser.toDict(config_class)
|
89
|
+
)
|
90
|
+
|
91
|
+
# Return the original class
|
92
|
+
return config_class
|
93
|
+
|
94
|
+
# Create a global Register instance
|
95
|
+
register = Register()
|
File without changes
|
File without changes
|
@@ -0,0 +1,96 @@
|
|
1
|
+
from typing import Dict, Any
|
2
|
+
|
3
|
+
class CacheConfig:
|
4
|
+
"""
|
5
|
+
Singleton class for managing application configuration caching.
|
6
|
+
|
7
|
+
This class ensures that configuration sections are registered only once
|
8
|
+
and provides methods to register, unregister, and retrieve configurations.
|
9
|
+
|
10
|
+
Attributes
|
11
|
+
----------
|
12
|
+
_instance : CacheConfig
|
13
|
+
A private class attribute that holds the singleton instance.
|
14
|
+
config : dict
|
15
|
+
A dictionary storing registered configuration sections.
|
16
|
+
"""
|
17
|
+
|
18
|
+
_instance = None
|
19
|
+
|
20
|
+
def __new__(cls, *args, **kwargs):
|
21
|
+
"""
|
22
|
+
Ensures a single instance of CacheConfig (Singleton Pattern).
|
23
|
+
|
24
|
+
Returns
|
25
|
+
-------
|
26
|
+
CacheConfig
|
27
|
+
The singleton instance of the class.
|
28
|
+
"""
|
29
|
+
if cls._instance is None:
|
30
|
+
cls._instance = super().__new__(cls)
|
31
|
+
cls._instance.config = {}
|
32
|
+
return cls._instance
|
33
|
+
|
34
|
+
def register(self, section: str, data: Dict[str, Any]) -> None:
|
35
|
+
"""
|
36
|
+
Registers a configuration section.
|
37
|
+
|
38
|
+
Parameters
|
39
|
+
----------
|
40
|
+
section : str
|
41
|
+
The name of the configuration section to register.
|
42
|
+
data : dict
|
43
|
+
The configuration data associated with the section.
|
44
|
+
|
45
|
+
Raises
|
46
|
+
------
|
47
|
+
ValueError
|
48
|
+
If the section is already registered.
|
49
|
+
"""
|
50
|
+
if section in self.config:
|
51
|
+
raise ValueError(f"Configuration section '{section}' is already registered.")
|
52
|
+
|
53
|
+
self.config[section] = data
|
54
|
+
|
55
|
+
def unregister(self, section: str) -> None:
|
56
|
+
"""
|
57
|
+
Unregisters a previously registered configuration section.
|
58
|
+
|
59
|
+
Parameters
|
60
|
+
----------
|
61
|
+
section : str
|
62
|
+
The name of the configuration section to remove.
|
63
|
+
|
64
|
+
Raises
|
65
|
+
------
|
66
|
+
KeyError
|
67
|
+
If the section is not found in the registered configurations.
|
68
|
+
"""
|
69
|
+
if section not in self.config:
|
70
|
+
raise KeyError(f"Configuration section '{section}' is not registered.")
|
71
|
+
|
72
|
+
del self.config[section]
|
73
|
+
|
74
|
+
def get(self, section: str) -> Dict[str, Any]:
|
75
|
+
"""
|
76
|
+
Retrieves the configuration for a specific section.
|
77
|
+
|
78
|
+
Parameters
|
79
|
+
----------
|
80
|
+
section : str
|
81
|
+
The name of the configuration section to retrieve.
|
82
|
+
|
83
|
+
Returns
|
84
|
+
-------
|
85
|
+
dict
|
86
|
+
The configuration data for the specified section.
|
87
|
+
|
88
|
+
Raises
|
89
|
+
------
|
90
|
+
KeyError
|
91
|
+
If the requested section is not found.
|
92
|
+
"""
|
93
|
+
if section not in self.config:
|
94
|
+
raise KeyError(f"Configuration section '{section}' is not registered.")
|
95
|
+
|
96
|
+
return self.config[section]
|
File without changes
|
@@ -0,0 +1,98 @@
|
|
1
|
+
from orionis.luminate.contracts.cache.cache_commands_interface import ICacheCommands
|
2
|
+
|
3
|
+
class CacheCommands(ICacheCommands):
|
4
|
+
"""
|
5
|
+
Singleton class for managing a cache of commands.
|
6
|
+
|
7
|
+
This class ensures that only one instance of the command cache exists
|
8
|
+
and provides methods for registering, unregistering, and retrieving commands.
|
9
|
+
"""
|
10
|
+
|
11
|
+
_instance = None
|
12
|
+
|
13
|
+
def __new__(cls, *args, **kwargs):
|
14
|
+
"""
|
15
|
+
Create or return the singleton instance of the CacheCommands class.
|
16
|
+
|
17
|
+
Ensures that only one instance of the CacheCommands class exists
|
18
|
+
during the lifetime of the application.
|
19
|
+
|
20
|
+
Returns
|
21
|
+
-------
|
22
|
+
CacheCommands
|
23
|
+
The singleton instance of the class.
|
24
|
+
"""
|
25
|
+
if cls._instance is None:
|
26
|
+
cls._instance = super().__new__(cls, *args, **kwargs)
|
27
|
+
cls._instance.commands = {}
|
28
|
+
return cls._instance
|
29
|
+
|
30
|
+
def register(self, signature: str, description: str, arguments: list, instance):
|
31
|
+
"""
|
32
|
+
Register a new command with its signature, description, and class instance.
|
33
|
+
|
34
|
+
Parameters
|
35
|
+
----------
|
36
|
+
signature : str
|
37
|
+
The unique identifier (signature) for the command.
|
38
|
+
description : str
|
39
|
+
A brief description of what the command does.
|
40
|
+
instance : class
|
41
|
+
The class or callable instance that defines the command behavior.
|
42
|
+
|
43
|
+
Raises
|
44
|
+
------
|
45
|
+
ValueError
|
46
|
+
If a command with the given signature already exists.
|
47
|
+
"""
|
48
|
+
if signature in self.commands:
|
49
|
+
raise ValueError(f"Command '{signature}' is already registered. Please ensure signatures are unique.")
|
50
|
+
|
51
|
+
self.commands[signature] = {
|
52
|
+
'instance':instance,
|
53
|
+
'arguments':arguments,
|
54
|
+
'description':description,
|
55
|
+
'signature':signature
|
56
|
+
}
|
57
|
+
|
58
|
+
def unregister(self, signature: str):
|
59
|
+
"""
|
60
|
+
Unregister an existing command by its signature.
|
61
|
+
|
62
|
+
Parameters
|
63
|
+
----------
|
64
|
+
signature : str
|
65
|
+
The unique identifier (signature) for the command to unregister.
|
66
|
+
|
67
|
+
Raises
|
68
|
+
------
|
69
|
+
KeyError
|
70
|
+
If the command with the given signature does not exist.
|
71
|
+
"""
|
72
|
+
if signature not in self.commands:
|
73
|
+
raise KeyError(f"Command '{signature}' not found.")
|
74
|
+
del self.commands[signature]
|
75
|
+
|
76
|
+
def get(self, signature: str):
|
77
|
+
"""
|
78
|
+
Retrieve the information of a registered command by its signature.
|
79
|
+
|
80
|
+
Parameters
|
81
|
+
----------
|
82
|
+
signature : str
|
83
|
+
The unique identifier (signature) for the command.
|
84
|
+
|
85
|
+
Returns
|
86
|
+
-------
|
87
|
+
dict
|
88
|
+
A dictionary containing the class, signature, and description of the command.
|
89
|
+
|
90
|
+
Raises
|
91
|
+
------
|
92
|
+
KeyError
|
93
|
+
If the command with the given signature does not exist.
|
94
|
+
"""
|
95
|
+
command = self.commands.get(signature)
|
96
|
+
if not command:
|
97
|
+
raise KeyError(f"Command with signature '{signature}' not found.")
|
98
|
+
return command
|
File without changes
|
File without changes
|
@@ -0,0 +1,50 @@
|
|
1
|
+
from dataclasses import dataclass, field
|
2
|
+
from typing import Dict
|
3
|
+
|
4
|
+
@dataclass
|
5
|
+
class App:
|
6
|
+
"""
|
7
|
+
Represents the application's core configuration.
|
8
|
+
|
9
|
+
This class defines the essential settings for the application, including
|
10
|
+
its name, debugging mode, encryption settings, and server-related properties.
|
11
|
+
|
12
|
+
Attributes
|
13
|
+
----------
|
14
|
+
name : str
|
15
|
+
The name of the application, used in logs, UI elements, and notifications.
|
16
|
+
debug : bool
|
17
|
+
Determines whether debugging mode is enabled. Should be `False` in production.
|
18
|
+
bytecode : bool
|
19
|
+
Indicates whether Python bytecode caching (.pyc files) is enabled.
|
20
|
+
timezone : str
|
21
|
+
The default timezone for the application, used for logging and scheduled tasks.
|
22
|
+
url : str
|
23
|
+
The base URL or host address where the application runs.
|
24
|
+
port : int
|
25
|
+
The port number the application listens on.
|
26
|
+
workers : int
|
27
|
+
The number of worker processes handling requests (affects performance).
|
28
|
+
reload : bool
|
29
|
+
Enables automatic server reloading when code changes (useful for development).
|
30
|
+
cipher : str
|
31
|
+
The encryption algorithm used for secure data handling (e.g., "AES-256-GCM").
|
32
|
+
key : str
|
33
|
+
The encryption key used for cryptographic operations.
|
34
|
+
custom : dict
|
35
|
+
A dictionary for storing additional custom properties. Defaults to an empty dictionary.
|
36
|
+
"""
|
37
|
+
|
38
|
+
name: str
|
39
|
+
debug: bool
|
40
|
+
bytecode: bool
|
41
|
+
timezone: str
|
42
|
+
url: str
|
43
|
+
port: int
|
44
|
+
workers: int
|
45
|
+
reload: bool
|
46
|
+
cipher: str
|
47
|
+
key: str
|
48
|
+
|
49
|
+
# Holds additional custom properties, initialized as an empty dictionary
|
50
|
+
custom: Dict[str, any] = field(default_factory=dict)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
from dataclasses import dataclass, field
|
2
|
+
from typing import Dict
|
3
|
+
|
4
|
+
@dataclass
|
5
|
+
class Auth:
|
6
|
+
"""
|
7
|
+
Represents a class that holds custom properties in a dictionary.
|
8
|
+
|
9
|
+
Attributes
|
10
|
+
----------
|
11
|
+
custom : dict
|
12
|
+
A dictionary to store any additional custom properties.
|
13
|
+
This field is initialized with an empty dictionary by default.
|
14
|
+
"""
|
15
|
+
|
16
|
+
# Custom dictionary to hold dynamic or extra properties, initialized as an empty dict
|
17
|
+
custom: Dict[str, any] = field(default_factory=dict)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
from dataclasses import dataclass, field
|
2
|
+
from typing import Dict, Any
|
3
|
+
|
4
|
+
@dataclass
|
5
|
+
class File:
|
6
|
+
"""
|
7
|
+
Represents a file storage path.
|
8
|
+
|
9
|
+
Attributes
|
10
|
+
----------
|
11
|
+
path : str
|
12
|
+
The file path used for caching.
|
13
|
+
"""
|
14
|
+
path: str
|
15
|
+
|
16
|
+
@dataclass
|
17
|
+
class Stores:
|
18
|
+
"""
|
19
|
+
Defines available cache stores.
|
20
|
+
|
21
|
+
Attributes
|
22
|
+
----------
|
23
|
+
file : File
|
24
|
+
An instance of `File` representing file-based cache storage.
|
25
|
+
"""
|
26
|
+
file: File
|
27
|
+
|
28
|
+
@dataclass
|
29
|
+
class Cache:
|
30
|
+
"""
|
31
|
+
Configuration for a cache system.
|
32
|
+
|
33
|
+
Attributes
|
34
|
+
----------
|
35
|
+
default : str
|
36
|
+
The default cache storage type (e.g., "ram" or "file").
|
37
|
+
stores : Stores
|
38
|
+
An instance of `Stores` containing cache storage configurations.
|
39
|
+
custom : Dict[str, Any], optional
|
40
|
+
A dictionary containing additional custom properties for cache configuration.
|
41
|
+
Defaults to an empty dictionary.
|
42
|
+
|
43
|
+
Notes
|
44
|
+
-----
|
45
|
+
- The `default` attribute defines the main cache type.
|
46
|
+
- The `stores` attribute holds configurations for different cache stores.
|
47
|
+
- The `custom` attribute allows for dynamic additional properties if needed.
|
48
|
+
"""
|
49
|
+
default: str
|
50
|
+
stores: Stores = field(default_factory=lambda: Stores(File("")))
|
51
|
+
custom: Dict[str, Any] = field(default_factory=dict)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
from dataclasses import dataclass, field
|
2
|
+
from typing import List, Optional, Union, Dict
|
3
|
+
|
4
|
+
@dataclass
|
5
|
+
class Cors:
|
6
|
+
"""
|
7
|
+
Interface that defines the structure for configuring Cross-Origin Resource Sharing (CORS)
|
8
|
+
for Starlette's CORSMiddleware.
|
9
|
+
|
10
|
+
Attributes
|
11
|
+
----------
|
12
|
+
allowed_methods : List[str]
|
13
|
+
A list of HTTP methods (e.g., "GET", "POST", "PUT", etc.) that are allowed for cross-origin requests.
|
14
|
+
|
15
|
+
allowed_origins : Union[str, List[str]]
|
16
|
+
A single origin or a list of origins that are allowed to access the resources.
|
17
|
+
Example: "https://example.com" or ["https://example.com", "https://another-origin.com"].
|
18
|
+
|
19
|
+
allowed_headers : List[str]
|
20
|
+
A list of headers that can be included in the requests from the allowed origins.
|
21
|
+
Example: ["Content-Type", "X-Custom-Header"].
|
22
|
+
|
23
|
+
exposed_headers : List[str]
|
24
|
+
A list of headers that the browser can access from the response.
|
25
|
+
Example: ["X-Exposed-Header"].
|
26
|
+
|
27
|
+
max_age : Optional[int]
|
28
|
+
The maximum amount of time (in seconds) that the results of a preflight request can be cached by the browser.
|
29
|
+
|
30
|
+
custom : Dict[str, any]
|
31
|
+
A dictionary for any custom properties or additional configurations related to CORS.
|
32
|
+
This field is initialized with an empty dictionary by default.
|
33
|
+
|
34
|
+
Notes
|
35
|
+
-----
|
36
|
+
- `allowed_methods`, `allowed_headers`, and `exposed_headers` should always be lists of strings.
|
37
|
+
- `allowed_origins` can either be a single string or a list of strings.
|
38
|
+
- `max_age` should be an integer representing the duration in seconds.
|
39
|
+
- The `custom` attribute is for additional configurations or custom properties.
|
40
|
+
"""
|
41
|
+
|
42
|
+
# List of allowed HTTP methods
|
43
|
+
allowed_methods: List[str]
|
44
|
+
|
45
|
+
# Single origin or list of origins allowed
|
46
|
+
allowed_origins: Union[str, List[str]]
|
47
|
+
|
48
|
+
# List of allowed headers
|
49
|
+
allowed_headers: List[str]
|
50
|
+
|
51
|
+
# List of headers that are accessible by the browser
|
52
|
+
exposed_headers: List[str]
|
53
|
+
|
54
|
+
# Time in seconds that the results of preflight requests can be cached
|
55
|
+
max_age: Optional[int]
|
56
|
+
|
57
|
+
# Custom properties or configurations for additional flexibility
|
58
|
+
custom: Dict[str, any] = field(default_factory=dict)
|