Skip to content

Commit

Permalink
Update inheritedglyphs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenwong7bm committed Feb 8, 2023
1 parent 4e04fb9 commit a27274b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions inheritedglyphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -70,21 +71,21 @@ 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]
else:
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 = []

Expand Down

0 comments on commit a27274b

Please sign in to comment.