Update update_amiibo_tools_lua.py

Updated with quality of life improvements to make things more clear in the output. 

Signed-off-by: Cory Solovewicz <cory@solovewicz.com>
This commit is contained in:
Cory Solovewicz 2025-08-30 21:59:16 -07:00 committed by GitHub
parent f50a7df5bb
commit 4455d28e6a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,7 +7,7 @@ Name: update_amiibo_tools_lua.py
Author: Cory Solovewicz Author: Cory Solovewicz
Description: Description:
This is a python script to automate what the updating of the amiibo_tools.lua This is a python script to automate what the updating of the /lualibs/amiibo_tools.lua
file which holds a lua table of all known amiibos. Previously updating the file which holds a lua table of all known amiibos. Previously updating the
amiibo_tools.lua was a very manual process. amiibo_tools.lua was a very manual process.
@ -19,7 +19,7 @@ which can then be placed in the /lualibs/ directory.
The temporary amiibo.json file is then deleted The temporary amiibo.json file is then deleted
Dependencies: Dependencies:
python3 -m pip install jq python -m pip install jq
How to run: How to run:
python update_amiibo_tools_lua.py python update_amiibo_tools_lua.py
@ -79,7 +79,7 @@ def process_file(filename):
data = re.sub('" =', '"] =', data) data = re.sub('" =', '"] =', data)
# Prepend the text # Prepend the text
prepend_text = 'local amiibo_tools = {}\n\n-- curl https://raw.githubusercontent.com/N3evin/AmiiboAPI/master/database/amiibo.json | jq \'del(.amiibos[].release)\' | jq \'del(.characters)\' | pbcopy --> transform to table\namiibo_tools.db =\n' prepend_text = '-- This file is auto-generated by /client/update_amiibo_tools_lua.py\n\nlocal amiibo_tools = {}\n\namiibo_tools.db =\n'
data = prepend_text + data data = prepend_text + data
# Append the text # Append the text
@ -93,6 +93,7 @@ def write_to_file(data, filename):
with open(filename, 'w', encoding='utf-8') as file: with open(filename, 'w', encoding='utf-8') as file:
file.write(data) file.write(data)
print(f"Output written to {filename}") print(f"Output written to {filename}")
print(f"Please backup the original /client/lualibs/amiibo_tools.lua and move the updated {filename} to the /client/lualibs/ directory.")
def delete_file(filename): def delete_file(filename):
try: try: