From 5d045a926b8694d94c40cb319be6ecdb4321c984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Fri, 10 Nov 2023 14:04:41 +0800 Subject: [PATCH] :bug: Fix KeyError caused by failure to retrieve `reliquarySubstats` --- python_genshin_artifact/enka/enka_parser.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/python_genshin_artifact/enka/enka_parser.py b/python_genshin_artifact/enka/enka_parser.py index 6ffbfc1..b5d8f49 100644 --- a/python_genshin_artifact/enka/enka_parser.py +++ b/python_genshin_artifact/enka/enka_parser.py @@ -86,12 +86,14 @@ def de_equip_list(equip_list: list[dict]) -> Tuple[WeaponInterface, List[Artifac stat_name = fight_map[_main_prop_id] stat_value = to_float(_main_prop_id, _reliquary_main_stat["statValue"]) _main_stat = (stat_name, stat_value) - for _reliquary_sub_stats in _flat["reliquarySubstats"]: - _append_prop_id = _reliquary_sub_stats["appendPropId"] - stat_name = fight_map[_append_prop_id] - stat_value = to_float(_append_prop_id, _reliquary_sub_stats["statValue"]) - _sub_stats = (stat_name, stat_value) - sub_stats.append(_sub_stats) + reliquary_sub_stats = _flat.get("reliquarySubstats") + if reliquary_sub_stats is not None: + for _reliquary_sub_stats in _flat["reliquarySubstats"]: + _append_prop_id = _reliquary_sub_stats["appendPropId"] + stat_name = fight_map[_append_prop_id] + stat_value = to_float(_append_prop_id, _reliquary_sub_stats["statValue"]) + _sub_stats = (stat_name, stat_value) + sub_stats.append(_sub_stats) slot = equip_type_map[_flat["equipType"]] star = _flat["rankLevel"] artifacts.append(