From a27274b0b6c47cda82d3ef3c1fd44c5d794abd0b Mon Sep 17 00:00:00 2001 From: haydenwong7bm <51369959+haydenwong7bm@users.noreply.github.com> Date: Wed, 8 Feb 2023 23:51:03 +0800 Subject: [PATCH] Update inheritedglyphs.py --- inheritedglyphs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/inheritedglyphs.py b/inheritedglyphs.py index 0cc87d8..ffa9d33 100644 --- a/inheritedglyphs.py +++ b/inheritedglyphs.py @@ -27,6 +27,7 @@ def _read_tsv(path): with open(path, 'rt', encoding='utf-8') as file: for line in file: key_value = line.rstrip('\n').split('\t') + key = key_value[0] value = key_value[1] @@ -70,11 +71,12 @@ def _read_tsv(path): IVS_MJ_TABLE = _read_tsv('conversion-tables/ivs-moji-joho.txt') def convert(string: str, *, use_supp_planes='c', use_compatibility=[J, K, T], convert_inherited=True, use_ivs=False) -> str: - if (not use_supp_planes) or (use_supp_planes not in {CORE, ALL}): - raise TypeError if not use_supp_planes: use_supp_planes = '' + if use_supp_planes not in {'', CORE, ALL}: + raise TypeError + if use_compatibility: compatibility_var_map = lambda x: {J: J_TABLE, K: K_TABLE, T: T_TABLE}[x] compatibility_order = [compatibility_var_map(i) for i in use_compatibility] @@ -82,9 +84,8 @@ def convert(string: str, *, use_supp_planes='c', use_compatibility=[J, K, T], co compatibility_order = [] if use_ivs: - ivs_var_map = lambda x: {AJ1: AJ1_TABLE, MJ: MJ_TABLE}[x] - if use_ivs: - ivs_order = [ivs_var_map(i) for i in use_ivs] + ivs_var_map = lambda x: {AJ1: IVS_AJ1_TABLE, MJ: IVS_MJ_TABLE}[x] + ivs_order = [ivs_var_map(i) for i in use_ivs] else: ivs_order = []