diff options
author | Peng Wu <alexepico@gmail.com> | 2011-11-09 09:58:11 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-11-09 09:58:11 +0800 |
commit | a3c4fcbc634c9c5db7522f2e05a0c18aa3f98427 (patch) | |
tree | 79532a993513c1dc200a069d112fba845d1b4219 /scripts | |
parent | 083a9fb6a32b1750c0924baf8cee550d75da64c3 (diff) | |
download | libpinyin-a3c4fcbc634c9c5db7522f2e05a0c18aa3f98427.tar.gz libpinyin-a3c4fcbc634c9c5db7522f2e05a0c18aa3f98427.tar.xz libpinyin-a3c4fcbc634c9c5db7522f2e05a0c18aa3f98427.zip |
write gen pinyin header
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/genpinyinheader.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/scripts/genpinyinheader.py b/scripts/genpinyinheader.py index ec03051..6c81726 100644 --- a/scripts/genpinyinheader.py +++ b/scripts/genpinyinheader.py @@ -20,10 +20,38 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +import os from genpinyintable import gen_content_table, \ gen_pinyin_index, gen_bopomofo_index from genspecialtable import gen_divided_table, gen_resplit_table +def get_table_content(tablename): + if tablename == 'CONTENT_TABLE': + return gen_content_table() + if tablename == 'PINYIN_INDEX': + return gen_pinyin_index() + if tablename == 'BOPOMOFO_INDEX': + return gen_bopomofo_index() + if tablename == 'DIVIDED_TABLE': + return gen_divided_table() + if tablename == 'RESPLIT_TABLE': + return gen_resplit_table() + + +def expand_file(filename): + infile = open(filename, "r") + for line in infile.readlines(): + line = line.rstrip(os.linesep) + if len(line) < 3 : + print(line) + continue + if line[0] == '@' and line[-1] == '@': + tablename = line[1:-1] + print(get_table_content(tablename)) + else: + print(line) + + ### main function ### if __name__ == "__main__": - pass + expand_file("pinyin_parser_table.h.in") |