summaryrefslogtreecommitdiffstats
path: root/scripts/genpuncttable.py
diff options
context:
space:
mode:
authorPeng Huang <shawn.p.huang@gmail.com>2010-05-17 10:41:11 +0800
committerPeng Huang <shawn.p.huang@gmail.com>2010-05-17 10:41:11 +0800
commit51438d761eb28fc9c19efc7eef82681ebdc86e65 (patch)
treee4376d04599181443cfd85c12c9c9edc8c6794b4 /scripts/genpuncttable.py
parent28d811bfa3676d1f96ec7b366caedececb6cc60b (diff)
parentc5aefb2ca27010474d12032f51be840c92ed4770 (diff)
downloadibus-libpinyin-51438d761eb28fc9c19efc7eef82681ebdc86e65.tar.gz
ibus-libpinyin-51438d761eb28fc9c19efc7eef82681ebdc86e65.tar.xz
ibus-libpinyin-51438d761eb28fc9c19efc7eef82681ebdc86e65.zip
Merge branch 'bopomofo'
Conflicts: ibus-pinyin.spec.in
Diffstat (limited to 'scripts/genpuncttable.py')
-rw-r--r--scripts/genpuncttable.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/genpuncttable.py b/scripts/genpuncttable.py
new file mode 100644
index 0000000..b852ec6
--- /dev/null
+++ b/scripts/genpuncttable.py
@@ -0,0 +1,32 @@
+# vim:set et sts=4:
+# -*- coding: utf-8 -*-
+
+from punct import *
+
+def tocstr(s):
+ s = s.replace('\\', '\\\\')
+ s = s.replace('"', '\\"')
+ return '"%s"' % s
+
+def gen_table():
+ array = []
+ i = 0
+ print 'static const gchar * const'
+ print 'puncts[] = {'
+ for k, vs in punct_map:
+ k = tocstr(k)
+ vs = map(tocstr, vs)
+ array.append((i, k))
+ line = ' %s, %s, NULL,' % (k, ", ".join(vs))
+ print line.encode("utf8")
+ i += len(vs) + 2
+ print '};'
+ print
+ print 'static const gchar * const * const'
+ print 'punct_table[] = {'
+ for i, k in array:
+ print ' &puncts[%d], // %s' % (i, k)
+ print '};'
+
+if __name__ == "__main__":
+ gen_table()