work on docs, tests and some fix

This commit is contained in:
2025-03-05 02:20:02 +03:00
parent 971258728c
commit 2bf2144815
25 changed files with 262 additions and 397 deletions
+1 -2
View File
@@ -1,2 +1 @@
from .entity import Router
from .exceptions import InvalidDescriptionInstanceException
from .entity import Router
+6 -6
View File
@@ -4,7 +4,8 @@ from inspect import getfullargspec
from ..command.entity import Command
from ..command.params.flag.entity import Flag
from ..command.params.flag.flags_group.entity import FlagsGroup
from ..router.exceptions import (RepeatedCommandException, RepeatedFlagNameException,
from ..router.exceptions import (RepeatedCommandException,
RepeatedFlagNameException,
TooManyTransferredArgsException,
RequiredArgumentNotPassedException,
IncorrectNumberOfHandlerArgsException)
@@ -25,7 +26,6 @@ class Router:
def command(self, command: Command) -> Callable[[Any], Any]:
command.validate_commands_params()
self._validate_command(command)
def command_decorator(func):
@@ -47,10 +47,10 @@ class Router:
def input_command_handler(self, input_command: Command):
input_command_name: str = input_command.get_string_entity()
input_command_name: str = input_command.get_trigger()
input_command_flags: FlagsGroup = input_command.get_input_flags()
for command_entity in self._command_entities:
if input_command_name.lower() == command_entity['command'].get_string_entity().lower():
if input_command_name.lower() == command_entity['command'].get_trigger().lower():
if command_entity['command'].get_registered_flags():
if input_command_flags:
for flag in input_command_flags:
@@ -70,7 +70,7 @@ class Router:
def _validate_command(self, command: Command):
command_name: str = command.get_string_entity()
command_name: str = command.get_trigger()
if command_name in self.get_all_commands():
raise RepeatedCommandException()
if self._ignore_command_register:
@@ -116,6 +116,6 @@ class Router:
def get_all_commands(self) -> list[str]:
all_commands: list[str] = []
for command_entity in self._command_entities:
all_commands.append(command_entity['command'].get_string_entity())
all_commands.append(command_entity['command'].get_trigger())
return all_commands
-5
View File
@@ -1,8 +1,3 @@
class InvalidDescriptionInstanceException(Exception):
def __str__(self):
return "Invalid Description Instance"
class RepeatedCommandException(Exception):
def __str__(self):
return "Commands in handler cannot be repeated"