Cleanup: Remove backwards-compatible code

Since we aren't interested in backwards compatibility this early in development, let's remove those code chunks to keep the code shorter.
This commit is contained in:
Bananaman
2023-03-24 22:26:24 +01:00
parent 703c65395c
commit 214687c9ce
5 changed files with 13 additions and 81 deletions

View File

@@ -19,9 +19,6 @@
import json
import os
import shlex
from .game_data_to_json import game_data_to_json
def get_games(game_ids=None):
@@ -42,28 +39,8 @@ def get_games(game_ids=None):
game_files = os.listdir(games_dir)
for game in game_files:
with open(os.path.join(games_dir, game), "r+") as open_file:
with open(os.path.join(games_dir, game), "r") as open_file:
data = json.loads(open_file.read())
# Convert any outdated JSON values to our newest data format.
needs_rewrite = False
if "executable" in data and isinstance(data["executable"], str):
needs_rewrite = True
try:
# Use shell parsing to determine what the individual components are.
executable_split = shlex.split(
data["executable"], comments=False, posix=True
)
except:
# Fallback: Split once at earliest space (1 part if no spaces, else 2 parts).
executable_split = data["executable"].split(" ", 1)
data["executable"] = executable_split
if needs_rewrite:
open_file.seek(0)
open_file.truncate()
open_file.write(game_data_to_json(data))
open_file.close()
games[data["game_id"]] = data