wynnbuilder-forked-for-changes/py_script/items_common.py
hppeng-wynn df9412e994
Api v3 (#267)
* Tweak ordering to be consistent internally

* v3 items  (#266)

* item_wrapper script

for updating item data with v3 endpoint

* metadata from v3

* v3 item format

For the purpose of wynnbuilder, additional mapping might be needed.

* v3 item format

additional mapping might be needed for wb

* v3 compressed item json

* clean item json v3 format

* Update translate map to api v3

partially... we will need to redo scripts to flatmap all the items

* Fix items for 2.0.4.3

finally

* New ingredients (and parse script update)

just realized I forgot to commit the parse script this whole time

* Forgot to commit data files, and bump ing db version

* Sketchily reverse translate major ids

internalname and separate lookup table lol

* Forgot to update data files

todo: script should update all files at once

* Bump wynn version number

already outdated...

* Forgot to update 2.0.4.3 major ids

---------

Co-authored-by: hppeng <hppeng>
Co-authored-by: RawFish69 <108964215+RawFish69@users.noreply.github.com>
2023-12-29 18:33:04 -08:00

44 lines
1.4 KiB
Python

import json
with open("translate_mappings.json", 'r') as infile:
translate_mappings = json.load(infile)
delete_keys = [
#"addedLore",
#"skin",
#"armorType",
#"armorColor",
#"material"
]
if __name__ == "__main__":
# SELF TEST: compare dict keys with `item_metadata.json`.
from item_wrapper import Items
local_metadata_file = "item_metadata.json"
def debug(*args, **kwargs):
print(*args, **kwargs)
try:
debug("updating item metadata...")
metadata_check = Items().get_metadata()
with open(local_metadata_file, 'w') as outfile:
json.dump(metadata_check, outfile, indent=2)
except:
debug("Could not update item metadata. using local wynn metadata")
with open(local_metadata_file, 'r') as infile:
metadata_check = json.load(infile)
checklist = set(x for x in translate_mappings.keys())
debug(f"Checking {len(checklist)} identifications")
n = 0
for identification in metadata_check['identifications']:
if identification in checklist:
checklist.remove(identification)
else:
print(f"WARNING: id not accounted for: {identification}")
n += 1
debug(f"{n} unmapped API identifications.")
for identification in checklist:
print(f"WARNING: unused translate map entry {identification}")
debug(f"{len(checklist)} unused translation entries.")