def writetoHTML(html_file, defaultInfo):
html_handle = open(html_file, 'w')
current_dir = os.path.dirname(__file__)
with open(current_dir + '/lib/template.html') as report:
for line in report:
line = line.strip()
print(line, file=html_handle)
try:
start_index = line.index("^^")
stop_index = line.index("$$")
if (line[start_index+2: stop_index] == 'defaultInfo'):
print(defaultInfo, file=html_handle)
else:
file_path = current_dir + '/lib' + line[start_index+2: stop_index]
with open(file_path) as fh:
for subline in fh:
subline = subline.strip()
print(subline, file=html_handle)
except ValueError:
pass
html_handle.close()
print("HTML report successfully saved to " + html_file)
评论列表
文章目录