Support Python 3.11 in HTML renderer
This commit is contained in:
@@ -3061,7 +3061,7 @@ def render_observation_5a_html(data: dict, section_number: int = 14) -> str:
|
|||||||
rows = []
|
rows = []
|
||||||
for row in obs.get("rows", []):
|
for row in obs.get("rows", []):
|
||||||
cells = row.get("cells", [])
|
cells = row.get("cells", [])
|
||||||
rows.append("".join(f"<td>{html_escape(text_5a(cell)) if cell else '<span class=\"write-box\"></span>'}</td>" for cell in cells))
|
rows.append("".join(f"<td>{html_or_write_box(cell, 'write-box')}</td>" for cell in cells))
|
||||||
table = f'<table class="obs-table"><thead><tr>{headers}</tr></thead><tbody>' + "".join(f"<tr>{row}</tr>" for row in rows) + "</tbody></table>"
|
table = f'<table class="obs-table"><thead><tr>{headers}</tr></thead><tbody>' + "".join(f"<tr>{row}</tr>" for row in rows) + "</tbody></table>"
|
||||||
return section_box_5a_html(section_number, obs.get("title", "Karta obserwacji"), table, "dense")
|
return section_box_5a_html(section_number, obs.get("title", "Karta obserwacji"), table, "dense")
|
||||||
|
|
||||||
@@ -3072,7 +3072,7 @@ def render_troubleshooting_5a_html(data: dict, section_number: int = 15) -> str:
|
|||||||
f'<td>{html_escape(text_5a(row.get("symptom", "")))}</td>'
|
f'<td>{html_escape(text_5a(row.get("symptom", "")))}</td>'
|
||||||
f'<td>{html_escape(text_5a(row.get("hypothesis", "")))}</td>'
|
f'<td>{html_escape(text_5a(row.get("hypothesis", "")))}</td>'
|
||||||
f'<td>{html_escape(text_5a(row.get("action", "")))}</td>'
|
f'<td>{html_escape(text_5a(row.get("action", "")))}</td>'
|
||||||
f'<td>{html_escape(text_5a(row.get("result", ""))) if row.get("result") else "<span class=\"write-box small\"></span>"}</td>'
|
f'<td>{html_or_write_box(row.get("result", ""), "write-box small")}</td>'
|
||||||
'</tr>'
|
'</tr>'
|
||||||
for row in data.get("troubleshooting", [])
|
for row in data.get("troubleshooting", [])
|
||||||
)
|
)
|
||||||
@@ -3080,6 +3080,12 @@ def render_troubleshooting_5a_html(data: dict, section_number: int = 15) -> str:
|
|||||||
return section_box_5a_html(section_number, "Troubleshooting log", table, "dense")
|
return section_box_5a_html(section_number, "Troubleshooting log", table, "dense")
|
||||||
|
|
||||||
|
|
||||||
|
def html_or_write_box(value: object, class_name: str) -> str:
|
||||||
|
if value:
|
||||||
|
return html_escape(text_5a(value))
|
||||||
|
return f'<span class="{html_escape(class_name)}"></span>'
|
||||||
|
|
||||||
|
|
||||||
def render_analysis_5a_html(data: dict, section_number: int = 16, line_count: int = 3) -> str:
|
def render_analysis_5a_html(data: dict, section_number: int = 16, line_count: int = 3) -> str:
|
||||||
answer_lines = "".join("<i></i>" for _ in range(line_count))
|
answer_lines = "".join("<i></i>" for _ in range(line_count))
|
||||||
items = "".join(
|
items = "".join(
|
||||||
|
|||||||
Reference in New Issue
Block a user