Extracted webroot into usable files

This commit is contained in:
Gunnar Skjold
2020-01-31 21:08:27 +01:00
parent ced6f125fd
commit fc1f1554d8
14 changed files with 51 additions and 414 deletions

25
scripts/makeweb.py Normal file
View File

@@ -0,0 +1,25 @@
import os
import re
webroot = "web"
srcroot = "src/web/root"
if not os.path.exists(srcroot):
os.mkdir(srcroot)
for filename in os.listdir(webroot):
basename = re.sub("[^0-9a-zA-Z]+", "_", filename)
srcfile = webroot + "/" + filename
dstfile = srcroot + "/" + basename + ".h"
varname = basename.upper()
with open(dstfile, "w") as dst:
dst.write("const char ")
dst.write(varname)
dst.write("[] PROGMEM = R\"==\"==(\n")
with open(srcfile, "r") as src:
for line in src.readlines():
dst.write(line)
dst.write("\n)==\"==\";\n")