mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-03 06:07:19 +02:00
Update generate-touch-layouts-ids.py
This commit is contained in:
parent
b1e7e71f86
commit
6f81137cd4
@ -1,28 +1,25 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
FOLDER = 'touch-layouts'
|
||||
OUTPUT_FILE = os.path.join(FOLDER, 'ids.json')
|
||||
|
||||
gameIds = list()
|
||||
product_ids = 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)
|
||||
with open(os.path.join(FOLDER, file)) as fp:
|
||||
content = json.load(fp)
|
||||
product_ids.append(content['product_id'])
|
||||
|
||||
# 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'
|
||||
# Sort list
|
||||
product_ids.sort()
|
||||
|
||||
# Write to file
|
||||
output = json.dumps(product_ids, separators=(',', ': '), indent=2) + '\n'
|
||||
with open(OUTPUT_FILE, 'w') as fp:
|
||||
fp.write(output)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user