def check(store_op_fun):

    def op_checker(store, *args, **kwargs):
        # NOTE(zhiyan): Trigger the hook of updating store
        # dynamic capabilities based on current store status.
        if store.conf.glance_store.store_capabilities_update_min_interval > 0:
            _schedule_capabilities_update(store)

        get_capabilities = [
            BitMasks.READ_ACCESS,
            BitMasks.READ_OFFSET if kwargs.get('offset') else BitMasks.NONE,
            BitMasks.READ_CHUNK if kwargs.get('chunk_size') else BitMasks.NONE
        ]

        op_cap_map = {
            'get': get_capabilities,
            'add': [BitMasks.WRITE_ACCESS],
            'delete': [BitMasks.WRITE_ACCESS]}

        op_exec_map = {
            'get': (exceptions.StoreRandomGetNotSupported
                    if kwargs.get('offset') or kwargs.get('chunk_size') else
                    exceptions.StoreGetNotSupported),
            'add': exceptions.StoreAddDisabled,
            'delete': exceptions.StoreDeleteNotSupported}

        op = store_op_fun.__name__.lower()

        try:
            req_cap = op_cap_map[op]
        except __HOLE__:
            LOG.warning(_LW('The capability of operation "%s" '
                            'could not be checked.'), op)
        else:
            if not store.is_capable(*req_cap):
                kwargs.setdefault('offset', 0)
                kwargs.setdefault('chunk_size', None)
                raise op_exec_map[op](**kwargs)

        return store_op_fun(store, *args, **kwargs)

    return op_checker
dataset/ETHPy150Open openstack/glance_store/glance_store/capabilities.py/check