def resolve_declare_monkey(self, sst, lnk, dir, action):  # pragma: no cover
    declare = lnk.options.get('create') in ('always', dir)
    assrt = lnk.options.get('assert') in ('always', dir)
    requested_type = lnk.options.get('node', {}).get('type')

    def do_resolved(type, subtype):
        err = None
        if type is None:
            if declare:
                err = self.declare(sst, lnk, action)
            else:
                err = NotFound(text='no such queue: %s' % lnk.name)
        else:
            if assrt:
                expected = lnk.options.get('node', {}).get('type')
                if expected and type != expected:
                    err = AssertionFailed(
                        text='expected %s, got %s' % (expected, type))
            if err is None:
                action(type, subtype)
        if err:
            tgt = lnk.target
            tgt.error = err
            del self._attachments[tgt]
            tgt.closed = True
            return

    self.resolve(sst, lnk.name, do_resolved, node_type=requested_type,
                 force=declare)
dataset/ETHPy150Open celery/kombu/kombu/transport/qpid_patches.py/resolve_declare_monkey/original