From 773e1d14a0d05b3c3d8b19b0f395c1099e861b53 Mon Sep 17 00:00:00 2001 From: loathingKernel <142770+loathingKernel@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:42:12 +0300 Subject: [PATCH] Revert "Rare: use OS specific encoding in some cases" This reverts commit bf65d61c39fa39083fdf2f4865048f97430ef6bb. --- rare/models/game.py | 4 ++-- rare/shared/image_manager.py | 2 +- rare/shared/rare_core.py | 2 +- rare/shared/wrappers.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rare/models/game.py b/rare/models/game.py index 6c4e28ba7..a2c35d9f4 100644 --- a/rare/models/game.py +++ b/rare/models/game.py @@ -152,7 +152,7 @@ def __load_metadata_json() -> Dict: metadata = {} file = os.path.join(data_dir(), "game_meta.json") try: - with open(file, "r") as f: + with open(file, "r", encoding="utf-8") as f: metadata = json.load(f) except FileNotFoundError: logger.info("%s does not exist", file) @@ -175,7 +175,7 @@ def __save_metadata(self): metadata: Dict = self.__load_metadata_json() # pylint: disable=unsupported-assignment-operation metadata[self.app_name] = vars(self.metadata) - with open(os.path.join(data_dir(), "game_meta.json"), "w+") as file: + with open(os.path.join(data_dir(), "game_meta.json"), "w+", encoding="utf-8") as file: json.dump(metadata, file, indent=2) def update_game(self): diff --git a/rare/shared/image_manager.py b/rare/shared/image_manager.py index 40db6b212..8ab0e8468 100644 --- a/rare/shared/image_manager.py +++ b/rare/shared/image_manager.py @@ -237,7 +237,7 @@ def __download(self, updates: List, json_data: Dict, game: Game, use_async: bool json_data["size"] = {"w": ImageSize.Tall.size.width(), "h": ImageSize.Tall.size.height()} # write image.json - with open(self.__img_json(game.app_name), "w") as file: + with open(self.__img_json(game.app_name), "w", encoding="utf-8") as file: json.dump(json_data, file) return bool(updates) diff --git a/rare/shared/rare_core.py b/rare/shared/rare_core.py index 87a430e7c..a9b3a710d 100644 --- a/rare/shared/rare_core.py +++ b/rare/shared/rare_core.py @@ -156,7 +156,7 @@ def core(self, init: bool = False) -> LegendaryCore: else: path = os.path.expanduser('~/.config/legendary') logger.info("Creating config in path: %s", config_path) - with open(os.path.join(path, "config.ini"), "w") as config_file: + with open(os.path.join(path, "config.ini"), "w", encoding="utf-8") as config_file: config_file.write("[Legendary]") self.__core = LegendaryCore() diff --git a/rare/shared/wrappers.py b/rare/shared/wrappers.py index d99b40d2b..d6eaca9ee 100644 --- a/rare/shared/wrappers.py +++ b/rare/shared/wrappers.py @@ -19,7 +19,7 @@ def __init__(self): self.__file = os.path.join(config_dir(), "wrappers.json") self.__wrappers_dict = {} try: - with open(self.__file) as f: + with open(self.__file, "r", encoding="utf-8") as f: self.__wrappers_dict = json.load(f) except FileNotFoundError: logger.info("%s does not exist", self.__file) @@ -114,7 +114,7 @@ def __save_wrappers(self): self.__wrappers_dict["wrappers"] = self.__wrappers self.__wrappers_dict["applists"] = self.__applists - with open(os.path.join(self.__file), "w+") as f: + with open(os.path.join(self.__file), "w+", encoding="utf-8") as f: json.dump(self.__wrappers_dict, f, default=lambda o: vars(o), indent=2)