From 973ec01b385de15d5676d23a5c378ad12f70383d Mon Sep 17 00:00:00 2001 From: Bananaman <38923130+Bananaman@users.noreply.github.com> Date: Fri, 24 Mar 2023 22:37:01 +0100 Subject: [PATCH] Cleanup: Remove pointless calls to close() Since "with open()" automatically closes the files anyway. --- src/utils/bottles_parser.py | 1 - src/utils/create_details_window.py | 1 - src/utils/get_games.py | 2 -- src/utils/heroic_parser.py | 4 ---- src/utils/save_games.py | 1 - src/utils/steam_parser.py | 1 - src/utils/toggle_hidden.py | 1 - 7 files changed, 11 deletions(-) diff --git a/src/utils/bottles_parser.py b/src/utils/bottles_parser.py index 18778a1..a2426ab 100644 --- a/src/utils/bottles_parser.py +++ b/src/utils/bottles_parser.py @@ -95,7 +95,6 @@ def bottles_parser(parent_widget, action): with open(os.path.join(bottles_dir, "library.yml"), "r") as open_file: data = open_file.read() - open_file.close() library = yaml.load(data, Loader=yaml.Loader) diff --git a/src/utils/create_details_window.py b/src/utils/create_details_window.py index 40fc371..96b71df 100644 --- a/src/utils/create_details_window.py +++ b/src/utils/create_details_window.py @@ -283,7 +283,6 @@ def create_details_window(parent_widget, game_id=None): if os.path.exists(path): with open(path, "r") as open_file: data = json.loads(open_file.read()) - open_file.close() data.update(values) save_games({game_id: data}) else: diff --git a/src/utils/get_games.py b/src/utils/get_games.py index 9125107..dd40ed8 100644 --- a/src/utils/get_games.py +++ b/src/utils/get_games.py @@ -41,8 +41,6 @@ def get_games(game_ids=None): for game in game_files: with open(os.path.join(games_dir, game), "r") as open_file: data = json.loads(open_file.read()) - open_file.close() - games[data["game_id"]] = data return games diff --git a/src/utils/heroic_parser.py b/src/utils/heroic_parser.py index a579391..8597f7f 100644 --- a/src/utils/heroic_parser.py +++ b/src/utils/heroic_parser.py @@ -107,7 +107,6 @@ def heroic_parser(parent_widget, action): os.path.join(heroic_dir, "lib-cache", "library.json"), "r" ) as open_file: data = open_file.read() - open_file.close() library = json.loads(data) try: @@ -160,7 +159,6 @@ def heroic_parser(parent_widget, action): os.path.join(heroic_dir, "gog_store", "installed.json"), "r" ) as open_file: data = open_file.read() - open_file.close() installed = json.loads(data) for item in installed["installed"]: values = {} @@ -179,7 +177,6 @@ def heroic_parser(parent_widget, action): os.path.join(heroic_dir, "gog_store", "library.json"), "r" ) as open_file: data = open_file.read() - open_file.close() library = json.loads(data) for game in library["games"]: if game["app_name"] == app_name: @@ -214,7 +211,6 @@ def heroic_parser(parent_widget, action): os.path.join(heroic_dir, "sideload_apps", "library.json"), "r" ) as open_file: data = open_file.read() - open_file.close() library = json.loads(data) for item in library["games"]: values = {} diff --git a/src/utils/save_games.py b/src/utils/save_games.py index 858f08c..854c140 100644 --- a/src/utils/save_games.py +++ b/src/utils/save_games.py @@ -35,4 +35,3 @@ def save_games(games): for game in games: with open(os.path.join(games_dir, f"{game}.json"), "w") as open_file: open_file.write(json.dumps(games[game], indent=4, sort_keys=True)) - open_file.close() diff --git a/src/utils/steam_parser.py b/src/utils/steam_parser.py index f99a8e3..0f65860 100644 --- a/src/utils/steam_parser.py +++ b/src/utils/steam_parser.py @@ -49,7 +49,6 @@ def get_game(task, datatypes, current_time, parent_widget, appmanifest, steam_di with open(appmanifest, "r") as open_file: data = open_file.read() - open_file.close() for datatype in datatypes: value = re.findall(f'"{datatype}"\t\t"(.*)"\n', data) values[datatype] = value[0] diff --git a/src/utils/toggle_hidden.py b/src/utils/toggle_hidden.py index 10aa284..21dc9b1 100644 --- a/src/utils/toggle_hidden.py +++ b/src/utils/toggle_hidden.py @@ -36,7 +36,6 @@ def toggle_hidden(game): with open(os.path.join(games_dir, f"{game}.json"), "r") as open_file: data = json.loads(open_file.read()) - open_file.close() data["hidden"] = not data["hidden"]