8 match
= re
.match('\(= c(?P<c>\d+)(?P<t>.) (?P<v>\d+)\)', line
)
10 comps
[match
.group('c')] = comps
.get(match
.group('c'), {})
11 comps
[match
.group('c')][match
.group('t')] = int(match
.group('v'))
13 maxx
= max(c
['x']+c
['w'] for c
in comps
.values())
14 maxy
= max(c
['y']+c
['h'] for c
in comps
.values())
15 print('$\\begin{{array}}{{|l|{}|}}'.format('@{}c@{}'*maxx
))
17 print('\t & {}\\\\'.format(
18 ' & '.join(map(str, range(1, maxx
+1)))))
20 for y
in range(1, maxy
+1):
21 print('\t{} & '.format(y
), end
='')
22 for x
in range(1, maxx
+1):
23 cs
= [c
for c
in comps
if
24 comps
[c
]['y'] + comps
[c
]['h'] >= y
and comps
[c
]['y'] <= y
and
25 comps
[c
]['x'] + comps
[c
]['w'] >= x
and comps
[c
]['x'] <= x
]
27 print('\\hspace{{.5mm}}{}\\hspace{{.5mm}}'.format(cs
[0]), end
='')
32 print('\t\\bottomrule')
33 print('\\end{array}$')