# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# def pairs_to_dict(response):
#     """Creates a dict given a list of key/value pairs"""
#     it = iter(response)
#     return dict(zip(it, it))
# 
# def string_keys_to_dict(key_string, callback):
#     return dict.fromkeys(key_string.split(), callback)
# 
# def bool_ok(response):
#     return nativestr(response) == 'OK'


from aredis.exceptions import RedisError
from aredis.utils import (dict_merge, pairs_to_dict,
                          string_keys_to_dict, bool_ok)


def stream_list(response):
    result = []
    if response:
        for r in response:
            kv_pairs = r[1]
            kv_dict = dict()
            while kv_pairs and len(kv_pairs) > 1:
                kv_dict[kv_pairs.pop()] = kv_pairs.pop()
            result.append((r[0], kv_dict))
    return result


def multi_stream_list(response):
    result = dict()
    if response:
        for r in response:
            result[r[0]] = stream_list(r[1])
    return result


def list_of_pairs_to_dict(response):
    return [pairs_to_dict(row) for row in response]


def parse_xinfo_stream(response):
    res = pairs_to_dict(response)
    if res['first-entry'] and len(res['first-entry']) > 0:

# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# def pairs_to_dict(response):
#     """Creates a dict given a list of key/value pairs"""
#     it = iter(response)
#     return dict(zip(it, it))
# 
# def string_keys_to_dict(key_string, callback):
#     return dict.fromkeys(key_string.split(), callback)
# 
# def bool_ok(response):
#     return nativestr(response) == 'OK'


# Path: aredis/commands/streams.py
from aredis.exceptions import RedisError
from aredis.utils import (dict_merge, pairs_to_dict,
                          string_keys_to_dict, bool_ok)



def stream_list(response):
    result = []
    if response:
        for r in response:
            kv_pairs = r[1]
            kv_dict = dict()
            while kv_pairs and len(kv_pairs) > 1:
                kv_dict[kv_pairs.pop()] = kv_pairs.pop()
            result.append((r[0], kv_dict))
    return result


def multi_stream_list(response):
    result = dict()
    if response:
        for r in response:
            result[r[0]] = stream_list(r[1])
    return result


def list_of_pairs_to_dict(response):
    return [pairs_to_dict(row) for row in response]


def parse_xinfo_stream(response):
    res = pairs_to_dict(response)
    if res['first-entry'] and len(res['first-entry']) > 0:

        res['first-entry'][1] = pairs_to_dict(res['first-entry'][1])