支持16byte分行和js

This commit is contained in:
2ndacc
2020-02-19 21:04:16 +08:00
parent b79b236fe3
commit 34f534bb24

View File

@@ -4,12 +4,14 @@ import os
import glob
import binascii
import gzip
import re
try:
io = __import__("io").BytesIO
except:
io = __import__("StringIO").StringIO
for fn in glob.glob('*.html'):
def gen(fn):
s = open(fn, 'rb').read()
dat = io()
with gzip.GzipFile(fileobj=dat, mode="w") as f:
@@ -20,6 +22,13 @@ for fn in glob.glob('*.html'):
except:
s = ','.join(["0x"+binascii.hexlify(c) for c in dat])
fn = fn.replace('.', '_')
print("const unsigned char %s[0x%x] = {%s};" % (fn, len(dat), s))
s = re.sub("((?:0x.+?,){16})", "\\1\n", s)
fn = fn.replace('.', '_')
print("const unsigned char %s[0x%x] = {\n%s};" % (fn, len(dat), s))
for fn in glob.glob('*.html'):
gen(fn)
for fn in glob.glob('*.js'):
gen(fn)