From 79947e5e1228cb79ea8a8ba9f99706bf69ca040e Mon Sep 17 00:00:00 2001 From: Roy <88516395+moraroy@users.noreply.github.com> Date: Tue, 11 Jun 2024 03:34:18 -0700 Subject: [PATCH] added check for shortcuts --- NSLGameScanner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NSLGameScanner.py b/NSLGameScanner.py index 9b14ea0..eb393a3 100644 --- a/NSLGameScanner.py +++ b/NSLGameScanner.py @@ -192,12 +192,16 @@ else: try: with open(shortcuts_file, 'rb') as file: shortcuts = vdf.binary_loads(file.read()) + # If the file is empty or does not contain the 'shortcuts' key, initialize an empty 'shortcuts' dictionary + if not shortcuts or 'shortcuts' not in shortcuts: + shortcuts = {'shortcuts': {}} except Exception as e: print(f"Error reading shortcuts file: {e}") # If an error occurs when reading the file, create a new file with an empty "shortcuts" section with open(shortcuts_file, 'wb') as file: vdf.binary_dumps({'shortcuts': {}}, file) + # Open the config.vdf file with open(f"{logged_in_home}/.steam/root/config/config.vdf", 'r') as file: config_data = vdf.load(file)