diff --git a/scripts/generate-touch-layouts-ids.py b/scripts/generate-touch-layouts-ids.py index 983f0fb..6096118 100644 --- a/scripts/generate-touch-layouts-ids.py +++ b/scripts/generate-touch-layouts-ids.py @@ -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)