reworked vdf code

This commit is contained in:
Roy 2024-06-20 16:19:49 -07:00 committed by GitHub
parent e1531369e7
commit 7b5c539982
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -183,11 +183,7 @@ hero64 = ""
shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf" shortcuts_file = f"{logged_in_home}/.steam/root/userdata/{steamid3}/config/shortcuts.vdf"
# Check if the shortcuts file exists # Check if the shortcuts file exists
if not os.path.exists(shortcuts_file): if os.path.exists(shortcuts_file):
# 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)
else:
# If the file exists, try to load it # If the file exists, try to load it
try: try:
with open(shortcuts_file, 'rb') as file: with open(shortcuts_file, 'rb') as file:
@ -206,6 +202,10 @@ if shortcuts and isinstance(shortcuts, dict) and 'shortcuts' in shortcuts:
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