Skip to content

Commit

Permalink
Rare: use OS specific encoding in some cases
Browse files Browse the repository at this point in the history
partially reverts 3f99773
  • Loading branch information
loathingKernel committed Oct 12, 2024
1 parent 1c49495 commit bf65d61
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rare/models/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def __load_metadata_json() -> Dict:
metadata = {}
file = os.path.join(data_dir(), "game_meta.json")
try:
with open(file, "r", encoding="utf-8") as f:
with open(file, "r") as f:
metadata = json.load(f)
except FileNotFoundError:
logger.info("%s does not exist", file)
Expand All @@ -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+", encoding="utf-8") as file:
with open(os.path.join(data_dir(), "game_meta.json"), "w+") as file:
json.dump(metadata, file, indent=2)

def update_game(self):
Expand Down
2 changes: 1 addition & 1 deletion rare/shared/image_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", encoding="utf-8") as file:
with open(self.__img_json(game.app_name), "w") as file:
json.dump(json_data, file)

return bool(updates)
Expand Down
2 changes: 1 addition & 1 deletion rare/shared/rare_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", encoding="utf-8") as config_file:
with open(os.path.join(path, "config.ini"), "w") as config_file:
config_file.write("[Legendary]")
self.__core = LegendaryCore()

Expand Down
4 changes: 2 additions & 2 deletions rare/shared/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self):
self.__file = os.path.join(config_dir(), "wrappers.json")
self.__wrappers_dict = {}
try:
with open(self.__file, "r", encoding="utf-8") as f:
with open(self.__file) as f:
self.__wrappers_dict = json.load(f)
except FileNotFoundError:
logger.info("%s does not exist", self.__file)
Expand Down Expand Up @@ -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+", encoding="utf-8") as f:
with open(os.path.join(self.__file), "w+") as f:
json.dump(self.__wrappers_dict, f, default=lambda o: vars(o), indent=2)


Expand Down

0 comments on commit bf65d61

Please sign in to comment.