forked from helloworld-1839/vertex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextra-toc.py
41 lines (32 loc) · 1.05 KB
/
extra-toc.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
import os
import json
def main():
result = []
all_ids = set()
base_dir = "public/data"
for filename in sorted(os.listdir(base_dir)):
if filename.endswith(".json"):
with open(os.path.join(base_dir, filename)) as f:
puzzle = json.loads(f.read())
puzzle["numShapes"] = len(puzzle["shapes"])
for x in [
"body",
"vertices",
"palette",
"shapes",
"displayDate",
"slug",
"purgatoryPuzzle",
]:
if x in puzzle:
del puzzle[x]
for x in ["puzzleConstructor", "date", "id"]:
if x not in puzzle:
assert False, f"Missing {x} in {puzzle}"
if puzzle["id"] in all_ids:
assert False, f"Duplicate id {puzzle['id']}"
result.append(puzzle)
with open("src/puzzle-toc.json", "w") as f:
f.write(json.dumps(result))
if __name__ == "__main__":
main()