1 Star 0 Fork 0

randomdot / AptTransTool

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tradeStats.py 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
randomdot 提交于 2022-10-24 20:51 . bug fix and clean code
import json
# from msilib.schema import File
from utils import *
# stats.json from poe.game.qq.com/api/trade/data/stats
# File struct example:
# {"result":[{"label":"综合","entries":[{"id":"pseudo.pseudo_total_cold_resistance","text":"+#%最大冰霜抗性","type":"pseudo"},...]},...]}
def createTradeStatsCacheFile(langTag:str):
lang = LANGUAGE_DICT[langTag]
with open(localesFilePath + lang + '/stats.json', 'r', encoding='utf8') as load_f:
statsDict:dict = json.load(load_f)
statsList:list = {entries['id']:entries['text'] for categ in statsDict["result"] for entries in categ['entries']}
jsonString = json.dumps(statsList, ensure_ascii=False, separators=(',\n', ': '))
with open(localesFilePath + lang + '/tradeStatsCache.json', 'w', encoding='utf8') as save_f:
save_f.write(jsonString)
print("Trade stats cache file saved:", localesFilePath+lang+'/tradeStatsCache.json')
def loadTradeStats(langTag:str) -> dict:
with open(localesFilePath + LANGUAGE_DICT[langTag] + '/tradeStatsCache.json', 'r', encoding='utf8') as load_f:
return json.load(load_f)
if __name__ == '__main__':
createTradeStatsCacheFile('lang "Simplified Chinese"')
Python
1
https://gitee.com/randomdot/apt-trans-tool.git
git@gitee.com:randomdot/apt-trans-tool.git
randomdot
apt-trans-tool
AptTransTool
main

搜索帮助