Files
Exiled-Exchange-2/dataParser/vendor/pseudo-stats/pseudo-parse.py
T
5e118f92ea v0.1.5 (#195)
* [Traditional Chinese] Translated and fixed common translation issues (#167)

#163

* Gem Sockets + Anoints (#170)

* adding anoints

* add gem sockets

---------

Co-authored-by: zoedel <6480974+zoedel@users.noreply.github.com>

* Update Japanese (#181)

* add chat parser (#183)

* Adds allocates to parser and pushes data files

* Feature/add Japanese support (#191)

* add ja app_i18n.json

* fix translate

* 表現を統一

* add ja client_strings.js

* add japanese support

* Update poe-dat dep

* Uniques seem to work? (#193)

* Fixes use pseudo incorrect includes

* additional tag for chat parsed items

* Features/sockets (#194)

* init for sockets

* add basic for empty sockets into parser

* Update some socket stuff

* Add some rune data

* add soul cors

* Rune socket ui start

* Working for empty cant disable though

* Empty sockets fully working

* divider

* Add basic dropdown placeholders

* disable select

* Focus search working incorrectly #188

* update README

* Update issue templates

* version bump :)

---------

Co-authored-by: Dr3aming <63219151+Dr3am1ng@users.noreply.github.com>
Co-authored-by: zoedel <zoedel@users.noreply.github.com>
Co-authored-by: zoedel <6480974+zoedel@users.noreply.github.com>
Co-authored-by: Kazuma Igarashi <bonz2go2@gmail.com>
Co-authored-by: Oscar <oscarada87@gmail.com>
2024-12-29 19:47:21 -06:00

55 lines
1.6 KiB
Python

import json
import os
def get_script_dir():
"""Returns the directory where the script is located."""
return os.path.dirname(os.path.realpath(__file__))
# List of localization codes
localizations = ["en", "ru", "ko", "cmn-Hant", "ja"]
key_to_find = "trade.ids.pseudo" # The specific key path to check for
def has_nested_key(obj, key_path):
keys = key_path.split(".")
for key in keys:
if isinstance(obj, dict) and key in obj:
obj = obj[key]
else:
return False
return True
def process_file(input_file_path, output_file_path):
result_list = []
# Use 'utf-8' encoding when opening the input file
with open(input_file_path, "r", encoding="utf-8") as input_file:
for line in input_file:
try:
json_object = json.loads(line)
if has_nested_key(json_object, key_to_find):
result_list.append(json_object)
except json.JSONDecodeError as e:
print(f"Error parsing JSON: {e}")
with open(output_file_path, "w", encoding="utf-8") as output_file:
for item in result_list:
output_file.write(json.dumps(item, ensure_ascii=False) + "\n")
print(
f"Processing complete for {input_file_path}. Check {output_file_path} for results."
)
if __name__ == "__main__":
for loc in localizations:
input_file_path = f"{get_script_dir()}/../../data/{loc}/stats.ndjson.old" # Path to the input file
output_file_path = (
f"{get_script_dir()}/{loc}/all-pseudo.ndjson" # Path to the output file
)
process_file(input_file_path, output_file_path)