From bf5c959324de7c26b735a896c53b3e03a582d04e Mon Sep 17 00:00:00 2001 From: Kevin Trocolli Date: Fri, 21 Jun 2024 22:19:57 -0400 Subject: [PATCH] chuni: fix reader issue caused by encoding weirdness (#55) --- titles/chuni/read.py | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/titles/chuni/read.py b/titles/chuni/read.py index 5082f7a..db7435c 100644 --- a/titles/chuni/read.py +++ b/titles/chuni/read.py @@ -48,9 +48,8 @@ class ChuniReader(BaseReader): for root, dirs, files in walk(f"{root_dir}loginBonusPreset"): for dir in dirs: if path.exists(f"{root}/{dir}/LoginBonusPreset.xml"): - with open(f"{root}/{dir}/LoginBonusPreset.xml", "rb") as fp: - bytedata = fp.read() - strdata = bytedata.decode("UTF-8") + with open(f"{root}/{dir}/LoginBonusPreset.xml", "r", encoding="utf-8") as fp: + strdata = fp.read() xml_root = ET.fromstring(strdata) for name in xml_root.findall("name"): @@ -121,9 +120,8 @@ class ChuniReader(BaseReader): for root, dirs, files in walk(evt_dir): for dir in dirs: if path.exists(f"{root}/{dir}/Event.xml"): - with open(f"{root}/{dir}/Event.xml", "rb") as fp: - bytedata = fp.read() - strdata = bytedata.decode("UTF-8") + with open(f"{root}/{dir}/Event.xml", "r", encoding="utf-8") as fp: + strdata = fp.read() xml_root = ET.fromstring(strdata) for name in xml_root.findall("name"): @@ -144,9 +142,8 @@ class ChuniReader(BaseReader): for root, dirs, files in walk(music_dir): for dir in dirs: if path.exists(f"{root}/{dir}/Music.xml"): - with open(f"{root}/{dir}/Music.xml", "rb") as fp: - bytedata = fp.read() - strdata = bytedata.decode("UTF-8") + with open(f"{root}/{dir}/Music.xml", "r", encoding='utf-8') as fp: + strdata = fp.read() xml_root = ET.fromstring(strdata) for name in xml_root.findall("name"): @@ -210,9 +207,8 @@ class ChuniReader(BaseReader): for root, dirs, files in walk(charge_dir): for dir in dirs: if path.exists(f"{root}/{dir}/ChargeItem.xml"): - with open(f"{root}/{dir}/ChargeItem.xml", "rb") as fp: - bytedata = fp.read() - strdata = bytedata.decode("UTF-8") + with open(f"{root}/{dir}/ChargeItem.xml", "r", encoding='utf-8') as fp: + strdata = fp.read() xml_root = ET.fromstring(strdata) for name in xml_root.findall("name"): @@ -240,9 +236,8 @@ class ChuniReader(BaseReader): for root, dirs, files in walk(avatar_dir): for dir in dirs: if path.exists(f"{root}/{dir}/AvatarAccessory.xml"): - with open(f"{root}/{dir}/AvatarAccessory.xml", "rb") as fp: - bytedata = fp.read() - strdata = bytedata.decode("UTF-8") + with open(f"{root}/{dir}/AvatarAccessory.xml", "r", encoding='utf-8') as fp: + strdata = fp.read() xml_root = ET.fromstring(strdata) for name in xml_root.findall("name"):