summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2018-10-22 17:05:31 +0800
committerPeng Wu <alexepico@gmail.com>2018-10-22 17:21:31 +0800
commit6716c315210920b2f1e7b3ef816052d051ab19dd (patch)
treebccf9450b56866d4213eb71572573515df680a5d
parentf3863de494c7de92f2e18728f0d52fb20828138c (diff)
downloadibus-libpinyin-6716c315210920b2f1e7b3ef816052d051ab19dd.tar.gz
ibus-libpinyin-6716c315210920b2f1e7b3ef816052d051ab19dd.tar.xz
ibus-libpinyin-6716c315210920b2f1e7b3ef816052d051ab19dd.zip
update update-simptrad-table.py for python3
-rwxr-xr-xscripts/update-simptrad-table.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/scripts/update-simptrad-table.py b/scripts/update-simptrad-table.py
index 718231d..d6fc7dd 100755
--- a/scripts/update-simptrad-table.py
+++ b/scripts/update-simptrad-table.py
@@ -6,7 +6,7 @@ from ZhConversion import *
from valid_hanzi import *
def convert(s, d, n):
- out = u""
+ out = ""
end = len(s)
begin = 0
while begin < end:
@@ -20,9 +20,9 @@ def convert(s, d, n):
return out
def filter_more(records, n):
- han = filter(lambda (k, v): len(k) <= n, records)
+ han = [(k, v) for (k, v) in records if len(k) <= 0]
hand = dict(han)
- hanm = filter(lambda (k, v): convert(k, hand, n) != v, records)
+ hanm = [(k, v) for (k, v) in records if convert(k, hand, n) != v]
return hanm + han
def filter_func(args):
@@ -46,24 +46,24 @@ def filter_func(args):
return True
def get_records():
- records = zh2Hant.items()
+ records = list(zh2Hant.items())
- records = filter(filter_func, records)
+ records = list(filter(filter_func, records))
- maxlen = max(map(lambda (k,v): len(k), records))
+ maxlen = max([len(k) for (k, v) in records])
for i in range(1, maxlen - 1):
records = filter_more(records, i)
- records = map(lambda (k, v): (k.encode("utf8"), v.encode("utf8")), records)
+ records = [(k.encode("utf8"), v.encode("utf8")) for (k, v) in records]
records.sort()
return maxlen, records
def main():
- print "static const gchar *simp_to_trad[][2] = {"
+ print("static const gchar *simp_to_trad[][2] = {")
maxlen, records = get_records()
for s, ts in records:
- print ' { "%s", "%s" },' % (s, ts)
- print "};"
- print '#define SIMP_TO_TRAD_MAX_LEN (%d)' % maxlen
+ print(' { "%s", "%s" },' % (s, ts))
+ print("};")
+ print('#define SIMP_TO_TRAD_MAX_LEN (%d)' % maxlen)
if __name__ == "__main__":
main()