testing of writin json to file

This commit is contained in:
Roy 2024-02-18 00:10:09 -08:00 committed by GitHub
parent ff56c3a04d
commit cdff413f4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1018,6 +1018,8 @@ if new_shortcuts_added or shortcuts_updated:
# Assuming 'games' is a list of game dictionaries
games = [shortcut for shortcut in shortcuts['shortcuts'].values()]
# Open the output file in write mode ('w')
with open('output.json', 'w') as outfile:
for game in games:
# Skip if 'appname' or 'exe' is None
if game.get('appname') is None or game.get('exe') is None:
@ -1034,11 +1036,13 @@ if new_shortcuts_added or shortcuts_updated:
'GameID': game.get('GameID', "default_game_id") # Use a default value if game_id is not defined
}
# Print the shortcut information in JSON format
# Convert the shortcut information to JSON format
message = json.dumps(shortcut_info)
print(message, flush=True) # Print to stdout
print("All finished!")
# Write the JSON output to the file
outfile.write(message + '\n') # Add a newline character after each game
print("All finished!")