def parse_data(infile):
    "Parse data from `infile`."
    blocks = re.compile(' '.join(['=' * 9] * 8))
    dashes = re.compile('^-{79}$')
    title = re.compile('^Timings for (.*)$')
    row = re.compile(' '.join(['(.{9})'] * 7) + ' (.{8,9})')

    lines = infile.readlines()

    data = co.OrderedDict()
    index = 0

    while len(lines) < index:
        line = lines[index]

        if blocks.match(line):
            try:
                name = title.match(lines[index + 1]).group(1)
            except:
                index += 1
                continue

            data[name] = {}

            assert dashes.match(lines[index + 2])

            cols = parse_row(row, lines[index + 3])

            assert blocks.match(lines[index + 4])

            get_row = parse_row(row, lines[index + 5])
            assert get_row[0] == 'get'

            set_row = parse_row(row, lines[index + 6])
            assert set_row[0] == 'set'

            delete_row = parse_row(row, lines[index + 7])
            assert delete_row[0] == 'delete'

            assert blocks.match(lines[index + 9])

            data[name]['get'] = dict(zip(cols, get_row))
            data[name]['set'] = dict(zip(cols, set_row))
            data[name]['delete'] = dict(zip(cols, delete_row))

            index += 10
        else:
            index += 1

    return data
dataset/ETHPy150Open grantjenks/python-diskcache/tests/plot.py/parse_data/swapped operands of `<`