-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle_template.py
82 lines (75 loc) · 2.09 KB
/
single_template.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
79
80
81
82
import pickle
import os
import time
import webbrowser
from _main import *
environment = get_jinja_env()
"""
path = "page/en/album.html"
name = "en/album/01.html"
data_path = "exported_data/album/01.json"
path = "page/en/track.html"
name = "en/track/ost/16.html"
data_path = "exported_data/track/ost/16.json"
"""
'''
path = "page/zh_cn/character_all.html"
name = "zh_cn/character/student/hoshino/index.html"
data_path = "exported_data/character/_all.json"
'''
'''
path = "page/en/background.html"
name = "en/background/BG_CS_Abydos_01.jpg.html"
data_path = "exported_data/background/BG_CS_Abydos_01.jpg.json"
'''
'''
path = "page/zh_cn/tag.html"
name = "zh_cn/tag/sad.html"
data_path = "exported_data/tag/sad.json"
'''
'''
path = "page/zh_cn/track_all.html"
name = "zh_cn/track/ost/index.html"
data_path = "exported_data/track/ost/_all.json"
'''
'''
path = "page/zh_cn/story.html"
name = "en/main/story/main/2/2/25.html"
data_path = "exported_data/character/student/mika/bond/01.json"
'''
'''
path = "page/zh_cn/student.html"
name = "zh_cn/character/student/hoshino/index.html"
data_path = "exported_data/character/student/ui/ui.json"
'''
'''
path = "page/zh_cn/npc.html"
name = "zh_cn/character/student/hoshino/index.html"
data_path = "exported_data/character/npc/Sora/Sora.json"
'''
'''
path = "page/en/composer.html"
name = "en/composer/1.html"
data_path = "exported_data/composer/1.json"
'''
'''
path = "page/zh_cn/event_story_all.html"
name = "en/main/story/main/2/2/25.html"
data_path = "exported_data/event/810/story/_all.json"
'''
'''
path = "page/en/ui.html"
name = "en/ui/1.html"
# data_path = "exported_data/ui/1.json"
data_path = "exported_data/event/812/ui/1.json"
'''
with open(data_path, mode="rb") as file:
data = pickle.load(file)
template = environment.get_template(path)
st = time.time_ns()
result = template.render(is_static="", ui=data)
print((time.time_ns() - st) / 1e+6)
os.makedirs(os.path.split(os.path.join("data_html/", name))[0], exist_ok=True)
with open(os.path.join("data_html/", name), mode="w", encoding="UTF-8") as file:
file.write(result)
webbrowser.open("http://localhost:9000/" + name)