mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-11 18:55:37 +00:00
Extracted webroot into usable files
This commit is contained in:
25
scripts/makeweb.py
Normal file
25
scripts/makeweb.py
Normal 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")
|
||||
Reference in New Issue
Block a user