ItemStudy/main.py

38 lines
787 B
Python
Raw Normal View History

2024-05-13 20:50:01 +00:00
from ItemRelate import main as relate
import json
import os
2024-05-13 20:50:01 +00:00
def batch():
scales = os.listdir("Scales")
items={}
for i in scales:
with open("Scales/"+i,"r") as scale:
tmp = json.load(scale)
for i in tmp["item"]:
items[i]=tmp["item"][i]
# print(items)
return items
def old_type(str):
with open(str,"r") as file:
scale=json.load(file)
new={"item":{}}
for i in scale:
new["item"][i["name"]]=i["label"]
# print(i["name"],i["label"])
with open(str,"w") as file:
file.write(json.dumps(new))
# old_type("Scales/ceE.json")
if os.path.getsize("Temp/items.json") == 0:
que=relate(batch())
with open("Temp/items.json","w") as items:
items.write(json.dumps(que))
else:
with open("Temp/items.json","r") as items:
que = json.load(items)
2024-05-13 20:50:01 +00:00
for i in que:
print(i)