MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / check_parser_uninstallable

Method check_parser_uninstallable

cmd2/cmd2.py:1052–1072  ·  view source on GitHub ↗
(parser: Cmd2ArgumentParser)

Source from the content-addressed store, hash-verified

1050 cmdset_id = id(cmdset)
1051
1052 def check_parser_uninstallable(parser: Cmd2ArgumentParser) -> None:
1053 try:
1054 subparsers_action = parser.get_subparsers_action()
1055 except ValueError:
1056 # No subcommands to check
1057 return
1058
1059 # Prevent redundant traversal of parser aliases
1060 checked_parsers: set[Cmd2ArgumentParser] = set()
1061
1062 for subparser in subparsers_action.choices.values():
1063 if subparser in checked_parsers:
1064 continue
1065 checked_parsers.add(subparser)
1066
1067 attached_cmdset_id = getattr(subparser, constants.PARSER_ATTR_COMMANDSET_ID, None)
1068 if attached_cmdset_id is not None and attached_cmdset_id != cmdset_id:
1069 raise CommandSetRegistrationError(
1070 f"Cannot uninstall CommandSet: '{subparser.prog}' is required by another CommandSet"
1071 )
1072 check_parser_uninstallable(subparser)
1073
1074 methods: list[tuple[str, Callable[..., Any]]] = inspect.getmembers(
1075 cmdset,

Callers

nothing calls this directly

Calls 3

get_subparsers_actionMethod · 0.80
addMethod · 0.80

Tested by

no test coverage detected