Пример #1
0
    def remove(self, **kwargs):
        """
        Handles the remove operation for units of the given type.

        :param type_id: type of unit being removed
        :type  type_id: str
        :param kwargs: CLI options as input by the user and parsed by the framework
        :type  kwargs: dict
        """
        UnitRemoveCommand.ensure_criteria(kwargs)

        repo_id = kwargs.pop(OPTION_REPO_ID.keyword)
        kwargs['type_ids'] = [self.type_id] # so it will be added to the criteria

        response = self.context.server.repo_unit.remove(repo_id, **kwargs)

        progress_msg = _('Progress on this task can be viewed using the '
                         'commands under "repo tasks".')

        if response.response_body.is_postponed():
            d = _('Unit removal postponed due to another operation on the destination '
                  'repository. ')
            d += progress_msg
            self.context.prompt.render_paragraph(d)
            self.context.prompt.render_reasons(response.response_body.reasons)
        else:
            self.context.prompt.render_paragraph(progress_msg)