Skip to content

Commit a70005e

Browse files
committed
V5 icons migration tool
1 parent cfb1a50 commit a70005e

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

other/v5-icons.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import sys
2+
import os
3+
import json
4+
5+
if len(sys.argv) != 2:
6+
print(f"Correct usage: {sys.argv[0]} <resourceDirPath>")
7+
exit(1)
8+
9+
resourceDir = sys.argv[1]
10+
11+
if not os.path.exists(resourceDir) or not os.path.isdir(resourceDir):
12+
print(f"'{resourceDir}' is not a directory")
13+
exit(1)
14+
15+
def processDir(dirName, processJson):
16+
finalJson = {}
17+
dirPath = os.path.join(resourceDir, dirName)
18+
for filename in os.listdir(dirPath):
19+
if filename.endswith(".json"):
20+
# print(dirName + " > " + filename)
21+
filePath = os.path.join(dirPath, filename)
22+
with open(filePath, encoding="utf-8") as fh:
23+
ret = processJson(json.load(fh), filename[:-5], finalJson)
24+
if ret != None:
25+
finalJson[filename[:-5]] = ret
26+
return finalJson
27+
28+
eventsEmotes = json.load(open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'v4-to-v5-events-emojis.json')))
29+
30+
def processEvents(data, filename, finalJson):
31+
ret = {}
32+
for possibilityEmote in data["possibilities"]:
33+
if possibilityEmote == "end":
34+
ret["end"] = {}
35+
for i in range(len(data["possibilities"]["end"]["outcomes"])):
36+
ret["end"][str(i)] = data["possibilities"]["end"]["outcomes"][i]["translations"]["fr"].split(' ', 1)[0]
37+
else:
38+
ret[eventsEmotes[filename][possibilityEmote]] = possibilityEmote
39+
return ret
40+
41+
jsonObj = {}
42+
jsonObj["events"] = processDir("events", processEvents)
43+
44+
print(json.dumps(jsonObj, ensure_ascii=False, indent=4, sort_keys=True))
45+

0 commit comments

Comments
 (0)