-
Notifications
You must be signed in to change notification settings - Fork 54
/
normalizer.py
44 lines (42 loc) · 1.06 KB
/
normalizer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Sort the JSON file files/mods.json's keys in a custom order
import ujson
all_mods = ujson.load(open("files/mods.json"))
# orig_mods = ujson.load(open("files/origmods.json"))
# for [mod, orig] in zip(all_mods, orig_mods):
for mod in all_mods:
new_mod = {}
for key in [
"id",
"nicknames",
"display",
"enabled",
"creator",
"discordcode",
"command",
"description",
"icon",
"icon_scaling",
"actions",
"categories",
"update_to_ids",
"warning",
"hidden",
"file",
"files",
"url",
"forge_id",
"packages",
"hash",
]:
if key in mod:
new_mod[key] = mod[key]
# elif key in orig:
# new_mod[key] = orig[key]
if "actions" in new_mod:
for action in new_mod["actions"]:
if "creator" in action:
del action["creator"]
mod.clear()
mod.update(new_mod)
# Write the new json file
ujson.dump(all_mods, open("files/mods.json", "w"), indent=4)