24 lines
897 B
Python
24 lines
897 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Any, Callable, Optional, Self, Sequence
|
|
from Utils.Common import Common
|
|
from Utils.Checks import Check
|
|
|
|
class CommandModel:
|
|
|
|
def __init__(self:Self,
|
|
names:str|Sequence[str],
|
|
callback:Callable[[dict[str, Any|None], Optional[list[Any|None]]], None]
|
|
) -> None:
|
|
self.names:list[str] = Common.get_keys(names)
|
|
self.callback:Callable[[dict[str, Any|None], Optional[list[Any|None]]], None] = callback
|
|
|
|
def update(self:Self,
|
|
names:str|Sequence[str],
|
|
callback:Optional[Callable[[dict[str, Any|None], Optional[list[Any|None]]], None]] = None,
|
|
overwrite:bool = False
|
|
) -> None:
|
|
self.names += [name for name in Common.get_keys(names) if name not in self.names]
|
|
if Check.is_function(callback) or overwrite:
|
|
self.callback = callback |