def get_report_data(heapy_obj, depth=1):
    LOGGER.debug('Getting report data at depth %i', depth)
    report = {'total_objects': 0, 'total_bytes': 0, 'rows': []}
    totals = REPORT_TOTAL.findall(str(heapy_obj))
    if totals:
        report['total_objects'], report['total_bytes'] = (int(totals[0][0]),
                                                          int(totals[0][1]))
    items = REPORT_ITEMS.findall(str(heapy_obj))
    for index, row in enumerate(items):
        report['rows'].append({'item': row[-1],
                               'count': {'value': int(row[1]),
                                         'percent': int(row[2])},
                               'size': {'value': int(row[3]),
                                        'percent': int(row[4])},
                               'cumulative': {'value': int(row[5]),
                                              'percent': int(row[6])}})
        if depth < MAX_REFERRER_DEPTH:
            try:
                rows = len(heapy_obj.byrcs[index])
            except IndexError:
                LOGGER.warning('Could not process item at index %i', index)
                report['rows'][index]['error'] = 'Could not get referrers'
                continue
            if rows > MAX_ROW_COUNT_PER_LEVEL:
                rows = MAX_ROW_COUNT_PER_LEVEL
            for referrer_index in range(0, rows):
                report['rows'][index]['referrers'] =\
                    get_report_data(heapy_obj.byrcs[index].referrers.byrcs,
                                    depth + 1)

    header = REPORT_HEADER.findall(str(heapy_obj))
    if header:
        report['title'] = header[0]
    return report
dataset/ETHPy150Open gmr/tinman/tinman/handlers/heapy.py/get_report_data/original