Skip to content

base

dev_tool.commands.base

REGISTRY = OrderedDict() module-attribute

CommandGroup

Bases: EventEmitterMixin

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)

configuration property

A property that gets the configuration manager instance.

Returns:

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_display

A decorator factory for display content registration.

This method creates a decorator that registers a method as display content in the command registry, preserving the order of declaration.

Parameters:

  • label (str) –

    The human-readable label for the display item.

Returns:

  • Callable

    A decorator function.

Source code in dev_tool/commands/base.py
def ordered_display(label: str) -> Callable:
    """
    A decorator factory for display content registration.

    This method creates a decorator that registers a method as display content
    in the command registry, preserving the order of declaration.

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

    return _ordered_decorator(label, group=ActionGroup.DISPLAY)

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)