-
Notifications
You must be signed in to change notification settings - Fork 10
/
prepare_all.py
78 lines (68 loc) · 1.76 KB
/
prepare_all.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from pathlib import Path
import json
import shutil
import os
project = Path(".").resolve()
common_assets = project / "assets" / "common"
pages = [
"MainScreen",
"RemoteManScreen",
"AboutScreen",
"AppEditScreen",
"AppListScreen",
"FileEditScreen",
"FileManagerScreen",
"HexdumpScreen",
"ImageViewScreen",
"RebootConfirmScreen",
"SettingsHomePage",
"SettingsLangScreen",
"SettingsMiscPage",
"SettingsFontSize",
"SettingsUiScreen",
"StorageInfoScreen",
"TextViewScreen",
"TimerOutScreen",
"TimerSetScreen",
"ToggleDanger",
]
module = {
"app-side": {
"path": "app-side/index"
}
}
targets = {
"band-7": 24,
"dialog": 32,
"nxp": 32,
"mhs": 32,
}
with open("app.json", "r") as f:
app_json = json.load(f)
# Prepare assets
for target_id in targets:
icon_size = targets[target_id]
assets_dir = project / "assets" / target_id
if assets_dir.is_dir():
shutil.rmtree(assets_dir)
assets_dir.mkdir()
# Misc files
shutil.copy(common_assets / "icon.png", assets_dir)
shutil.copy(common_assets / "i_next.png", assets_dir)
shutil.copy(common_assets / "brightness.png", assets_dir)
shutil.copy(common_assets / "battery.png", assets_dir)
shutil.copytree(common_assets / "edit", assets_dir / "edit")
shutil.copytree(common_assets / "files", assets_dir / "files")
shutil.copytree(common_assets / "qs", assets_dir / "qs")
if target_id == "band-7":
shutil.copytree(common_assets / "timer", assets_dir / "timer")
shutil.copytree(common_assets / f"menu_{icon_size}", assets_dir / "menu")
# App.json
app_json["targets"][target_id]["module"] = {
"page": {
"pages": [f"page/{i}" for i in pages]
},
**module
}
with open("app.json", "w") as f:
f.write(json.dumps(app_json, indent=2, ensure_ascii=False))