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 695dc80 commit 5713a18
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions src/unihan_db/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,35 +77,45 @@ def import_char(
c.kTotalStrokes.append(kTotalStrokes(hans=d["zh-Hans"], hant=d["zh-Hant"]))

if "kHanyuPinyin" in char:
for d in char["kHanyuPinyin"]:
k = kHanyuPinyin()
assert isinstance(d["locations"], list)
for loc in d["locations"]:
for _khp in char["kHanyuPinyin"]:
assert isinstance(_khp, dict)
assert isinstance(_khp["locations"], list)
assert isinstance(_khp["readings"], list)
khp_readings: t.List[UnhnReading] = []
khp_locations: t.List[UnhnLocation] = []

for loc in _khp["locations"]:
assert isinstance(loc, dict)
k.locations.append(
khp_locations.append(
UnhnLocation(
volume=loc["volume"],
page=loc["page"],
character=loc["character"],
virtual=loc["virtual"],
)
)
for reading in d["readings"]:
k.readings.append(UnhnReading(reading=reading))
c.kHanyuPinyin.append(k)
for reading in _khp["readings"]:
khp_readings.append(UnhnReading(reading=reading))
c.kHanyuPinyin.append(
kHanyuPinyin(
locations=khp_readings,
readings=khp_readings,
)
)

if "kHanYu" in char:
k = kHanYu()
for d in char["kHanYu"]:
k.locations.append(
khy_locations: t.List[UnhnLocation] = []
for _khy in char["kHanYu"]:
assert isinstance(_khy, dict)
khy_locations.append(
UnhnLocation(
volume=d["volume"],
page=d["page"],
character=d["character"],
virtual=d["virtual"],
volume=_khy["volume"],
page=_khy["page"],
character=_khy["character"],
virtual=_khy["virtual"],
)
)
c.kHanYu.append(k)
c.kHanYu.append(kHanYu(locations=khy_locations))

if "kIRGHanyuDaZidian" in char:
_khdz_locations: t.List[UnhnLocation] = []
Expand Down

0 comments on commit 5713a18

Please sign in to comment.