mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2024-12-21 15:21:52 +01:00
Update NSLGameScanner.py
This commit is contained in:
parent
9867dd5a22
commit
ca5255f6fb
@ -202,24 +202,21 @@ if os.path.exists(shortcuts_file):
|
|||||||
try:
|
try:
|
||||||
with open(shortcuts_file, 'rb') as file:
|
with open(shortcuts_file, 'rb') as file:
|
||||||
shortcuts = vdf.binary_loads(file.read())
|
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:
|
except Exception as e:
|
||||||
print(f"Error reading shortcuts file: {e}")
|
print(f"Error reading shortcuts file: {e}")
|
||||||
print("Please check the file and try again.")
|
print("Please check the file and try again.")
|
||||||
sys.exit() # Exit the script if an error occurs
|
sys.exit() # Exit the script if an error occurs
|
||||||
|
|
||||||
|
# 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': {}}
|
||||||
|
|
||||||
# Check data integrity before writing to file
|
# Check data integrity before writing to file
|
||||||
if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
|
if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
|
||||||
with open(shortcuts_file, 'wb') as file:
|
with open(shortcuts_file, 'wb') as file:
|
||||||
vdf.binary_dumps(shortcuts, file)
|
vdf.binary_dumps(shortcuts, file)
|
||||||
else:
|
else:
|
||||||
print("The data to be written to the shortcuts file is not valid.")
|
print("The data to be written to the shortcuts file is not valid.")
|
||||||
else:
|
|
||||||
# If the file does not exist, 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
|
# Open the config.vdf file
|
||||||
|
Loading…
Reference in New Issue
Block a user