Statistics
| Branch: | Tag: | Revision:

root / build @ 5d1d131b

History | View | Annotate | Download (836 Bytes)

1
#!/usr/bin/env python
2

    
3
import os
4
import stat
5

    
6
SRCDIR = 'kamaki'
7
SRC = 'kamaki.py'
8
CLIENT = 'client.py'
9
DSTDIR = 'bin'
10
DST = 'kamaki'
11

    
12

    
13
def main():
14
    if not os.path.exists(DSTDIR):
15
        os.makedirs(DSTDIR)
16
    dstpath = os.path.join(DSTDIR, DST)
17
    dst = open(dstpath, 'w')
18
    
19
    srcpath = os.path.join(SRCDIR, SRC)
20
    clientpath = os.path.join(SRCDIR, CLIENT)
21

    
22
    for line in open(srcpath):
23
        if line.startswith('from client import'):
24
            for l in open(clientpath):
25
                if l.startswith('#'):
26
                    continue    # Skip comments
27
                dst.write(l)
28
        else:
29
            dst.write(line)
30
    
31
    dst.close()
32
    
33
    # Make file executable
34
    mode = stat.S_IMODE(os.stat(dstpath).st_mode)
35
    mode |= 0111
36
    os.chmod(dstpath, mode)
37

    
38

    
39
if __name__ == '__main__':
40
    main()