add metrics concept

This commit is contained in:
2025-05-12 16:22:29 +03:00
parent c38fe10006
commit 8b06e9cd39
19 changed files with 57 additions and 123 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
from enum import Enum
from enum import StrEnum
class PredefinedMessages(Enum):
class PredefinedMessages(StrEnum):
"""
Public. A dataclass with predetermined messages for quick use
"""
+3 -6
View File
@@ -201,9 +201,7 @@ class BaseApp:
return False
return True
def _error_handler(
self, error: BaseInputCommandException, raw_command: str
) -> None:
def _error_handler(self, error: BaseInputCommandException, raw_command: str) -> None:
"""
Private. Handles parsing errors of the entered command
:param error: error being handled
@@ -296,7 +294,7 @@ class BaseApp:
self._unknown_command_handler = unknown_command_handler
def _pre_cycle_setup(self) -> None:
def pre_cycle_setup(self) -> None:
"""
Private. Configures various aspects of the application before the start of the cycle
:return: None
@@ -330,7 +328,6 @@ class BaseApp:
self._print_func(message)
if self._messages_on_startup:
print("\n")
if not self._repeat_command_groups_description:
self._print_command_group_description()
@@ -381,7 +378,7 @@ class App(BaseApp):
Private. Starts the user input processing cycle
:return: None
"""
self._pre_cycle_setup()
self.pre_cycle_setup()
while True:
if self._repeat_command_groups_description:
self._print_command_group_description()
+4 -1
View File
@@ -1,4 +1,7 @@
__all__ = ["Flag", "InputFlag"]
__all__ = ["Flag", "InputFlag", "UndefinedInputFlags", "ValidInputFlags", "InvalidValueInputFlags", "Flags"]
from argenta.command.flag.models import Flag, InputFlag
from argenta.command.flag.flags.models import (UndefinedInputFlags,
ValidInputFlags, Flags,
InvalidValueInputFlags)
@@ -7,7 +7,7 @@ __all__ = [
]
from argenta.command.flags.models import (
from argenta.command.flag.flags.models import (
Flags,
InputFlags,
UndefinedInputFlags,
+1 -1
View File
@@ -1,5 +1,5 @@
from argenta.command.flag.models import Flag, InputFlag
from argenta.command.flags.models import InputFlags, Flags
from argenta.command.flag.flags.models import InputFlags, Flags
from argenta.command.exceptions import (
UnprocessedInputFlagException,
RepeatedInputFlagsException,
+4
View File
@@ -0,0 +1,4 @@
__all__ = ["get_time_of_pre_cycle_setup"]
from argenta.metrics.main import get_time_of_pre_cycle_setup
+26
View File
@@ -0,0 +1,26 @@
import io
from contextlib import redirect_stdout
from time import time
from argenta.router import Router
from argenta.command import Command
from argenta.response import Response
from argenta.response.status import Status
from argenta.command.flag import Flag, Flags
from argenta.app import App
def get_time_of_pre_cycle_setup(app: App) -> float:
start = time()
with redirect_stdout(io.StringIO()):
app.pre_cycle_setup()
end = time()
return end - start
+1 -1
View File
@@ -1,5 +1,5 @@
from argenta.response.status import Status
from argenta.command.flags import (
from argenta.command.flag.flags import (
ValidInputFlags,
UndefinedInputFlags,
InvalidValueInputFlags,
+1 -1
View File
@@ -6,7 +6,7 @@ from argenta.command import Command
from argenta.command.models import InputCommand
from argenta.response import Response, Status
from argenta.router.command_handler.entity import CommandHandlers, CommandHandler
from argenta.command.flags.models import (
from argenta.command.flag.flags import (
Flags,
InputFlags,
UndefinedInputFlags,