예제 #1
0
                ('plus de 13 ans', 3),
            )),
        )),
        ('quartier de détention', (
            ('hommes', 6,),
            ('garçons', (
                ('moins de 13 ans', 0),
                ('plus de 13 ans', 2),
            )),
            ('jeunes filles', 1),
        )),
    )),
)


structures = get_all_structures(d)
tables = [build_table_dict(d, structure) for structure in structures]


with open('example.html', 'w') as f:
    f.write((
        '<style>table { border-collapse: collapse; }'
        'td, th { border: 1px solid grey; padding: 0 5px; }</style>'
        + '<h1>Optimal table</h1>'
        + build_optimal_table_dict(d).generate_html()
        + '<h1>All possible tables</h1>'
        + ''.join(repr(table.structure) +
                  ' ugliness : ' + str(table.get_ugliness()) +
                  table.generate_html() for table in tables)
    ).encode('utf-8'))
예제 #2
0
 def testHorizontal(self):
     html = build_table_dict(self.data, (h, h)).generate_html()
     self.assertEqualControl(html, 'level_mixed_hh.html')
예제 #3
0
                ('moins de 13 ans', 1),
                ('plus de 13 ans', 3),
            )),
        )),
        ('quartier de détention', (
            (
                'hommes',
                6,
            ),
            ('garçons', (
                ('moins de 13 ans', 0),
                ('plus de 13 ans', 2),
            )),
            ('jeunes filles', 1),
        )),
    )),
)

structures = get_all_structures(d)
tables = [build_table_dict(d, structure) for structure in structures]

with open('example.html', 'w') as f:
    f.write(('<style>table { border-collapse: collapse; }'
             'td, th { border: 1px solid grey; padding: 0 5px; }</style>' +
             '<h1>Optimal table</h1>' +
             build_optimal_table_dict(d).generate_html() +
             '<h1>All possible tables</h1>' + ''.join(
                 repr(table.structure) + ' ugliness : ' +
                 str(table.get_ugliness()) + table.generate_html()
                 for table in tables)).encode('utf-8'))
예제 #4
0
 def testVertical(self):
     html = build_table_dict(self.data, (v, v)).generate_html()
     self.assertEqualControl(html, 'level_2_vv.html')