Skip to content

base

dev_tool.commands.base

REGISTRY = OrderedDict() module-attribute

CommandGroup

A base class for command groups.

This class provides automatic registration of decorated methods when the class is instantiated.

The constructor for the CommandGroup class.

This method finds all methods decorated with a register attribute and calls their register method to register them with the command system.

Source code in dev_tool/commands/base.py
def __init__(self) -> None:
    """
    The constructor for the CommandGroup class.

    This method finds all methods decorated with a register attribute
    and calls their register method to register them with the command system.
    """

    for value in self.__class__.__dict__.values():
        if callable(value) and hasattr(value, 'register'):
            value.register(self)

ordered_command

A decorator for registering command functions.

This decorator registers a method as a command with the specified label.

Parameters:

  • label (str) –

    The human-readable label for the command.

Returns:

  • Callable

    A decorator function.

Source code in dev_tool/commands/base.py
def ordered_command(label: str) -> Callable:
    """
    A decorator for registering command functions.

    This decorator registers a method as a command with the specified label.

    :param label: The human-readable label for the command.
    :return: A decorator function.
    """

    return _ordered_decorator(label, group=ActionGroup.COMMAND)

ordered_submenu

A decorator for registering submenu functions.

This decorator registers a method as a submenu provider with the specified label.

Parameters:

  • label (str) –

    The human-readable label for the submenu.

Returns:

  • Callable

    A decorator function.

Source code in dev_tool/commands/base.py
def ordered_submenu(label: str) -> Callable:
    """
    A decorator for registering submenu functions.

    This decorator registers a method as a submenu provider with the specified label.

    :param label: The human-readable label for the submenu.
    :return: A decorator function.
    """

    return _ordered_decorator(label, group=ActionGroup.SUBMENU)