Fix 9 bugs: ODT covered-cells, CSV BOM, HTML charset, stderr, dead code
- #13 (critical): Add CoveredTableCell elements to ODT for valid row spans (ODF 1.2) - #28: Move "Total issues" info message from stdout to stderr (clean pipe output) - #27: Wrap HTML export in full document with DOCTYPE and meta charset utf-8 - #26: Save CSV with utf-8-sig encoding (UTF-8 BOM for Excel compatibility) - #31: Document CSV uses full project/version values (not display_* like console/MD) - #30: Fix ODT header formatting when author is empty (no leading dot/space) - #36: Remove test_cli_smoke_empty testing unreachable code path (return []) - #37: Remove unused mock_path variable in ODT test fixture - #34: Remove unreachable len(parts) != 2 check in parse_date_range Closes #13, #28, #27, #26, #31, #30, #36, #37, #34
This commit is contained in:
@@ -3,7 +3,7 @@ from typing import List
|
||||
|
||||
from odf.opendocument import OpenDocument, load
|
||||
from odf.style import Style, TableCellProperties, TableColumnProperties
|
||||
from odf.table import Table, TableCell, TableColumn, TableRow
|
||||
from odf.table import CoveredTableCell, Table, TableCell, TableColumn, TableRow
|
||||
from odf.text import P
|
||||
|
||||
from ..report_builder import group_rows_by_project_and_version
|
||||
@@ -35,7 +35,10 @@ class ODTFormatter(Formatter):
|
||||
|
||||
# Заголовок
|
||||
month_name = get_month_name_from_range(self.from_date, self.to_date)
|
||||
header_text = f"{self.author}. Отчет за месяц {month_name}."
|
||||
if self.author:
|
||||
header_text = f"{self.author}. Отчет за месяц {month_name}."
|
||||
else:
|
||||
header_text = f"Отчет за месяц {month_name}."
|
||||
doc.text.addElement(P(stylename=para_style_name, text=header_text))
|
||||
doc.text.addElement(P(stylename=para_style_name, text=""))
|
||||
|
||||
@@ -86,15 +89,19 @@ class ODTFormatter(Formatter):
|
||||
for r in rows_for_version:
|
||||
row = TableRow()
|
||||
|
||||
# Ячейка "Проект" - только в первой строке всего проекта
|
||||
# Ячейка "Проект" - только в первой строке всего проекта,
|
||||
# в остальных — covered-cell для валидности ODF (#13)
|
||||
if first_version_in_project and first_row_in_version:
|
||||
cell_project = TableCell(stylename=cell_style_name)
|
||||
cell_project.setAttribute("numberrowsspanned", str(total_project_rows))
|
||||
p = P(stylename=para_style_name, text=project)
|
||||
cell_project.addElement(p)
|
||||
row.addElement(cell_project)
|
||||
else:
|
||||
row.addElement(CoveredTableCell())
|
||||
|
||||
# Ячейка "Версия" - только в первой строке каждой версии
|
||||
# Ячейка "Версия" - только в первой строке каждой версии,
|
||||
# в остальных — covered-cell для валидности ODF (#13)
|
||||
if first_row_in_version:
|
||||
cell_version = TableCell(stylename=cell_style_name)
|
||||
cell_version.setAttribute("numberrowsspanned", str(row_span_version))
|
||||
@@ -102,6 +109,8 @@ class ODTFormatter(Formatter):
|
||||
cell_version.addElement(p)
|
||||
row.addElement(cell_version)
|
||||
first_row_in_version = False
|
||||
else:
|
||||
row.addElement(CoveredTableCell())
|
||||
|
||||
# Остальные колонки
|
||||
task_cell = TableCell(stylename=cell_style_name)
|
||||
|
||||
Reference in New Issue
Block a user