def multiple_action_transactions(self, args):
        action = None

        # TODO: catch that we don't mix in requisiton and stock report keywords in the same multi-action message?

        _args = iter(args)

        def next():
            return _args.next()

        found_product_for_action = True
        while True:
            try:
                keyword = next()
            except StopIteration:
                if not found_product_for_action:
                    raise SMSError('product expected for action "%s"' % action)
                break

            old_action = action
            _next_action = self.C.action_by_keyword(keyword)
            if _next_action:
                action = _next_action
                if not found_product_for_action:
                    raise SMSError('product expected for action "%s"' % old_action.keyword)
                found_product_for_action = False
                continue

            try:
                product = self.product_from_code(keyword)
                found_product_for_action = True
            except:
                product = None
            if product:
                if not action:
                    raise SMSError('need to specify an action before product')
                elif action.action == const.StockActions.STOCKOUT:
                    value = 0
                else:
                    try:
                        value = int(next())
                    except (ValueError, __HOLE__):
                        raise SMSError('quantity expected for product "%s"' % product.code)

                yield StockTransactionHelper(
                    domain=self.domain.name,
                    location_id=self.location.location_id,
                    case_id=self.case_id,
                    product_id=product.get_id,
                    action=action.action,
                    subaction=action.subaction,
                    quantity=value,
                )
                continue

            raise SMSError('do not recognize keyword "%s"' % keyword)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/commtrack/sms.py/StockReportParser.multiple_action_transactions