(self, container)
| 1669 | self._actions.remove(action) |
| 1670 | |
| 1671 | def _add_container_actions(self, container): |
| 1672 | # collect groups by titles |
| 1673 | title_group_map = {} |
| 1674 | for group in self._action_groups: |
| 1675 | if group.title in title_group_map: |
| 1676 | # This branch could happen if a derived class added |
| 1677 | # groups with duplicated titles in __init__ |
| 1678 | msg = f'cannot merge actions - two groups are named {group.title!r}' |
| 1679 | raise ValueError(msg) |
| 1680 | title_group_map[group.title] = group |
| 1681 | |
| 1682 | # map each action to its group |
| 1683 | group_map = {} |
| 1684 | for group in container._action_groups: |
| 1685 | |
| 1686 | # if a group with the title exists, use that, otherwise |
| 1687 | # create a new group matching the container's group |
| 1688 | if group.title not in title_group_map: |
| 1689 | title_group_map[group.title] = self.add_argument_group( |
| 1690 | title=group.title, |
| 1691 | description=group.description, |
| 1692 | conflict_handler=group.conflict_handler) |
| 1693 | |
| 1694 | # map the actions to their new group |
| 1695 | for action in group._group_actions: |
| 1696 | group_map[action] = title_group_map[group.title] |
| 1697 | |
| 1698 | # add container's mutually exclusive groups |
| 1699 | # NOTE: if add_mutually_exclusive_group ever gains title= and |
| 1700 | # description= then this code will need to be expanded as above |
| 1701 | for group in container._mutually_exclusive_groups: |
| 1702 | if group._container is container: |
| 1703 | cont = self |
| 1704 | else: |
| 1705 | cont = title_group_map[group._container.title] |
| 1706 | mutex_group = cont.add_mutually_exclusive_group( |
| 1707 | required=group.required) |
| 1708 | |
| 1709 | # map the actions to their new mutex group |
| 1710 | for action in group._group_actions: |
| 1711 | group_map[action] = mutex_group |
| 1712 | |
| 1713 | # add all actions to this container or their group |
| 1714 | for action in container._actions: |
| 1715 | group_map.get(action, self)._add_action(action) |
| 1716 | |
| 1717 | def _get_positional_kwargs(self, dest, **kwargs): |
| 1718 | # make sure required is not specified |
no test coverage detected