Determine the category for a command. :param func: the do_* function implementing the command :return: category name
(self, func: BoundCommandFunc)
| 3343 | return cast(BoundCommandFunc, command_func) if callable(command_func) else None |
| 3344 | |
| 3345 | def _get_command_category(self, func: BoundCommandFunc) -> str: |
| 3346 | """Determine the category for a command. |
| 3347 | |
| 3348 | :param func: the do_* function implementing the command |
| 3349 | :return: category name |
| 3350 | """ |
| 3351 | # Check if the command function has a category. |
| 3352 | if hasattr(func, constants.CMD_ATTR_HELP_CATEGORY): |
| 3353 | category: str = getattr(func, constants.CMD_ATTR_HELP_CATEGORY) |
| 3354 | |
| 3355 | # Otherwise get the category from its defining class. |
| 3356 | else: |
| 3357 | defining_cls = get_defining_class(func) |
| 3358 | category = getattr(defining_cls, "DEFAULT_CATEGORY", self.DEFAULT_CATEGORY) |
| 3359 | |
| 3360 | return category |
| 3361 | |
| 3362 | def onecmd(self, statement: Statement | str, *, add_to_history: bool = True) -> bool: |
| 3363 | """Execute the actual do_* method for a command. |
no test coverage detected