-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpreprocess.py
More file actions
31 lines (25 loc) · 1.07 KB
/
preprocess.py
File metadata and controls
31 lines (25 loc) · 1.07 KB
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
import linpg
import glob
import os
def preprocess(pathIn: str, dataIn: dict[str, list[str]]):
for _path in glob.glob(os.path.join(pathIn, "*")):
assert isinstance(_path, str)
if os.path.isdir(_path):
preprocess(_path, _data)
elif _path.endswith(".json"):
dataIn["jsons"].append("./" + _path.replace("\\", "/"))
# linpg.config.organize(_path)
elif _path.endswith(".png") or _path.endswith(".jpg"):
dataIn["images"].append("./" + _path.replace("\\", "/"))
elif _path.endswith(".mp3") or _path.endswith(".ogg") or _path.endswith(".m4a"):
dataIn["audios"].append("./" + _path.replace("\\", "/"))
_data: dict[str, list[str]] = {"jsons": [], "images": [], "audios":[]}
# document all images and json in images folder
preprocess("images", _data)
# document all images and json in levels folder
preprocess("levels", _data)
# document all images and json in levels folder
preprocess("ui", _data)
# document all sounds
preprocess("audios", _data)
linpg.config.save("./additional.json", _data)