MCPcopy
hub / github.com/tanelpoder/0xtools / _add_container_actions

Method _add_container_actions

lib/0xtools/argparse.py:1353–1391  ·  view source on GitHub ↗
(self, container)

Source from the content-addressed store, hash-verified

1351 self._actions.remove(action)
1352
1353 def _add_container_actions(self, container):
1354 # collect groups by titles
1355 title_group_map = {}
1356 for group in self._action_groups:
1357 if group.title in title_group_map:
1358 msg = _('cannot merge actions - two groups are named %r')
1359 raise ValueError(msg % (group.title))
1360 title_group_map[group.title] = group
1361
1362 # map each action to its group
1363 group_map = {}
1364 for group in container._action_groups:
1365
1366 # if a group with the title exists, use that, otherwise
1367 # create a new group matching the container's group
1368 if group.title not in title_group_map:
1369 title_group_map[group.title] = self.add_argument_group(
1370 title=group.title,
1371 description=group.description,
1372 conflict_handler=group.conflict_handler)
1373
1374 # map the actions to their new group
1375 for action in group._group_actions:
1376 group_map[action] = title_group_map[group.title]
1377
1378 # add container's mutually exclusive groups
1379 # NOTE: if add_mutually_exclusive_group ever gains title= and
1380 # description= then this code will need to be expanded as above
1381 for group in container._mutually_exclusive_groups:
1382 mutex_group = self.add_mutually_exclusive_group(
1383 required=group.required)
1384
1385 # map the actions to their new mutex group
1386 for action in group._group_actions:
1387 group_map[action] = mutex_group
1388
1389 # add all actions to this container or their group
1390 for action in container._actions:
1391 group_map.get(action, self)._add_action(action)
1392
1393 def _get_positional_kwargs(self, dest, **kwargs):
1394 # make sure required is not specified

Callers 1

__init__Method · 0.80

Calls 3

add_argument_groupMethod · 0.95
_add_actionMethod · 0.45

Tested by

no test coverage detected