# Path: aredis/utils.py
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ClusterError(RedisError):
#     pass


from aredis.utils import (bool_ok,
                          nativestr,
                          NodeFlag,
                          list_keys_to_dict,
                          dict_merge)
from aredis.exceptions import (RedisError,
                               ClusterError)
        nodes = slot_info[2:]
        parse_node = lambda node: {
            'host': node[0],
            'port': node[1],
            'node_id': node[2] if len(node) > 2 else '',
            'server_type': 'slave'
        }
        res[(min_slot, max_slot)] = [parse_node(node) for node in nodes]
        res[(min_slot, max_slot)][0]['server_type'] = 'master'
    return res



class ClusterCommandMixin:

    NODES_FLAGS = dict_merge({
        'CLUSTER INFO': NodeFlag.ALL_NODES,
        'CLUSTER COUNTKEYSINSLOT': NodeFlag.SLOT_ID
    },
    list_keys_to_dict(
        ['CLUSTER NODES', 'CLUSTER SLOTS'], NodeFlag.RANDOM
    )
    )

    RESPONSE_CALLBACKS = {
        'CLUSTER ADDSLOTS': bool_ok,
        'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x),
        'CLUSTER COUNTKEYSINSLOT': lambda x: int(x),
        'CLUSTER DELSLOTS': bool_ok,
        'CLUSTER FAILOVER': bool_ok,

# Path: aredis/utils.py
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ClusterError(RedisError):
#     pass


# Path: aredis/commands/cluster.py
from aredis.utils import (bool_ok,
                          nativestr,
                          NodeFlag,
                          list_keys_to_dict,
                          dict_merge)
from aredis.exceptions import (RedisError,
                               ClusterError)

        nodes = slot_info[2:]
        parse_node = lambda node: {
            'host': node[0],
            'port': node[1],
            'node_id': node[2] if len(node) > 2 else '',
            'server_type': 'slave'
        }
        res[(min_slot, max_slot)] = [parse_node(node) for node in nodes]
        res[(min_slot, max_slot)][0]['server_type'] = 'master'
    return res



class ClusterCommandMixin:

    NODES_FLAGS = dict_merge({
        'CLUSTER INFO': NodeFlag.ALL_NODES,
        'CLUSTER COUNTKEYSINSLOT': NodeFlag.SLOT_ID
    },
    list_keys_to_dict(
        ['CLUSTER NODES', 'CLUSTER SLOTS'], NodeFlag.RANDOM
    )
    )

    RESPONSE_CALLBACKS = {
        'CLUSTER ADDSLOTS': bool_ok,
        'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x),
        'CLUSTER COUNTKEYSINSLOT': lambda x: int(x),
        'CLUSTER DELSLOTS': bool_ok,
        'CLUSTER FAILOVER': bool_ok,

        'CLUSTER FORGET': bool_ok,