Tighten configuration and export handling
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
from importlib import resources
|
||||
from typing import List
|
||||
from typing import Dict, List
|
||||
|
||||
from odf.opendocument import OpenDocument, load
|
||||
from odf.style import Style, TableCellProperties, TableColumnProperties
|
||||
from odf.table import Table, TableCell, TableColumn, TableRow
|
||||
from odf.text import P
|
||||
from odf.table import Table, TableColumn, TableRow, TableCell
|
||||
from odf.style import Style, TableColumnProperties, TableCellProperties
|
||||
from .base import Formatter
|
||||
|
||||
from ..types import ReportRow
|
||||
from ..utils import get_month_name_from_range
|
||||
from .base import Formatter
|
||||
|
||||
|
||||
class ODTFormatter(Formatter):
|
||||
@@ -25,11 +27,7 @@ class ODTFormatter(Formatter):
|
||||
Форматирует данные в объект OpenDocument.
|
||||
"""
|
||||
|
||||
with (
|
||||
resources.files("redmine_reporter")
|
||||
.joinpath("templates", "template.odt")
|
||||
.open("rb") as f
|
||||
):
|
||||
with resources.files("redmine_reporter").joinpath("templates/template.odt").open("rb") as f:
|
||||
doc = load(f)
|
||||
|
||||
para_style_name = "Standard"
|
||||
@@ -43,9 +41,7 @@ class ODTFormatter(Formatter):
|
||||
# Стиль ячеек
|
||||
cell_style_name = "TableCellStyle"
|
||||
cell_style = Style(name=cell_style_name, family="table-cell")
|
||||
cell_props = TableCellProperties(
|
||||
padding="0.04in", border="0.05pt solid #000000"
|
||||
)
|
||||
cell_props = TableCellProperties(padding="0.04in", border="0.05pt solid #000000")
|
||||
cell_style.addElement(cell_props)
|
||||
doc.automaticstyles.addElement(cell_style)
|
||||
|
||||
@@ -73,7 +69,7 @@ class ODTFormatter(Formatter):
|
||||
header_row.addElement(cell)
|
||||
table.addElement(header_row)
|
||||
|
||||
projects = {}
|
||||
projects: Dict[str, Dict[str, List[ReportRow]]] = {}
|
||||
for r in rows:
|
||||
project = r["project"]
|
||||
version = r["version"]
|
||||
@@ -103,9 +99,7 @@ class ODTFormatter(Formatter):
|
||||
# Ячейка "Проект" - только в первой строке всего проекта
|
||||
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)
|
||||
)
|
||||
cell_project.setAttribute("numberrowsspanned", str(total_project_rows))
|
||||
p = P(stylename=para_style_name, text=project)
|
||||
cell_project.addElement(p)
|
||||
row.addElement(cell_project)
|
||||
@@ -113,9 +107,7 @@ class ODTFormatter(Formatter):
|
||||
# Ячейка "Версия" - только в первой строке каждой версии
|
||||
if first_row_in_version:
|
||||
cell_version = TableCell(stylename=cell_style_name)
|
||||
cell_version.setAttribute(
|
||||
"numberrowsspanned", str(row_span_version)
|
||||
)
|
||||
cell_version.setAttribute("numberrowsspanned", str(row_span_version))
|
||||
p = P(stylename=para_style_name, text=version)
|
||||
cell_version.addElement(p)
|
||||
row.addElement(cell_version)
|
||||
|
||||
Reference in New Issue
Block a user