✨ Data convertion
This commit is contained in:
parent
0579a6b0ba
commit
8b847e0f9c
3 changed files with 380 additions and 0 deletions
38
data/convert/31-0/melee.py
Executable file
38
data/convert/31-0/melee.py
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env python3
|
||||
# # -*- coding: utf-8 -*-
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
with open("../../extraction/raw-31-0/data.cdb.json") as f:
|
||||
raw = json.load(f)
|
||||
with open("../../clean/31-0/main.zh.mo.json") as f:
|
||||
trans = json.load(f)
|
||||
|
||||
lines = raw["sheets"][1]["lines"]
|
||||
melee = []
|
||||
|
||||
for i in lines:
|
||||
if i["group"] == 4:
|
||||
melee.append(i)
|
||||
i["name"] = trans[i["name"]]["msgstr"][0]
|
||||
if "ambiantDesc" in i:
|
||||
i["ambiantDesc"] = trans[i["ambiantDesc"].strip()]["msgstr"][0]
|
||||
if "gameplayDesc" in i:
|
||||
i["gameplayDesc"] = trans[i["gameplayDesc"].strip()]["msgstr"][0]
|
||||
if i["props"]:
|
||||
|
||||
def replace_props(m):
|
||||
result = i["props"][m.group(1)]
|
||||
if isinstance(result, list):
|
||||
result = result[0]
|
||||
if not isinstance(result, str):
|
||||
result = str(result)
|
||||
return result
|
||||
|
||||
i["gameplayDesc"], _ = re.subn(
|
||||
r"::\+?(.*?)::", replace_props, i["gameplayDesc"]
|
||||
)
|
||||
|
||||
|
||||
print(json.dumps(melee, ensure_ascii=False))
|
Loading…
Add table
Add a link
Reference in a new issue