def format_binary_data(data):
    stream = io.BytesIO(data)
    row_offset = 0
    row_size = 16
    while True:
        data = stream.read(row_size)
        if (not data):
            return
        hexrow = io.BytesIO()
        asciirow = io.BytesIO()
        for (i, byte) in enumerate(data):
            if (32 <= ord(byte) <= 126):
                asciirow.write(byte)
            else:
                asciirow.write('.')
            hexrow.write(format(ord(byte), '02x'))
            if (i < 15):
                if ((i % 2) == 1):
                    hexrow.write(' ')
                if ((i % 8) == 7):
                    hexrow.write(' ')
            row_offset += 1
        (yield '{0:08x}:   {1:40s}   {2:16s}'.format(row_offset, hexrow.getvalue(), asciirow.getvalue()))
def format_binary_data(data):
    stream = io.BytesIO(data)
    row_offset = 0
    row_size = 16
    while True:
        data = stream.read(row_size)
        if (not data):
            return
        hexrow = io.BytesIO()
        asciirow = io.BytesIO()
        for (i, byte) in enumerate(data):
            if (32 <= ord(byte) <= 126):
                asciirow.write(byte)
            else:
                asciirow.write('.')
            hexrow.write(format(ord(byte), '02x'))
            if (i < 15):
                if ((i % 2) == 1):
                    hexrow.write(' ')
                if ((i % 8) == 7):
                    hexrow.write(' ')
            row_offset += 1
        (yield '{0:08x}:   {1:40s}   {2:16s}'.format(row_offset, hexrow.getvalue(), asciirow.getvalue()))