diff options
author | Peng Wu <alexepico@gmail.com> | 2011-12-14 15:06:39 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2011-12-14 15:06:39 +0800 |
commit | cd8659a2748c8afe04e3c8e0964845a84ed739df (patch) | |
tree | 21532594c2867aa66863640c954bb3ccb8eb3bf9 /scripts/gendoublepinyinheader.py | |
parent | 8fe06a2c0f4f299bb2fa1610769814913fee5d6f (diff) | |
download | libpinyin-cd8659a2748c8afe04e3c8e0964845a84ed739df.tar.gz libpinyin-cd8659a2748c8afe04e3c8e0964845a84ed739df.tar.xz libpinyin-cd8659a2748c8afe04e3c8e0964845a84ed739df.zip |
refactor expand_file
Diffstat (limited to 'scripts/gendoublepinyinheader.py')
-rw-r--r-- | scripts/gendoublepinyinheader.py | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/scripts/gendoublepinyinheader.py b/scripts/gendoublepinyinheader.py index 96a363e..15de35e 100644 --- a/scripts/gendoublepinyinheader.py +++ b/scripts/gendoublepinyinheader.py @@ -20,9 +20,8 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -import os import pinyin - +from utils import expand_file def gen_shengmu_table(scheme): entries = [] @@ -64,20 +63,7 @@ def get_table_content(tablename): if part == "YUN": return gen_yunmu_table(scheme) -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__": - expand_file("double_pinyin_table.h.in") + expand_file("double_pinyin_table.h.in", get_table_content) |