Skip to content

Commit

Permalink
!squash
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Jun 10, 2023
1 parent f232024 commit 740108c
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/unihan_db/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ def import_char(
c: Unhn,
char: t.Dict[
str,
t.Dict[
str,
t.Union[int, str, t.List[t.Dict[str, object]], t.Dict[str, object]],
t.Union[
t.Dict[
str,
t.Union[int, str, t.List[t.Dict[str, object]], t.Dict[str, object]],
],
t.List[t.Dict[str, object]],
t.Dict[str, object],
],
],
): # NOQA: C901
Expand Down Expand Up @@ -253,17 +257,22 @@ def import_char(
("kIRG_VSource", kIRG_VSource, c.kIRG_VSource),
)

for f, model, column in irg_fields:
for f, Model, column in irg_fields:
if f in char:
d = char[f]
k = model(source=d["source"], location=d["location"])
column.append(k)
_md = char[f]
assert isinstance(_md, dict)
column.append(Model(source=_md["source"], location=_md["location"]))

if "kGSR" in char:
for d in char["kGSR"]:
assert isinstance(d, dict)
k = kGSR(set=d["set"], letter=d["letter"], apostrophe=d["apostrophe"])
c.kGSR.append(k)
for _kgsr in char["kGSR"]:
assert isinstance(_kgsr, dict)
c.kGSR.append(
kGSR(
set=_kgsr["set"],
letter=_kgsr["letter"],
apostrophe=_kgsr["apostrophe"],
)
)

if "kCheungBauerIndex" in char:
kcbi = char["kCheungBauerIndex"]
Expand Down

0 comments on commit 740108c

Please sign in to comment.