Enable a command by restoring its functions. :param command: the command being enabled
(self, command: str)
| 5591 | set_title(title) |
| 5592 | |
| 5593 | def enable_command(self, command: str) -> None: |
| 5594 | """Enable a command by restoring its functions. |
| 5595 | |
| 5596 | :param command: the command being enabled |
| 5597 | """ |
| 5598 | # If the command is already enabled, then return |
| 5599 | if command not in self.disabled_commands: |
| 5600 | return |
| 5601 | |
| 5602 | command_func_name = constants.COMMAND_FUNC_PREFIX + command |
| 5603 | help_func_name = constants.HELP_FUNC_PREFIX + command |
| 5604 | completer_func_name = constants.COMPLETER_FUNC_PREFIX + command |
| 5605 | |
| 5606 | # Restore the command function to its original value |
| 5607 | dc = self.disabled_commands[command] |
| 5608 | setattr(self, command_func_name, dc.command_func) |
| 5609 | |
| 5610 | # Restore the help function to its original value |
| 5611 | if dc.help_func is None: |
| 5612 | delattr(self, help_func_name) |
| 5613 | else: |
| 5614 | setattr(self, help_func_name, dc.help_func) |
| 5615 | |
| 5616 | # Restore the completer function to its original value |
| 5617 | if dc.completer_func is None: |
| 5618 | delattr(self, completer_func_name) |
| 5619 | else: |
| 5620 | setattr(self, completer_func_name, dc.completer_func) |
| 5621 | |
| 5622 | # Remove the disabled command entry |
| 5623 | del self.disabled_commands[command] |
| 5624 | |
| 5625 | def enable_category(self, category: str) -> None: |
| 5626 | """Enable an entire category of commands. |
no outgoing calls