1# Wrapping Python data as Metakit views
2#
3# Expected output (3 times):
4#    a      b      c
5#    -----  -----  -
6#    one    un     1
7#    two    deux   2
8#    three  trois  3
9#    -----  -----  -
10#    Total: 3 rows
11
12import metakit
13
14class C:
15    def __init__(self, a, b, c):
16    	self.a, self.b, self.c = a, b, c
17
18dc = [	C ('one', 'un', 1),
19	C ('two', 'deux', 2),
20	C ('three', 'trois', 3)  ]
21
22dd = [	{'a':'one', 'b':'un', 'c':1},
23	{'a':'two', 'b':'deux', 'c':2},
24	{'a':'three', 'b':'trois', 'c':3}  ]
25
26dt = [	('one', 'un', 1),
27	('two', 'deux', 2),
28	('three', 'trois', 3)  ]
29
30pl = [	metakit.property('S','a'),
31	metakit.property('S','b'),
32	metakit.property('I','c')  ]
33
34vc = metakit.wrap(dc, pl)
35vd = metakit.wrap(dd, pl)
36vt = metakit.wrap(dt, pl, 1)
37
38metakit.dump(vc, 'class objects:')
39metakit.dump(vd, 'dictionary elements:')
40metakit.dump(vt, 'tuples (by position):')
41