From b89d1c95ec886b07bc8967a94d77e0abfff9bd0d Mon Sep 17 00:00:00 2001 From: Mc-muffin <8714476+Mc-muffin@users.noreply.github.com> Date: Sun, 7 Jan 2024 03:44:15 -0500 Subject: [PATCH] Honor null EnglisText node semantics plus other small None check fix --- pythonlib/games/ToolsTOR.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pythonlib/games/ToolsTOR.py b/pythonlib/games/ToolsTOR.py index 2deca85..c227579 100644 --- a/pythonlib/games/ToolsTOR.py +++ b/pythonlib/games/ToolsTOR.py @@ -431,15 +431,17 @@ class ToolsTOR(ToolsTales): japanese_text = entry_node.find("JapaneseText").text english_text = entry_node.find("EnglishText").text - #Use the values only for Status = Done and use English if non empty - final_text = '' - if (status in self.list_status_insertion): - final_text = english_text or '' - else: - final_text = japanese_text or '' + # ElementTree saves self-closing nodes for empty strings ('') + # as such, japanese lines that are None are in fact just ''. + # For english lines however None means "use Japanese line" + # so honor that detail here + + final_text = japanese_text or '' + if (status in self.list_status_insertion and english_text is not None): + final_text = english_text voiceId_node = entry_node.find("VoiceId") - if (voiceId_node != None): + if (voiceId_node is not None): final_text = ''.format(voiceId_node.text) + final_text #Convert the text values to bytes using TBL, TAGS, COLORS, ...