def _format_tables(tables, id_label='id', separator='.', include_headers=True,
                   include_data=True):
    answ = []
    assert include_data or include_headers, "This method is pretty useless if you don't include anything!"

    for table_name, table in sorted(tables.items()):
        new_table = []
        keys = sorted(table.items()[0][1].keys()) # the keys for every row are the same

        if include_headers:
            id_key = [id_label]
            id_len = len(table.keys()[0]) # this is a proxy for the complexity of the ID
            if id_len > 1:
                id_key += ["{id}__{count}".format(id=id_label, count=i) \
                           for i in range(id_len)]
            header_vals = [separator.join(key) for key in keys]
            new_table.append(FormattedRow(header_vals, id_key, separator,
                                          is_header_row=True))

        if include_data:
            for id, row in sorted(table.items()):
                values = [row[key] for key in keys]
                new_table.append(FormattedRow(values, id, separator))

        answ.append((separator.join(table_name), new_table))
    return answ
Update summary with a package
dataset/ETHPy150Open dimagi/commcare-hq/corehq/ex-submodules/couchexport/export.py/_format_tables--crossover with--dataset/ETHPy150Open mathcamp/pypicloud/pypicloud/cache/dynamo.py/PackageSummary.update_with