mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2025-12-18 05:55:57 +00:00
v0.8.2 (#480)
* Price checking does not work when using a gamepad(Ctrl+D) #452 Uses parts from #454 to fix the issue. Co-authored-by: lawrsp <7957003+lawrsp@users.noreply.github.com> * Fix tests :( * Fix magic rarity item name parse in "cmn-Hant" language (#460) * Fix magic rarity item name parse in "cmn-Hant" language * Add by translated when ref is null --------- Co-authored-by: kvan7 <kvan.valve@gmail.com> * chore: yarn to npm and add missing step (#461) * fix: update game config path for linux to poe2 * fix tests * fix: MacOS crash on startup (#428) * fix: MacOS crash on startup * update for windows/linux * move main app startup into function Mac calls that in async, other platforms proceed in sync. * [PoE2] - Relics broken again #444 * test prettier and add npm script * add format/lint support to main * Fix defineProps macro * Run speed v0.8.0 - Russian. #447 * fix negative gold * Merge branch 'Kvan7:master' into master * fix: app-ready fixing before we're ready * Merge branch 'dev' into pr/larssn/428 * should work? * Merge commit 'ab1c8bfa3a31b06da9cf18db0273f6a92e407bc5' into pr/larssn/428 * fix being lazy on the merge * fix: add executable bit to compilation script (#465) * Item Images (#472) * image data stuff * ignore lookup file * update testing * sort items * change sort ot be by refname * more code * working pulling * Fixes #456 Create script to request item's images from trade site #456 * Fixes #457 Update ImageFix to use new saved images before poe1 ones #457 * add images to items * Add Spear as item category * Add Flail as category * Add "goodness" from upstream * Fix #474 Tier # missing from some defense stats #474 * minor oops * remove error for waystones * Add a bunch of images to the docs * Extra widgets docs * Update chat commands links docs * add stash search docs * Item info docs page * more docs * Update bug-report.yml * Version bump * extra version bump --------- Co-authored-by: lawrsp <7957003+lawrsp@users.noreply.github.com> Co-authored-by: Seth Falco <seth@falco.fun> Co-authored-by: Amir Zarrinkafsh <nightah@me.com> Co-authored-by: Lars <890725+larssn@users.noreply.github.com>
This commit is contained in:
@@ -15,6 +15,12 @@ def read_ndjson(file_path, encoding="utf-8"):
|
||||
return [json.loads(line) for line in file]
|
||||
|
||||
|
||||
def read_cache(file_path):
|
||||
"""Reads a cache file and returns a dictionary of parsed JSON objects."""
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
return json.loads(file.read())
|
||||
|
||||
|
||||
def write_ndjson(file_path, data):
|
||||
"""Writes a list of JSON objects to a newline-delimited JSON file."""
|
||||
with open(file_path, "w", encoding="utf-8") as file:
|
||||
@@ -22,14 +28,23 @@ def write_ndjson(file_path, data):
|
||||
file.write(json.dumps(item, ensure_ascii=False) + "\n")
|
||||
|
||||
|
||||
def update_icons(new_items, old_items):
|
||||
def get_save_name(item: dict[str, str]) -> str:
|
||||
return item["namespace"] + "=" + item["name"]
|
||||
|
||||
|
||||
def update_icons(new_items, old_items, api_cache={}):
|
||||
"""Update icons in new_items if they are missing and present in old_items."""
|
||||
old_icons = {item["refName"]: item["icon"] for item in old_items if "icon" in item}
|
||||
old_icons = {
|
||||
get_save_name(item): item["icon"] for item in old_items if "icon" in item
|
||||
}
|
||||
|
||||
for new_item in new_items:
|
||||
ref_name = new_item["refName"]
|
||||
if new_item.get("icon") == "%NOT_FOUND%" and ref_name in old_icons:
|
||||
new_item["icon"] = old_icons[ref_name]
|
||||
lookup_name = get_save_name(new_item)
|
||||
if new_item.get("icon") == "%NOT_FOUND%":
|
||||
if lookup_name in api_cache and api_cache[lookup_name] != "%NOT_FOUND%":
|
||||
new_item["icon"] = api_cache[lookup_name]
|
||||
elif lookup_name in old_icons:
|
||||
new_item["icon"] = old_icons[lookup_name]
|
||||
|
||||
return new_items
|
||||
|
||||
@@ -45,8 +60,13 @@ if __name__ == "__main__":
|
||||
old_items = read_ndjson(os.path.join(script_dir, "items.ndjson.old"))
|
||||
new_items = read_ndjson(os.path.join(script_dir, "items.ndjson"))
|
||||
|
||||
# Load the cache from the cache file in the script's directory
|
||||
cache_items = read_cache(
|
||||
os.path.join(get_script_dir(lang=""), "itemImageCache.json")
|
||||
)
|
||||
|
||||
# Update new_items with icons from old_items where applicable
|
||||
updated_new_items = update_icons(new_items, old_items)
|
||||
updated_new_items = update_icons(new_items, old_items, api_cache=cache_items)
|
||||
|
||||
# Write the updated new items back to the new file or a new file as needed
|
||||
write_ndjson(os.path.join(script_dir, "items.ndjson"), updated_new_items)
|
||||
|
||||
Reference in New Issue
Block a user