(response)
return info
Parse the response of Redis's INFO command into a Python dict.
In doing so, convert byte data into unicode.
Parse the response of Redis's INFO command into a Python dict.
In doing so, convert byte data into unicode.
Parse the response of Redis s INFO command into a Python dict . In doing so convert byte data into unicode .
def parse_info(response):
    '''Parse the response of Redis's INFO command into a Python dict.
In doing so, convert byte data into unicode.'''
    info = {}
    response = response.decode('utf-8')

    def get_value(value):
        if ',' and '=' not in value:
            return value
        sub_dict = {}
        for item in value.split(','):
            k, v = item.split('=')
            try:
                sub_dict[k] = int(v)
            except ValueError:
                sub_dict[k] = v
        return sub_dict
    data = info
    for line in response.splitlines():
        keyvalue = line.split(':')
        if len(keyvalue) == 2:
            key, value = keyvalue
            try:
                data[key] = int(value)
            except ValueError:
                data[key] = get_value(value)
        else:
            data = {}
            info[line[2:]] = data
    return info
def parse_info ( response ) : info = { } response = response . decode ( 'utf-8' ) def get_value ( value ) : if ',' and '=' not in value : return value sub_dict = { } for item in value . split ( ',' ) : k , v = item . split ( '=' ) try : sub_dict [ k ] = int ( v ) except ValueError : sub_dict [ k ] = v return sub_dict data = info for line in response . splitlines ( ) : keyvalue = line . split ( ':' ) if len ( keyvalue ) == 2 : key , value = keyvalue try : data [ key ] = int ( value ) except ValueError : data [ key ] = get_value ( value ) else : data = { } info [ line [ 2 : ] ] = data return info