Skip to content

Commit 4e91cc6

Browse files
committed
Merge branch 'master' into history_improvements
2 parents b84798c + e365db3 commit 4e91cc6

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

cmd2/cmd2.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,9 +3652,8 @@ def enable_category(self, category: str) -> None:
36523652
:param category: the category to enable
36533653
"""
36543654
for cmd_name in list(self.disabled_commands):
3655-
dc = self.disabled_commands[cmd_name]
3656-
cmd_category = getattr(dc.command_function, HELP_CATEGORY, None)
3657-
if cmd_category is not None and cmd_category == category:
3655+
func = self.disabled_commands[cmd_name].command_function
3656+
if hasattr(func, HELP_CATEGORY) and getattr(func, HELP_CATEGORY) == category:
36583657
self.enable_command(cmd_name)
36593658

36603659
def disable_command(self, command: str, message_to_print: str) -> None:
@@ -3696,10 +3695,7 @@ def disable_category(self, category: str, message_to_print: str) -> None:
36963695

36973696
for cmd_name in all_commands:
36983697
func = self.cmd_func(cmd_name)
3699-
cmd_category = getattr(func, HELP_CATEGORY, None)
3700-
3701-
# If this command is in the category, then disable it
3702-
if cmd_category is not None and cmd_category == category:
3698+
if hasattr(func, HELP_CATEGORY) and getattr(func, HELP_CATEGORY) == category:
37033699
self.disable_command(cmd_name, message_to_print)
37043700

37053701
# noinspection PyUnusedLocal

0 commit comments

Comments
 (0)