Added support Python 3 in "make_header.py" file

This commit is contained in:
Mintormo 2018-05-19 16:51:49 +03:00
parent 228b09bafb
commit 5d28a21454

View file

@ -4,15 +4,16 @@ import os
import glob
import string
enc = "utf-8"
# Generate include files
f = open("theme_data.h", "wb")
f.write("// THIS FILE HAS BEEN AUTOGENERATED, DON'T EDIT!!\n")
f.write(b"// THIS FILE HAS BEEN AUTOGENERATED, DON\'T EDIT!!\n")
# Generate png image block
f.write("\n// png image block\n");
f.write(b"\n// png image block\n")
pixmaps = glob.glob("*.png")
pixmaps.sort()
@ -21,22 +22,23 @@ for x in pixmaps:
var_str = x[:-4] + "_png"
f.write("\nstatic const unsigned char " + var_str + "[] = {\n\t")
s = "\nstatic const unsigned char " + var_str + "[] = {\n\t"
f.write(s.encode(enc))
pngf = open(x, "rb")
b = pngf.read(1)
while(len(b) == 1):
f.write(hex(ord(b)))
f.write(hex(ord(b)).encode(enc))
b = pngf.read(1)
if (len(b) == 1):
f.write(", ")
f.write(b", ")
f.write("\n};\n")
f.write(b"\n};\n")
pngf.close()
# Generate shaders block
f.write("\n// shaders block\n");
f.write(b"\n// shaders block\n");
shaders = glob.glob("*.gsl")
shaders.sort()
@ -45,7 +47,8 @@ for x in shaders:
var_str = x[:-4] + "_shader_code"
f.write("\nstatic const char *" + var_str + " = \n")
s = "\nstatic const char *" + var_str + " = \n"
f.write(s.encode(enc))
sf = open(x, "rb")
@ -55,12 +58,13 @@ for x in shaders:
b = b[:-2]
if (b.endswith("\n")):
b = b[:-1]
f.write(" \"" + b)
s = ' \"' + b
f.write(s.encode(enc))
b = sf.readline()
if (b != ""):
f.write("\"\n")
f.write(b'"\n')
f.write("\";\n")
f.write(b'";\n')
sf.close()
f.close()