From 3aec55f7282326119b23ffdcd081b43096a2784c Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Tue, 7 May 2024 19:59:20 +0700 Subject: [PATCH] Create generate-touch-layouts-ids.py --- scripts/generate-touch-layouts-ids.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 scripts/generate-touch-layouts-ids.py diff --git a/scripts/generate-touch-layouts-ids.py b/scripts/generate-touch-layouts-ids.py new file mode 100644 index 0000000..983f0fb --- /dev/null +++ b/scripts/generate-touch-layouts-ids.py @@ -0,0 +1,29 @@ +import os + +FOLDER = 'touch-layouts' +OUTPUT_FILE = os.path.join(FOLDER, 'ids.json') + +gameIds = list() + +# Get files in folder +for file in os.listdir(FOLDER): + if not file.endswith('.json') or file == 'ids.json': + continue + + # Get game ID from file name (as int so we can sort the list later) + gameId = int(file.replace('.json', '')) + gameIds.append(gameId) + +# Sort list of ints +gameIds.sort() +# Convert int to string +gameIds = list(map((lambda x: str(x)), gameIds)) + +# Generate output string +output = '[\n ' + ',\n '.join(gameIds) + '\n]\n' + +# Write to file +with open(OUTPUT_FILE, 'w') as fp: + fp.write(output) + +print(output)