def before_buildfs(source, target, env):
print "before_buildfs"
# SPIFFS Stats With Different Combinations of Processing
# Updated: 12.28.2016
# No Processing
# 20 Files, 1.46 MB of 2.81 MB Used
# custom_option = "gz"
# 19 Files, 898.84 KB of 2.81 MB Used
# custom_option = "gz|css"
# 17 Files, 896.88 KB of 2.81 MB Used
# custom_option = "gz|css|js"
# 13 Files, 893.94 KB of 2.81 MB Used
# custom_option = "gz|css|js|media"
# 8 Files, 898.60 KB of 2.81 MB Used
# clone 'www' folder to 'data' folder
files = dir_util.copy_tree(www, data, )
# embed Javascript, CSS & media into html files
if re.search(r'css|js|media', options):
for file in files:
if re.search(r'\.htm', file):
print file
content = read_file(file)
if re.search(r'css', options):
content = embed_css( content )
if re.search(r'js', options):
content = combine_js( content )
if re.search(r'media', options):
content = embed_media( content )
# Save New HTML File
with open(file, 'w') as new_file:
new_file.write( content )
new_file.close()
# gzip appropriate files
if re.search(r'gz', options):
pattern = re.compile(ur'\.htm|\.css|\.js|\.map|\.svg|\.ico')
for file in files:
if re.search(pattern, file):
if os.path.exists(file):
print file
gzFile( file )
# remove 'data' folder after upload
评论列表
文章目录