Make a simple table in html log output (#1286)

This commit is contained in:
AlexL 2023-12-12 22:33:28 +01:00 committed by GitHub
parent 1ee5d24f33
commit 9cd3c06c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,9 @@ def log(img, dic, single_line_number=3):
div_name = only_name.replace('.', '_') div_name = only_name.replace('.', '_')
item = f'<div id="{div_name}">\n' item = f'<div id="{div_name}">\n'
item += f"<p>{only_name}</p>\n" item += "<table><tr>"
item += f"<td><img src=\"{only_name}\" width=auto height=100% loading=lazy style=\"height:auto;max-width:512px\" onerror=\"document.getElementById('{div_name}').style.display = 'none';\"></img></p></td>"
item += f"<td><p>{only_name}</p>\n"
for i, (k, v) in enumerate(dic): for i, (k, v) in enumerate(dic):
if i < single_line_number: if i < single_line_number:
item += f"<p>{k}: <b>{v}</b></p>\n" item += f"<p>{k}: <b>{v}</b></p>\n"
@ -44,7 +46,8 @@ def log(img, dic, single_line_number=3):
item += f"<p>{k}: <b>{v}</b>, " item += f"<p>{k}: <b>{v}</b>, "
else: else:
item += f"{k}: <b>{v}</b></p>\n" item += f"{k}: <b>{v}</b></p>\n"
item += f"<p><img src=\"{only_name}\" width=auto height=100% loading=lazy style=\"height:auto;max-width:512px\" onerror=\"document.getElementById('{div_name}').style.display = 'none';\"></img></p><hr></div>\n" item += "</td>"
item += "</tr></table><hr></div>\n"
existing_log = item + existing_log existing_log = item + existing_log
with open(html_name, 'w', encoding='utf-8') as f: with open(html_name, 'w', encoding='utf-8') as f: