summaryrefslogtreecommitdiff
path: root/i18npool/oogen.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2020-03-14 15:40:11 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2021-04-07 16:17:20 +0000
commit4cbf2aa11503a34bc0b7bb7014116b0994f80c6c (patch)
tree85863d1a809b14db6d195941db988b9bafe44952 /i18npool/oogen.py
parent7619c4693e1b77dc72d0f9646f97f72a0f8d1a0e (diff)
Generate openoffice_dat.c from source.
Change-Id: I78f00cc0fb38cc5121a9d543197792a9f12e9177
Diffstat (limited to 'i18npool/oogen.py')
-rwxr-xr-xi18npool/oogen.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/i18npool/oogen.py b/i18npool/oogen.py
new file mode 100755
index 000000000000..5b53552cb196
--- /dev/null
+++ b/i18npool/oogen.py
@@ -0,0 +1,54 @@
+#!/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('''char_in.brk
+char.brk
+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(['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)