Cleanup: Remove pointless calls to close()

Since "with open()" automatically closes the files anyway.
This commit is contained in:
Bananaman
2023-03-24 22:37:01 +01:00
parent 214687c9ce
commit 973ec01b38
7 changed files with 0 additions and 11 deletions

View File

@@ -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)

View File

@@ -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:

View File

@@ -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

View File

@@ -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 = {}

View File

@@ -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()

View File

@@ -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]

View File

@@ -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"]