-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_html.py
More file actions
executable file
·39 lines (29 loc) · 1.2 KB
/
Copy pathupdate_html.py
File metadata and controls
executable file
·39 lines (29 loc) · 1.2 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
32
33
34
#!/usr/bin/python3
if __name__ == "__main__":
web_path = "web/"
html_file = "index.html"
js_file = "sw.js"
css_file = "style.css"
template_file = "htmltemplate.cpp"
with open(web_path+html_file,"r") as fhtml:
html = fhtml.readlines()
with open("sketches/timinggatecontroller/{}".format(template_file),"w") as hf:
hf.write('#include "htmltemplate.h"\n\n')
hf.write('namespace HTML\n{\n\n')
hf.write('const char PROGMEM index[] = R"rawliteral(\n')
for ln in html:
if ln.count(css_file) > 0:
hf.write(' <style>\n')
with open(web_path+css_file, "r") as css:
for ln_css in css.readlines():
hf.write(' {}'.format(ln_css))
hf.write(' </style>\n')
elif ln.count(js_file) > 0:
hf.write(' <script>\n')
with open(web_path+js_file, "r") as js:
for ln_js in js.readlines():
hf.write(' {}'.format(ln_js))
hf.write(' </script>\n')
else:
hf.write(ln)
hf.write('\n)rawliteral";\n\n} // namespace HTML\n')