Skip to content

Commit 67cdd4f

Browse files
[Baldur's Gate 3]: Fix UnicodeEncodeError and ValueError (#218)
* [Baldur's Gate 3]: Fix UnicodeEncodeError when writing to mod settings * [Baldur's Gate 3]: Fix ValueError due to assumption that MO2 is installed in home directory
1 parent 3262f22 commit 67cdd4f

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

games/baldursgate3/bg3_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ def retrieve_mod_metadata_in_new_thread(mod: mobase.IModInterface):
250250
if mod.name() in metadata
251251
)
252252
+ self._mod_settings_xml_end
253-
)
253+
),
254+
encoding="utf-8",
254255
)
255256
qInfo(
256257
f"backing up generated file {self.modsettings_path} to {self.modsettings_backup}, "

games/game_baldursgate3.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,7 @@ def _on_finished_run(self, exec_path: str, exit_code: int):
190190
moved: dict[str, str] = {}
191191
for path in self.utils.overwrite_path.rglob("*.log"):
192192
try:
193-
moved[str(path.relative_to(Path.home()))] = str(
194-
(self.utils.log_dir / path.name).relative_to(Path.home())
195-
)
193+
moved[str(path)] = str((self.utils.log_dir / path.name))
196194
path.replace(self.utils.log_dir / path.name)
197195
except PermissionError as e:
198196
qDebug(str(e))
@@ -201,9 +199,7 @@ def _on_finished_run(self, exec_path: str, exit_code: int):
201199
if path.name == "log.txt":
202200
dest = self.utils.log_dir / f"{path.parent.name}-{path.name}"
203201
try:
204-
moved[str(path.relative_to(Path.home()))] = str(
205-
dest.relative_to(Path.home())
206-
)
202+
moved[str(path)] = str(dest)
207203
path.replace(dest)
208204
except PermissionError as e:
209205
qDebug(str(e))
@@ -230,10 +226,8 @@ def _on_finished_run(self, exec_path: str, exit_code: int):
230226
for folder in sorted(list(fdir.walk(top_down=False)))[:-1]:
231227
try:
232228
folder[0].rmdir()
233-
removed.add(folder[0].relative_to(Path.home()))
229+
removed.add(folder[0])
234230
except OSError:
235231
pass
236232
if cat is not None and cat.isDebugEnabled() and len(removed) > 0:
237-
qDebug(
238-
f"cleaned empty dirs from {fdir.relative_to(Path.home())} {removed}"
239-
)
233+
qDebug(f"cleaned empty dirs from {fdir} {removed}")

games/game_divinityoriginalsin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ class DivinityOriginalSinGame(BasicGame):
3232
def init(self, organizer: mobase.IOrganizer):
3333
super().init(organizer)
3434
self._register_feature(
35-
BasicGameSaveGameInfo(
36-
lambda s: s.with_suffix(".png") # Not confirmed
37-
)
35+
BasicGameSaveGameInfo(lambda s: s.with_suffix(".png")) # Not confirmed
3836
)
3937
return True

0 commit comments

Comments
 (0)