example_encoder.py 894 Bytes
Newer Older
1
2
3
4
5
6
7
#!/usr/bin/python

import labcomm
import sys
import test

if __name__ == '__main__':
8
    version = sys.argv[2] if len(sys.argv) == 3 else "LabComm2014"
9
10
    encoder = labcomm.Encoder(labcomm.StreamWriter(open(sys.argv[1], 'w')), version)
    encoder.add_decl(test.twoLines.signature)
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    tl = dict(
        l1=dict(
            start=dict(
                x=dict(val=1), 
                y=dict(val=11)
            ),
            end=dict(
                x=dict(val=2), 
                y=dict(val=22)
            )
        ),
        l2=dict(
            start=dict(
                x=dict(val=3), 
                y=dict(val=33)
            ),
            end=dict(
                x=dict(val=4), 
                y=dict(val=44)
            )
        ),
        f=dict(
            a=10, 
            b=20, 
            c=False
        )
    )
38
    encoder.encode(tl, test.twoLines.signature)