summaryrefslogtreecommitdiff
path: root/i18npool/oogen.py
blob: 107212fa81bd653e6f032859c6f80fd9dd772f2b (plain)
1
2
3
4
5
6
7
8
9
10
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3

import os, sys, subprocess

output_name = sys.argv[1]
output_dir = os.path.split(output_name)[0]
dattmp_name = os.path.splitext(output_name)[0] + '.tmp'
gncmtmp_name = output_name.replace('_dat.c', '_tmp.c')
priv_dir = sys.argv[2]
rsp_name = os.path.join(priv_dir, dattmp_name)

if not os.path.isdir(priv_dir):
    os.mkdir(priv_dir)

open(dattmp_name, 'w').write('''count_word.brk
dict_word_he.brk
dict_word_hu.brk
dict_word_nodash.brk
dict_word_prepostdash.brk
dict_word.brk
edit_word_he.brk
edit_word_hu.brk
edit_word.brk
line.brk
sent.brk
''')

rc = subprocess.call(['/usr/sbin/gencmn',
                      '-n',
                      'OpenOffice',
                      '-t',
                      'tmp',
                      '-S',
                      '-d',
                      output_dir,
                      '0',
                      dattmp_name])

os.unlink(dattmp_name)

if rc != 0:
    sys.exit(rc)

d = open(gncmtmp_name, 'r').read()
with open(output_name, 'w') as ofile:
    ofile.write('''#ifdef _MSC_VER
#pragma warning(disable : 4229)
#endif
''')
    ofile.write(d)

os.unlink(gncmtmp_name)